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
|
2022-12-20 14:05:32 +01:00
|
|
|
import devices
|
2023-01-25 07:40:33 +01:00
|
|
|
from function.modules import brightness_choose_n_action, heating_function
|
2022-12-20 14:05:32 +01:00
|
|
|
import logging
|
2023-01-25 07:40:33 +01:00
|
|
|
from function.rooms import room
|
2023-01-25 12:49:36 +01:00
|
|
|
from function.videv import videv_switching, videv_switch_brightness_color_temp, videv_heating, videv_multistate, videv_audio_player
|
2022-12-23 10:00:09 +01:00
|
|
|
import task
|
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 ground_floor_west_floor(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-84CCA8AD1148
|
|
|
|
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_SHELLY)
|
|
|
|
self.main_light_tradfri = devices.group(
|
|
|
|
devices.tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE % 1),
|
|
|
|
devices.tradfri_light(mqtt_client, config.TOPIC_GFW_FLOOR_MAIN_LIGHT_ZIGBEE % 2)
|
|
|
|
)
|
|
|
|
super().__init__(mqtt_client)
|
|
|
|
|
2022-12-20 14:05:32 +01:00
|
|
|
#
|
2023-01-25 07:40:33 +01:00
|
|
|
# Functionality initialisation
|
|
|
|
#
|
|
|
|
# Request silvercrest data of lead light after power on
|
|
|
|
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, True, self.main_light_tradfri[0].request_data, True)
|
|
|
|
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_FLOOR_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[0].add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_main_light.set_brightness_mcb)
|
|
|
|
self.main_light_tradfri[0].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_GFW_FLOOR_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 ground_floor_west_marion(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-E8DB84A1E067
|
|
|
|
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_SHELLY)
|
|
|
|
self.heating_valve = devices.brennenstuhl_heatingvalve(mqtt_client, config.TOPIC_GFW_MARION_HEATING_VALVE_ZIGBEE)
|
|
|
|
super().__init__(mqtt_client)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Functionality initialisation
|
|
|
|
#
|
|
|
|
# heating function
|
|
|
|
self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_GFW_MARION)
|
|
|
|
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_MARION_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.gui_heating = devices.nodered_gui_radiator(mqtt_client, config.TOPIC_GFW_MARION_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
|
2023-01-20 08:03:06 +01:00
|
|
|
#
|
|
|
|
self.main_light_videv = videv_switching(
|
|
|
|
mqtt_client, config.TOPIC_GFW_MARION_MAIN_LIGHT_VIDEV,
|
|
|
|
self.main_light_shelly, devices.shelly.KEY_OUTPUT_0
|
|
|
|
)
|
2023-01-25 07:40:33 +01:00
|
|
|
self.heating_function_videv = videv_heating(
|
|
|
|
mqtt_client, config.TOPIC_GFW_MARION_HEATING_VALVE_VIDEV,
|
|
|
|
self.heating_function
|
|
|
|
)
|
2022-12-20 14:05:32 +01:00
|
|
|
|
|
|
|
|
2023-01-25 07:40:33 +01:00
|
|
|
class ground_floor_west_dirk(room):
|
2022-12-22 20:12:57 +01:00
|
|
|
STATE_ACTIVE_DEVICE_MAIN_LIGHT = 0
|
|
|
|
STATE_ACTIVE_DEVICE_DESK_LIGHT = 1
|
|
|
|
STATE_ACTIVE_DEVICE_AMPLIFIER = 2
|
|
|
|
STATE_ACTIVE_DEVICE_MAX_VALUE = STATE_ACTIVE_DEVICE_AMPLIFIER
|
2022-12-23 10:00:09 +01:00
|
|
|
#
|
2022-12-25 16:31:22 +01:00
|
|
|
LED_ACTIVE_DEVICE_MAIN_LIGHT = devices.nodered_gui_leds.KEY_LED_0
|
|
|
|
LED_ACTIVE_DEVICE_DESK_LIGHT = devices.nodered_gui_leds.KEY_LED_1
|
|
|
|
LED_ACTIVE_DEVICE_AMPLIFIER = devices.nodered_gui_leds.KEY_LED_2
|
|
|
|
#
|
2022-12-23 10:00:09 +01:00
|
|
|
KEY_POWERPLUG_AMPLIFIER = devices.my_powerplug.KEY_OUTPUT_0
|
|
|
|
KEY_POWERPLUG_CD_PLAYER = devices.my_powerplug.KEY_OUTPUT_2
|
|
|
|
KEY_POWERPLUG_DESK_LIGHT = devices.my_powerplug.KEY_OUTPUT_1
|
|
|
|
KEY_POWERPLUG_PC_DOCK = devices.my_powerplug.KEY_OUTPUT_3
|
|
|
|
#
|
|
|
|
AUDIO_SOURCE_PC = 0
|
|
|
|
AUDIO_SOURCE_CD = 1
|
|
|
|
AUDIO_SOURCE_RASPI = 2
|
2022-12-22 20:12:57 +01:00
|
|
|
|
2022-12-20 14:05:32 +01:00
|
|
|
def __init__(self, mqtt_client):
|
2022-12-22 12:09:53 +01:00
|
|
|
#
|
2023-01-25 07:40:33 +01:00
|
|
|
# Device initialisation
|
|
|
|
#
|
|
|
|
# http://shelly1l-3C6105E44F27
|
|
|
|
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_SHELLY)
|
|
|
|
self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_ZIGBEE)
|
2022-12-27 14:39:53 +01:00
|
|
|
self.powerplug_common = devices.my_powerplug(mqtt_client, config.TOPIC_GFW_DIRK_POWERPLUG)
|
|
|
|
self.desk_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_ZIGBEE)
|
|
|
|
self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_GFW_DIRK_INPUT_DEVICE)
|
|
|
|
self.remote_amplifier = devices.remote(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_REMOTE)
|
2023-01-25 12:49:36 +01:00
|
|
|
self.spotify_state = devices.audio_status(mqtt_client, config.TOPIC_GFW_DIRK_SPOTIFY)
|
|
|
|
self.mpd_state = devices.audio_status(mqtt_client, config.TOPIC_GFW_DIRK_MPD)
|
2023-01-25 07:40:33 +01:00
|
|
|
self.heating_valve = devices.brennenstuhl_heatingvalve(mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_ZIGBEE)
|
|
|
|
super().__init__(mqtt_client)
|
2022-12-27 11:29:39 +01:00
|
|
|
#
|
2023-01-25 07:40:33 +01:00
|
|
|
# Functionality initialisation
|
|
|
|
#
|
|
|
|
# Button - Brightness functionality
|
|
|
|
self.brightness_functions = brightness_choose_n_action(self.button_tradfri)
|
2022-12-28 14:52:24 +01:00
|
|
|
self.brightness_functions.add(self.main_light_tradfri, self.main_light_shelly, devices.shelly.KEY_OUTPUT_0)
|
|
|
|
self.brightness_functions.add(self.desk_light_tradfri, self.powerplug_common, self.KEY_POWERPLUG_DESK_LIGHT)
|
|
|
|
self.brightness_functions.add(self.remote_amplifier, self.powerplug_common, self.KEY_POWERPLUG_AMPLIFIER)
|
2023-01-25 07:40:33 +01:00
|
|
|
# Button - Main light
|
2022-12-25 16:31:22 +01:00
|
|
|
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_TOGGLE,
|
|
|
|
self.main_light_shelly.toggle_output_0_mcb)
|
2023-01-25 07:40:33 +01:00
|
|
|
# Button - Desk light
|
2022-12-25 16:31:22 +01:00
|
|
|
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT,
|
|
|
|
self.powerplug_common.toggle_output_1_mcb)
|
2023-01-25 07:40:33 +01:00
|
|
|
# Button - Amplifier
|
|
|
|
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT_LONG,
|
|
|
|
self.powerplug_common.toggle_output_0_mcb)
|
|
|
|
# Button - CD player
|
|
|
|
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG,
|
|
|
|
self.powerplug_common.toggle_output_2_mcb)
|
|
|
|
# Button - PC dock
|
|
|
|
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT,
|
|
|
|
self.powerplug_common.toggle_output_3_mcb)
|
|
|
|
|
|
|
|
# Mediaplayer - Amplifier auto on
|
|
|
|
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.powerplug_common.set_output_0_mcb, True)
|
|
|
|
self.spotify_state.add_callback(devices.status.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True)
|
|
|
|
self.mpd_state.add_callback(devices.status.KEY_STATE, None, self.powerplug_common.set_output_0_mcb, True)
|
|
|
|
# Mediaplayer - Audio source selection
|
|
|
|
self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, True, self.audio_source_selector, True)
|
|
|
|
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, True, self.audio_source_selector, True)
|
|
|
|
self.spotify_state.add_callback(devices.status.KEY_STATE, True, self.audio_source_selector, True)
|
|
|
|
self.mpd_state.add_callback(devices.status.KEY_STATE, True, self.audio_source_selector, True)
|
|
|
|
self.audio_source = self.AUDIO_SOURCE_PC
|
|
|
|
|
|
|
|
# heating function
|
|
|
|
self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_GFW_DIRK)
|
|
|
|
|
|
|
|
##### TEMPORARY ###################################################################################################################
|
|
|
|
self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_DIRK_MAIN_LIGHT_GUI)
|
|
|
|
self.gui_desk_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_GUI)
|
|
|
|
self.gui_amplifier = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_GUI)
|
|
|
|
self.gui_cd_player = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_GUI)
|
|
|
|
self.gui_pc_dock = devices.nodered_gui_switch(mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_GUI)
|
|
|
|
# Callback initialisation
|
|
|
|
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_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)
|
2023-01-08 11:41:08 +01:00
|
|
|
self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.powerplug_common.set_output_1_mcb)
|
|
|
|
self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_desk_light.set_state_mcb)
|
|
|
|
self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_BRIGHTNESS, None, self.desk_light_tradfri.set_brightness_mcb)
|
|
|
|
self.gui_desk_light.add_callback(devices.nodered_gui_light.KEY_COLOR_TEMP, None, self.desk_light_tradfri.set_color_temp_mcb)
|
|
|
|
self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_desk_light.set_enable_mcb)
|
|
|
|
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_desk_light.set_brightness_mcb)
|
|
|
|
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_desk_light.set_color_temp_mcb)
|
|
|
|
self.gui_amplifier.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_0_mcb)
|
|
|
|
self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, None, self.gui_amplifier.set_state_mcb)
|
|
|
|
self.gui_cd_player.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_2_mcb)
|
|
|
|
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.gui_cd_player.set_state_mcb)
|
|
|
|
self.gui_pc_dock.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_3_mcb)
|
|
|
|
self.powerplug_common.add_callback(self.KEY_POWERPLUG_PC_DOCK, None, self.gui_pc_dock.set_state_mcb)
|
2023-01-25 07:40:33 +01:00
|
|
|
|
|
|
|
self.gui_heating = devices.nodered_gui_radiator(mqtt_client, config.TOPIC_GFW_DIRK_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)
|
|
|
|
|
|
|
|
self.gui_led_active_device = devices.nodered_gui_leds(mqtt_client, config.TOPIC_GFW_DIRK_DEVICE_CHOOSER_LED)
|
|
|
|
|
|
|
|
def update_active_device_led(device, key, data):
|
|
|
|
for i in range(0, len(self.brightness_functions.brightness_device_list)):
|
|
|
|
self.gui_led_active_device.set_led(devices.nodered_gui_leds.KEY_LED_LIST[i], data == i)
|
|
|
|
self.brightness_functions.add_callback(brightness_choose_n_action.KEY_ACTIVE_DEVICE, None, update_active_device_led, True)
|
|
|
|
##### 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_GFW_DIRK_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
|
|
|
|
)
|
|
|
|
self.desk_light_videv = videv_switch_brightness_color_temp(
|
|
|
|
mqtt_client, config.TOPIC_GFW_DIRK_DESK_LIGHT_VIDEV,
|
|
|
|
self.powerplug_common, self.KEY_POWERPLUG_DESK_LIGHT,
|
|
|
|
self.desk_light_tradfri, devices.tradfri_light.KEY_BRIGHTNESS,
|
|
|
|
self.desk_light_tradfri, devices.tradfri_light.KEY_COLOR_TEMP
|
|
|
|
)
|
|
|
|
self.amplifier_videv = videv_switching(
|
|
|
|
mqtt_client, config.TOPIC_GFW_DIRK_AMPLIFIER_VIDEV,
|
|
|
|
self.powerplug_common, self.KEY_POWERPLUG_AMPLIFIER
|
|
|
|
)
|
|
|
|
self.cd_player_videv = videv_switching(
|
|
|
|
mqtt_client, config.TOPIC_GFW_DIRK_CD_PLAYER_VIDEV,
|
|
|
|
self.powerplug_common, self.KEY_POWERPLUG_CD_PLAYER
|
|
|
|
)
|
|
|
|
self.pc_dock_videv = videv_switching(
|
|
|
|
mqtt_client, config.TOPIC_GFW_DIRK_PC_DOCK_VIDEV,
|
|
|
|
self.powerplug_common, self.KEY_POWERPLUG_PC_DOCK
|
|
|
|
)
|
2023-01-25 07:40:33 +01:00
|
|
|
self.heating_function_videv = videv_heating(
|
|
|
|
mqtt_client, config.TOPIC_GFW_DIRK_HEATING_VALVE_VIDEV,
|
|
|
|
self.heating_function
|
|
|
|
)
|
|
|
|
self.brightness_functions_device_videv = videv_multistate(
|
|
|
|
mqtt_client, config.TOPIC_GFW_DIRK_ACTIVE_BRIGHTNESS_DEVICE_VIDEV,
|
|
|
|
brightness_choose_n_action.KEY_ACTIVE_DEVICE, self.brightness_functions, 3
|
|
|
|
)
|
2023-01-25 12:49:36 +01:00
|
|
|
self.audio_player_videv = videv_audio_player(
|
|
|
|
mqtt_client, config.TOPIC_GFW_DIRK_AUDIO_PLAYER_VIDEV,
|
|
|
|
self.spotify_state, self.mpd_state
|
|
|
|
)
|
2023-01-25 07:40:33 +01:00
|
|
|
#
|
|
|
|
# Other stuff
|
|
|
|
#
|
|
|
|
self.delayed_task_remote = task.delayed(1.0, self.send_audio_source)
|
2022-12-25 16:31:22 +01:00
|
|
|
|
2022-12-22 08:10:56 +01:00
|
|
|
def all_off(self, device=None, key=None, data=None):
|
|
|
|
super().all_off(device, key, data)
|
2022-12-22 12:09:53 +01:00
|
|
|
self.powerplug_common.set_output_all(False)
|
|
|
|
|
2022-12-23 10:00:09 +01:00
|
|
|
def audio_source_selector(self, device, key, data):
|
|
|
|
if device == self.powerplug_common and key == self.KEY_POWERPLUG_CD_PLAYER:
|
2022-12-26 16:54:26 +01:00
|
|
|
# switch on of cd player
|
|
|
|
self.audio_source = self.AUDIO_SOURCE_CD
|
2022-12-23 10:00:09 +01:00
|
|
|
elif device in [self.spotify_state, self.mpd_state]:
|
2022-12-26 16:54:26 +01:00
|
|
|
# switch on raspi-source
|
|
|
|
self.audio_source = self.AUDIO_SOURCE_RASPI
|
2022-12-23 10:00:09 +01:00
|
|
|
elif device == self.powerplug_common and key == self.KEY_POWERPLUG_AMPLIFIER:
|
2022-12-26 16:54:26 +01:00
|
|
|
# switch on of amplifier -> select source and reset stored source value
|
2023-01-25 07:40:33 +01:00
|
|
|
self.delayed_task_remote.run()
|
2022-12-23 10:00:09 +01:00
|
|
|
|
|
|
|
def send_audio_source(self):
|
|
|
|
if self.audio_source == self.AUDIO_SOURCE_PC:
|
|
|
|
logger.info("Sending IR command to change audio source to pc")
|
|
|
|
self.remote_amplifier.set_line3()
|
|
|
|
elif self.audio_source == self.AUDIO_SOURCE_CD:
|
|
|
|
logger.info("Sending IR command to change audio source to cd")
|
|
|
|
self.remote_amplifier.set_cd()
|
|
|
|
elif self.audio_source == self.AUDIO_SOURCE_RASPI:
|
|
|
|
logger.info("Sending IR command to change audio source to raspi")
|
|
|
|
self.remote_amplifier.set_line1()
|
|
|
|
self.audio_source = self.AUDIO_SOURCE_PC
|