#!/usr/bin/env python # -*- coding: utf-8 -*- # import config from devdi import topic as props from function.db import get_radiator_data, set_radiator_data from function.modules import heating_function from function.rooms import room, room_collection from function.videv import videv_switch_brightness, videv_switch_brightness_color_temp, videv_heating, videv_switching 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__) loc = props.LOC_FFW class first_floor_west(room_collection): def __init__(self, mqtt_client, pd, vd): super().__init__(mqtt_client, pd, vd) self.floor = first_floor_west_floor(mqtt_client, pd, vd) self.bath = first_floor_west_bath(mqtt_client, pd, vd) self.julian = first_floor_west_julian(mqtt_client, pd, vd) self.livingroom = first_floor_west_living(mqtt_client, pd, vd) self.sleep = first_floor_west_sleep(mqtt_client, pd, vd) class first_floor_west_floor(room): def __init__(self, mqtt_client, pd, vd): roo = props.ROO_FLO # # Device initialisation # # http://shelly1-58BF25D848EA # main light self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL) super().__init__(mqtt_client, pd, vd) # # Virtual Device Interface # # main light self.main_light = videv_switching( mqtt_client, config.TOPIC_FFW_FLOOR_MAIN_LIGHT_VIDEV, self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0 ) class first_floor_west_julian(room): def __init__(self, mqtt_client, pd, vd): roo = props.ROO_JUL # # Device initialisation # # http://shelly1l-3C6105E43452 # main light self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL) self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL) # heating function self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA) super().__init__(mqtt_client, pd, vd) # # Functionality initialisation # # heating function self.heating_function = heating_function( self.heating_valve, config.DEFAULT_TEMPERATURE, **get_radiator_data(self.heating_valve.topic) ) self.heating_function.add_callback(None, None, set_radiator_data, True) # # Virtual Device Interface # # main light self.main_light_videv = videv_switch_brightness_color_temp( mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_VIDEV, self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0, self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS, self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP ) # heating function self.heating_function_videv = videv_heating( mqtt_client, config.TOPIC_FFW_JULIAN_HEATING_VALVE_VIDEV, self.heating_function ) class first_floor_west_bath(room): def __init__(self, mqtt_client, pd, vd): roo = props.ROO_BAT # # Device initialisation # # http://shelly1-58BF25D84219 # main light self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL) # heating function self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA) super().__init__(mqtt_client, pd, vd) # # Functionality initialisation # # heating function self.heating_function = heating_function( self.heating_valve, config.DEFAULT_TEMPERATURE, **get_radiator_data(self.heating_valve.topic) ) self.heating_function.add_callback(None, None, set_radiator_data, True) # # Virtual Device Interface # # main light self.main_light = videv_switching( mqtt_client, config.TOPIC_FFW_BATH_MAIN_LIGHT_VIDEV, self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0 ) # heating function self.heating_function_videv = videv_heating( mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_VIDEV, self.heating_function ) class first_floor_west_living(room): def __init__(self, mqtt_client, pd, vd): roo = props.ROO_LIV # # Device initialisation # # http://shelly1l-84CCA8ACE6A1 # main light self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL) self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL) # heating function self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA) super().__init__(mqtt_client, pd, vd) # # Functionality initialisation # # heating function self.heating_function = heating_function( self.heating_valve, config.DEFAULT_TEMPERATURE, **get_radiator_data(self.heating_valve.topic) ) self.heating_function.add_callback(None, None, set_radiator_data, True) # # Virtual Device Interface # # main light self.main_light_videv = videv_switch_brightness_color_temp( mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_VIDEV, self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0, self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS, self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP ) # heating function self.heating_function_videv = videv_heating( mqtt_client, config.TOPIC_FFW_LIVINGROOM_HEATING_VALVE_VIDEV, self.heating_function ) class first_floor_west_sleep(room): def __init__(self, mqtt_client, pd, vd): roo = props.ROO_SLP # # Device initialisation # # http://shelly1-3494546A51F2 # main light self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL) self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL) # heating function self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA) # window light self.window_light = pd.get(props.STG_ZFW, loc, roo, props.FUN_WIL) super().__init__(mqtt_client, pd, vd) # # Functionality initialisation # # heating function self.heating_function = heating_function( self.heating_valve, config.DEFAULT_TEMPERATURE, **get_radiator_data(self.heating_valve.topic) ) self.heating_function.add_callback(None, None, set_radiator_data, True) # main light self.main_light_shelly.add_callback(self.main_light_shelly.KEY_OUTPUT_0, None, self.window_light.set_output_0_mcb, True) # # Virtual Device Interface # # main light self.main_light_videv = videv_switch_brightness( mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_VIDEV, self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0, self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS ) # heating function self.heating_function_videv = videv_heating( mqtt_client, config.TOPIC_FFW_SLEEP_HEATING_VALVE_VIDEV, self.heating_function ) # window lamp self.windowlamp_videv = videv_switch_brightness_color_temp( mqtt_client, config.TOPIC_FFW_SLEEP_WINDOW_LAMP_VIDEV, self.window_light, self.window_light.KEY_OUTPUT_0, self.window_light, self.window_light.KEY_BRIGHTNESS, self.window_light, self.window_light.KEY_COLOR_TEMP )