smart_brain/function/first_floor_east.py

219 lines
9.7 KiB
Python
Raw Normal View History

2022-12-20 14:05:32 +01:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import config
import devices
from function.modules import brightness_choose_n_action, timer_on_activation, heating_function
2023-01-31 19:17:10 +01:00
from function.rooms import room, room_collection
from function.videv import videv_switching, videv_switch_brightness, videv_switching_timer, videv_switch_brightness_color_temp, videv_heating, videv_multistate
2023-01-30 12:20:02 +01:00
import logging
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-31 19:17:10 +01:00
class first_floor_east(room_collection):
def __init__(self, mqtt_client):
super().__init__(mqtt_client)
self.dining = first_floor_east_dining(mqtt_client)
self.floor = first_floor_east_floor(mqtt_client)
self.kitchen = first_floor_east_kitchen(mqtt_client)
self.livingroom = first_floor_east_living(mqtt_client)
self.sleep = first_floor_east_sleep(mqtt_client)
class first_floor_east_floor(room):
2022-12-20 14:05:32 +01:00
def __init__(self, mqtt_client):
#
# Device initialisation
#
2022-12-20 14:05:32 +01:00
# http://shelly1l-3C6105E4E629
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY)
super().__init__(mqtt_client)
#
# Virtual Device Interface
2023-01-20 08:03:06 +01:00
#
self.main_light = videv_switching(
mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_VIDEV,
self.main_light_shelly, devices.shelly.KEY_OUTPUT_0
)
2022-12-20 14:05:32 +01:00
class first_floor_east_kitchen(room):
2022-12-20 14:05:32 +01:00
def __init__(self, mqtt_client):
#
# Device initialisation
#
2022-12-20 14:05:32 +01:00
# http://shelly1l-8CAAB5616C01
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY)
# http://shelly1-e89f6d85a466/
self.circulation_pump_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY)
super().__init__(mqtt_client)
2023-01-09 16:42:18 +01:00
#
# Functionality initialisation
#
self.circulation_pump = timer_on_activation(self.circulation_pump_shelly, devices.shelly.KEY_OUTPUT_0, 10*60)
self.circulation_pump_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, True, self.main_light_shelly.flash_0_mcb, True)
#
# Virtual Device Interface
2023-01-20 08:03:06 +01:00
#
self.main_light_videv = videv_switching(
mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_VIDEV,
self.main_light_shelly, devices.shelly.KEY_OUTPUT_0
)
self.circulation_pump_videv = videv_switching_timer(
2023-01-20 08:03:06 +01:00
mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_VIDEV,
self.circulation_pump_shelly, devices.shelly.KEY_OUTPUT_0,
self.circulation_pump, timer_on_activation.KEY_TIMER
2023-01-20 08:03:06 +01:00
)
2023-01-09 16:42:18 +01:00
2022-12-20 14:05:32 +01:00
class first_floor_east_dining(room):
2022-12-20 14:05:32 +01:00
def __init__(self, mqtt_client):
#
# Device initialisation
#
2022-12-20 14:05:32 +01:00
# http://shelly1l-84CCA8ADD055
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY)
2022-12-27 14:39:53 +01:00
self.floorlamp_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)
2022-12-20 14:05:32 +01:00
if config.CHRISTMAS:
2022-12-27 14:39:53 +01:00
self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
super().__init__(mqtt_client)
2022-12-20 14:05:32 +01:00
#
# Functionality initialisation
2022-12-20 14:05:32 +01:00
#
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_powerplug.set_output_0_mcb, True)
#
# Virtual Device Interface
2023-01-20 08:03:06 +01:00
#
self.main_light_videv = videv_switching(
mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_VIDEV,
self.main_light_shelly, devices.shelly.KEY_OUTPUT_0
)
self.floorlamp_videv = videv_switching(
mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_VIDEV,
self.floorlamp_powerplug, devices.silvercrest_powerplug.KEY_OUTPUT_0
)
if config.CHRISTMAS:
self.garland_videv = videv_switching(
mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_VIDEV,
self.garland_powerplug, devices.silvercrest_powerplug.KEY_OUTPUT_0
)
2022-12-20 14:05:32 +01:00
class first_floor_east_sleep(room):
2022-12-20 14:05:32 +01:00
def __init__(self, mqtt_client):
#
# Device initialisation
#
2022-12-20 14:05:32 +01:00
# http://shelly1l-E8DB84A254C7
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY)
self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE)
2022-12-27 14:39:53 +01:00
self.bed_light_di_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE)
2023-01-12 06:46:20 +01:00
self.bed_light_ma_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_POWERPLUG)
self.heating_valve = devices.brennenstuhl_heatingvalve(mqtt_client, config.TOPIC_FFE_SLEEP_HEATING_VALVE_ZIGBEE)
2022-12-27 14:39:53 +01:00
self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_FFE_SLEEP_INPUT_DEVICE)
super().__init__(mqtt_client)
#
# Functionality initialisation
#
2023-01-09 16:42:18 +01:00
# button / brightness function
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.bed_light_di_tradfri, self.bed_light_di_tradfri, devices.tradfri_light.KEY_OUTPUT_0)
# button / main light
2022-12-22 07:55:56 +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)
# button / bed light
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT,
self.bed_light_di_tradfri.toggle_output_0_mcb)
2023-01-12 06:46:20 +01:00
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT_LONG,
self.bed_light_ma_powerplug.toggle_output_0_mcb)
# heating function
self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_FFE_SLEEP)
#
# Virtual Device Interface
2023-01-20 08:03:06 +01:00
#
self.main_light_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_FFE_SLEEP_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.bed_light_di_videv = videv_switch_brightness(
mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_VIDEV,
self.bed_light_di_tradfri, devices.tradfri_light.KEY_OUTPUT_0,
self.bed_light_di_tradfri, devices.tradfri_light.KEY_BRIGHTNESS,
)
self.bed_light_ma_videv = videv_switching(
mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_VIDEV,
self.bed_light_ma_powerplug, devices.silvercrest_powerplug.KEY_OUTPUT_0
)
self.heating_function_videv = videv_heating(
mqtt_client, config.TOPIC_FFE_SLEEP_HEATING_VALVE_VIDEV,
self.heating_function
)
self.brightness_functions_device_videv = videv_multistate(
mqtt_client, config.TOPIC_FFE_SLEEP_ACTIVE_BRIGHTNESS_DEVICE_VIDEV,
brightness_choose_n_action.KEY_ACTIVE_DEVICE, self.brightness_functions, 2
)
2022-12-20 14:05:32 +01:00
class first_floor_east_living(room):
2022-12-20 14:05:32 +01:00
def __init__(self, mqtt_client):
#
# Device initialisation
#
# http://shelly1l-3C6105E3F910
self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY)
self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE)
self.floorlamp_tradfri = devices.group(
*[devices.tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i) for i in range(1, 7)])
2022-12-24 12:08:08 +01:00
if config.CHRISTMAS:
2022-12-27 14:39:53 +01:00
self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)
self.powerplug_xmas_star = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
super().__init__(mqtt_client)
2022-12-20 14:05:32 +01:00
#
# Functionality initialisation
2022-12-20 14:05:32 +01:00
#
# floor lamp synchronisation with main_light
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_tradfri.set_output_0_mcb, True)
#
# Virtual Device Interface
2023-01-20 08:03:06 +01:00
#
self.main_light_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_FFE_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
)
self.floorlamp_videv = videv_switch_brightness_color_temp(
mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_VIDEV,
self.floorlamp_tradfri, devices.tradfri_light.KEY_OUTPUT_0,
self.floorlamp_tradfri, devices.tradfri_light.KEY_BRIGHTNESS,
self.floorlamp_tradfri, devices.tradfri_light.KEY_COLOR_TEMP
2023-01-20 08:03:06 +01:00
)
if config.CHRISTMAS:
self.xmas_tree_videv = videv_switching(
mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_VIDEV,
self.powerplug_xmas_tree, devices.silvercrest_powerplug.KEY_OUTPUT_0
)