2022-12-20 14:05:32 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
|
2022-12-27 14:39:53 +01:00
|
|
|
import config
|
2023-01-20 08:03:06 +01:00
|
|
|
import devices
|
2022-12-20 14:05:32 +01:00
|
|
|
import logging
|
2023-01-25 07:40:33 +01:00
|
|
|
from function.modules import heating_function
|
|
|
|
from function.rooms import room
|
|
|
|
from function.videv import videv_switch_brightness, videv_switch_brightness_color_temp, videv_heating
|
2022-12-20 14:05:32 +01:00
|
|
|
|
2023-01-11 15:39:09 +01:00
|
|
|
|
2022-12-20 14:05:32 +01:00
|
|
|
try:
|
|
|
|
from config import APP_NAME as ROOT_LOGGER_NAME
|
|
|
|
except ImportError:
|
|
|
|
ROOT_LOGGER_NAME = 'root'
|
|
|
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
|
|
|
|
|
|
|
|
2023-01-25 07:40:33 +01:00
|
|
|
class first_floor_west_julian(room):
|
2022-12-20 14:05:32 +01:00
|
|
|
def __init__(self, mqtt_client):
|
2023-01-25 07:40:33 +01:00
|
|
|
#
|
|
|
|
# Device initialisation
|
|
|
|
#
|
|
|
|
# http://shelly1l-3C6105E43452
|
|
|
|
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_SHELLY)
|
|
|
|
self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_ZIGBEE)
|
|
|
|
super().__init__(mqtt_client)
|
|
|
|
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_GUI)
|
|
|
|
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
|
|
|
|
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
|
|
|
|
|
|
|
|
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
|
|
|
|
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
|
|
|
|
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
|
|
|
|
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
|
|
|
|
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Virtual Device Interface
|
2023-01-20 08:03:06 +01:00
|
|
|
#
|
|
|
|
self.main_light_videv = videv_switch_brightness_color_temp(
|
|
|
|
mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_VIDEV,
|
|
|
|
self.main_light_shelly, devices.shelly.KEY_OUTPUT_0,
|
|
|
|
self.main_light_tradfri, devices.tradfri_light.KEY_BRIGHTNESS,
|
|
|
|
self.main_light_tradfri, devices.tradfri_light.KEY_COLOR_TEMP
|
|
|
|
)
|
2022-12-20 14:05:32 +01:00
|
|
|
|
|
|
|
|
2023-01-25 07:40:33 +01:00
|
|
|
class first_floor_west_bath(room):
|
2023-01-11 15:39:09 +01:00
|
|
|
def __init__(self, mqtt_client):
|
2023-01-25 07:40:33 +01:00
|
|
|
#
|
|
|
|
# Device initialisation
|
|
|
|
#
|
|
|
|
self.heating_valve = devices.brennenstuhl_heatingvalve(mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_ZIGBEE)
|
|
|
|
super().__init__(mqtt_client)
|
|
|
|
#
|
|
|
|
# Functionality initialisation
|
|
|
|
#
|
|
|
|
# heating function
|
|
|
|
self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_FFW_BATH)
|
|
|
|
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
self.gui_heating = devices.nodered_gui_radiator(mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_GUI)
|
2023-01-25 11:17:29 +01:00
|
|
|
self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_CURRENT, None, self.gui_heating.set_temperature_mcb, True)
|
2023-01-25 07:40:33 +01:00
|
|
|
|
|
|
|
def set_heating_setpoint(device, key, data):
|
|
|
|
self.heating_function.set(heating_function.KEY_USER_TEMPERATURE_SETPOINT, data)
|
|
|
|
self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TEMP, None, set_heating_setpoint)
|
|
|
|
self.heating_function.add_callback(heating_function.KEY_TEMPERATURE_SETPOINT, None, self.gui_heating.set_setpoint_temperature_mcb, True)
|
|
|
|
|
|
|
|
def boost(device, key, data):
|
|
|
|
self.heating_function.set(heating_function.KEY_START_BOOST, data)
|
|
|
|
self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_BOOST, None, boost)
|
|
|
|
|
|
|
|
def setpoint_to_default(device, key, data):
|
|
|
|
self.heating_function.set(heating_function.KEY_SET_DEFAULT_TEMPERATURE, data)
|
|
|
|
self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SETPOINT_TO_DEFAULT, None, setpoint_to_default)
|
|
|
|
|
|
|
|
def away_mode(device, key, data):
|
|
|
|
self.heating_function.set(heating_function.KEY_AWAY_MODE, data)
|
|
|
|
self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_AWAY, None, away_mode)
|
|
|
|
self.heating_function.add_callback(heating_function.KEY_AWAY_MODE, None, self.gui_heating.set_away_mcb)
|
|
|
|
|
|
|
|
def summer_mode(device, key, data):
|
|
|
|
self.heating_function.set(heating_function.KEY_SUMMER_MODE, data)
|
|
|
|
self.gui_heating.add_callback(devices.nodered_gui_radiator.KEY_SUMMER, None, summer_mode)
|
|
|
|
self.heating_function.add_callback(heating_function.KEY_SUMMER_MODE, None, self.gui_heating.set_summer_mcb)
|
|
|
|
|
|
|
|
self.heating_function.add_callback(heating_function.KEY_BOOST_TIMER, None, self.gui_heating.set_timer_mcb)
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Virtual Device Interface
|
|
|
|
#
|
|
|
|
self.heating_function_videv = videv_heating(
|
|
|
|
mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_VIDEV,
|
|
|
|
self.heating_function
|
|
|
|
)
|
2023-01-20 08:03:06 +01:00
|
|
|
|
2023-01-14 19:39:51 +01:00
|
|
|
def all_off(self):
|
|
|
|
pass
|
2023-01-14 13:27:36 +01:00
|
|
|
|
|
|
|
|
2023-01-25 07:40:33 +01:00
|
|
|
class first_floor_west_living(room):
|
2023-01-14 13:27:36 +01:00
|
|
|
def __init__(self, mqtt_client):
|
2023-01-25 07:40:33 +01:00
|
|
|
#
|
|
|
|
# Device initialisation
|
|
|
|
#
|
|
|
|
# http://shelly1l-84CCA8ACE6A1
|
|
|
|
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_SHELLY)
|
|
|
|
self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_ZIGBEE)
|
|
|
|
super().__init__(mqtt_client)
|
|
|
|
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_GUI)
|
|
|
|
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
|
|
|
|
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
|
|
|
|
|
|
|
|
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
|
|
|
|
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
|
|
|
|
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_main_light.set_color_temp_mcb)
|
|
|
|
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
|
|
|
|
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.main_light_tradfri.set_color_temp_mcb)
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Virtual Device Interface
|
2023-01-20 08:03:06 +01:00
|
|
|
#
|
|
|
|
self.main_light_videv = videv_switch_brightness_color_temp(
|
|
|
|
mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_VIDEV,
|
|
|
|
self.main_light_shelly, devices.shelly.KEY_OUTPUT_0,
|
|
|
|
self.main_light_tradfri, devices.tradfri_light.KEY_BRIGHTNESS,
|
|
|
|
self.main_light_tradfri, devices.tradfri_light.KEY_COLOR_TEMP
|
|
|
|
)
|
2023-01-14 13:27:36 +01:00
|
|
|
|
|
|
|
|
2023-01-25 07:40:33 +01:00
|
|
|
class first_floor_west_sleep(room):
|
2023-01-14 13:27:36 +01:00
|
|
|
def __init__(self, mqtt_client):
|
2023-01-25 07:40:33 +01:00
|
|
|
#
|
|
|
|
# Device initialisation
|
|
|
|
#
|
|
|
|
# http://shelly1-3494546A51F2
|
|
|
|
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_SHELLY)
|
|
|
|
self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_ZIGBEE)
|
|
|
|
super().__init__(mqtt_client)
|
|
|
|
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_GUI)
|
|
|
|
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb)
|
|
|
|
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb)
|
|
|
|
|
|
|
|
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_enable_mcb)
|
|
|
|
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
|
|
|
|
self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.main_light_tradfri.set_brightness_mcb)
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
|
|
|
|
#
|
|
|
|
# Virtual Device Interface
|
2023-01-20 08:03:06 +01:00
|
|
|
#
|
|
|
|
self.main_light_videv = videv_switch_brightness(
|
|
|
|
mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_VIDEV,
|
|
|
|
self.main_light_shelly, devices.shelly.KEY_OUTPUT_0,
|
|
|
|
self.main_light_tradfri, devices.tradfri_light.KEY_BRIGHTNESS
|
|
|
|
)
|