121 lines
4.9 KiB
Python
121 lines
4.9 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
#
|
|
|
|
import config
|
|
from devdi import rooms
|
|
from function.db import get_radiator_data, set_radiator_data
|
|
from function.modules import heating_function
|
|
from function.rooms import room, room_collection
|
|
import logging
|
|
|
|
|
|
try:
|
|
from config import APP_NAME as ROOT_LOGGER_NAME
|
|
except ImportError:
|
|
ROOT_LOGGER_NAME = 'root'
|
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
|
|
|
|
|
class first_floor_west(room_collection):
|
|
def __init__(self, mqtt_client):
|
|
super().__init__(mqtt_client)
|
|
self.floor = first_floor_west_floor(mqtt_client)
|
|
self.bath = first_floor_west_bath(mqtt_client)
|
|
self.julian = first_floor_west_julian(mqtt_client)
|
|
self.livingroom = first_floor_west_living(mqtt_client)
|
|
self.sleep = first_floor_west_sleep(mqtt_client)
|
|
|
|
|
|
class first_floor_west_floor(rooms.ffw_floor, room):
|
|
def __init__(self, mqtt_client):
|
|
super().__init__(mqtt_client)
|
|
room.__init__(self, mqtt_client)
|
|
#
|
|
# connect videv and switch
|
|
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
|
|
|
|
|
|
class first_floor_west_julian(rooms.ffw_julian, room):
|
|
def __init__(self, mqtt_client):
|
|
super().__init__(mqtt_client)
|
|
room.__init__(self, mqtt_client)
|
|
#
|
|
# light <-> videv
|
|
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
|
|
self.videv_main_light.connect_br_device(self.light_main_light, self.light_main_light.KEY_BRIGHTNESS)
|
|
self.videv_main_light.connect_ct_device(self.light_main_light, self.light_main_light.KEY_COLOR_TEMP)
|
|
|
|
# heating function
|
|
self.heating_function = heating_function(
|
|
self.valve_heating,
|
|
config.DEFAULT_TEMPERATURE,
|
|
**get_radiator_data(self.valve_heating.topic)
|
|
)
|
|
self.heating_function.add_callback(None, None, set_radiator_data, True)
|
|
self.videv_heating.connect_heating_function(self.heating_function)
|
|
|
|
|
|
class first_floor_west_bath(rooms.ffw_bath, room):
|
|
def __init__(self, mqtt_client):
|
|
super().__init__(mqtt_client)
|
|
room.__init__(self, mqtt_client)
|
|
#
|
|
# light <-> videv
|
|
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
|
|
|
|
# heating function
|
|
self.heating_function = heating_function(
|
|
self.valve_heating,
|
|
config.DEFAULT_TEMPERATURE,
|
|
**get_radiator_data(self.valve_heating.topic)
|
|
)
|
|
self.heating_function.add_callback(None, None, set_radiator_data, True)
|
|
self.videv_heating.connect_heating_function(self.heating_function)
|
|
|
|
|
|
class first_floor_west_living(rooms.ffw_livingroom, room):
|
|
def __init__(self, mqtt_client):
|
|
super().__init__(mqtt_client)
|
|
room.__init__(self, mqtt_client)
|
|
#
|
|
# light <-> videv
|
|
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
|
|
self.videv_main_light.connect_br_device(self.light_main_light, self.light_main_light.KEY_BRIGHTNESS)
|
|
self.videv_main_light.connect_ct_device(self.light_main_light, self.light_main_light.KEY_COLOR_TEMP)
|
|
|
|
# heating function
|
|
self.heating_function = heating_function(
|
|
self.valve_heating,
|
|
config.DEFAULT_TEMPERATURE,
|
|
**get_radiator_data(self.valve_heating.topic)
|
|
)
|
|
self.heating_function.add_callback(None, None, set_radiator_data, True)
|
|
self.videv_heating.connect_heating_function(self.heating_function)
|
|
|
|
|
|
class first_floor_west_sleep(rooms.ffw_sleep, room):
|
|
def __init__(self, mqtt_client):
|
|
super().__init__(mqtt_client)
|
|
room.__init__(self, mqtt_client)
|
|
#
|
|
# light <-> videv
|
|
self.videv_main_light.connect_sw_device(self.switch_main_light, self.switch_main_light.KEY_OUTPUT_0)
|
|
self.videv_main_light.connect_br_device(self.light_main_light, self.light_main_light.KEY_BRIGHTNESS)
|
|
#
|
|
self.videv_window_light.connect_sw_device(self.light_window_light, self.light_window_light.KEY_OUTPUT_0)
|
|
self.videv_window_light.connect_br_device(self.light_window_light, self.light_window_light.KEY_BRIGHTNESS)
|
|
self.videv_window_light.connect_ct_device(self.light_window_light, self.light_window_light.KEY_COLOR_TEMP)
|
|
|
|
# main light -> window light
|
|
self.switch_main_light.add_callback(self.switch_main_light.KEY_OUTPUT_0, None, self.light_window_light.set_output_0_mcb, True)
|
|
|
|
# heating function
|
|
self.heating_function = heating_function(
|
|
self.valve_heating,
|
|
config.DEFAULT_TEMPERATURE,
|
|
**get_radiator_data(self.valve_heating.topic)
|
|
)
|
|
self.heating_function.add_callback(None, None, set_radiator_data, True)
|
|
self.videv_heating.connect_heating_function(self.heating_function)
|