smart_brain/function/__init__.py

78 lines
3.9 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
2022-12-19 16:11:35 +01:00
import devices
2022-12-20 14:05:32 +01:00
from function.ground_floor_west import ground_floor_west_floor, ground_floor_west_marion, ground_floor_west_dirk
from function.first_floor_west import first_floor_west_julian, first_floor_west_living
from function.first_floor_east import first_floor_east_floor, first_floor_east_kitchen, first_floor_east_dining, first_floor_east_sleep_madi, first_floor_east_living
2022-12-21 17:04:55 +01:00
from function.common import common_heating, common_circulation_pump
2022-12-20 14:28:44 +01:00
import inspect
from function import modules
# TODO: implement switch off functionality (except of switch off button transportation)
2022-12-20 10:18:32 +01:00
# TODO: implement garland (incl. day events like sunset, sunrise, ...)
# TODO: implement existing nodered functionality "dirk" (ground floor west)
2022-12-20 14:28:44 +01:00
# TODO: implement warning message
2022-12-19 16:11:35 +01:00
class all_functions(object):
def __init__(self, mqtt_client):
2022-12-20 19:38:57 +01:00
self.mqtt_client = mqtt_client
#
2022-12-20 19:38:57 +01:00
self.__devices__ = None
2022-12-21 17:04:55 +01:00
# ground floor west
2022-12-20 19:38:57 +01:00
self.gfw_floor = ground_floor_west_floor(self.mqtt_client)
self.gfw_marion = ground_floor_west_marion(self.mqtt_client)
self.gfw_dirk = ground_floor_west_dirk(self.mqtt_client)
2022-12-20 10:18:32 +01:00
# first floor west
2022-12-20 19:38:57 +01:00
self.ffw_julian = first_floor_west_julian(self.mqtt_client)
self.ffw_living = first_floor_west_living(self.mqtt_client)
# first floor east
2022-12-20 19:38:57 +01:00
self.ffe_floor = first_floor_east_floor(self.mqtt_client)
self.ffe_kitchen = first_floor_east_kitchen(self.mqtt_client)
self.ffe_dining = first_floor_east_dining(self.mqtt_client)
self.ffe_sleep_madi = first_floor_east_sleep_madi(self.mqtt_client)
self.ffe_living = first_floor_east_living(self.mqtt_client)
2022-12-21 17:04:55 +01:00
# heating and warm water
self.common_heat_sleep_madi = common_heating(self.mqtt_client)
self.common_circulation_pump = common_circulation_pump(self.mqtt_client)
2022-12-20 19:38:57 +01:00
#
2022-12-21 17:04:55 +01:00
# Interactions
#
2022-12-21 17:04:55 +01:00
# input device
2022-12-20 19:38:57 +01:00
self.init_input_device_sleep_madi_functionality()
2022-12-21 17:04:55 +01:00
# Circulation pump
self.init_circulation_pump()
2022-12-20 19:38:57 +01:00
def init_input_device_sleep_madi_functionality(self):
#
2022-12-20 19:38:57 +01:00
self.ffe_button_tradfri_sleep = devices.tradfri_button(
self.mqtt_client, topic="zigbee_og_e/input_device/og_east")
#
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "toggle",
self.ffe_sleep_madi.toggle_main_light)
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_up_click",
self.ffe_sleep_madi.toggle_bed_light_di)
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_down_click",
self.ffe_sleep_madi.toggle_bed_light_di)
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "arrow_right_click",
self.ffe_floor.toggle_main_light)
2022-12-20 19:38:57 +01:00
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, None,
self.ffe_sleep_madi.fade_light)
2022-12-21 17:04:55 +01:00
def init_circulation_pump(self):
self.common_circulation_pump.main_light_shelly.add_callback(
devices.shelly.KEY_OUTPUT_0, None, self.ffe_kitchen.flash_main_light)
def devicelist(self):
if self.__devices__ is None:
self.__devices__ = []
2022-12-20 14:28:44 +01:00
for name, obj in inspect.getmembers(self):
2022-12-20 15:32:59 +01:00
if obj.__class__.__module__ == "devices":
self.__devices__.append(obj)
elif obj.__class__.__module__.split('.')[0] == 'function':
2022-12-20 14:28:44 +01:00
for devicename, device in inspect.getmembers(obj):
if device.__class__.__module__ == "devices":
self.__devices__.append(device)
return self.__devices__