added ground floor west main functionality
This commit is contained in:
parent
3c4336d05d
commit
a84a6f0ba5
@ -100,7 +100,7 @@ class base(dict):
|
|||||||
"Received data for (%s) %s - %s", self.topic, key, str(self.get(key)))
|
"Received data for (%s) %s - %s", self.topic, key, str(self.get(key)))
|
||||||
self.callback_caller(key, self[key])
|
self.callback_caller(key, self[key])
|
||||||
elif key not in self.RX_IGNORE_KEYS:
|
elif key not in self.RX_IGNORE_KEYS:
|
||||||
logger.warning('Got a message from \"%s\"with unparsed content "%s"', self.topic, key)
|
logger.warning('Got a message from \"%s\" with unparsed content "%s"', self.topic, key)
|
||||||
else:
|
else:
|
||||||
logger.debug("Ignoring key %s", key)
|
logger.debug("Ignoring key %s", key)
|
||||||
|
|
||||||
@ -133,6 +133,9 @@ class base(dict):
|
|||||||
return data
|
return data
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def set(self, key, data):
|
||||||
|
self.pack(key, data)
|
||||||
|
|
||||||
def pack(self, key, data):
|
def pack(self, key, data):
|
||||||
data = self.pack_filter(key, data)
|
data = self.pack_filter(key, data)
|
||||||
if self.TX_TOPIC is not None:
|
if self.TX_TOPIC is not None:
|
||||||
|
@ -6,6 +6,15 @@ import devices
|
|||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
# TODO: implement first floor west and dirk (ground floor west)
|
||||||
|
# TODO: implement bed light dirk fading by input device
|
||||||
|
# TODO: implement heating function sleep_madi
|
||||||
|
# TODO: implement garland
|
||||||
|
# TODO: implement circulation pump
|
||||||
|
# TODO: implement switch off functionality (except of switch off button transportation)
|
||||||
|
# TODO: WARNING - Got a message from "shellies/floor_eg_w"with unparsed content "event" and "event_cnt"
|
||||||
|
# TODO: implement warning message (incl. fixing all_functions.devicelist
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from config import APP_NAME as ROOT_LOGGER_NAME
|
from config import APP_NAME as ROOT_LOGGER_NAME
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -13,6 +22,52 @@ except ImportError:
|
|||||||
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class all_functions(object):
|
||||||
|
def __init__(self, mqtt_client):
|
||||||
|
self.rooms = {}
|
||||||
|
self.__devices__ = None
|
||||||
|
#
|
||||||
|
# first floor east
|
||||||
|
#
|
||||||
|
self.ffe_floor = first_floor_east_floor(mqtt_client)
|
||||||
|
self.ffe_kitchen = first_floor_east_kitchen(mqtt_client)
|
||||||
|
self.ffe_dining = first_floor_east_dining(mqtt_client)
|
||||||
|
self.ffe_sleep_madi = first_floor_east_sleep_madi(mqtt_client)
|
||||||
|
self.ffe_living = first_floor_east_living(mqtt_client)
|
||||||
|
#
|
||||||
|
# ground floor west
|
||||||
|
#
|
||||||
|
self.gfw_floor = ground_floor_west_floor(mqtt_client)
|
||||||
|
self.gfw_marion = ground_floor_west_marion(mqtt_client)
|
||||||
|
self.gfw_dirk = ground_floor_west_dirk(mqtt_client)
|
||||||
|
#
|
||||||
|
# Input devices and Off Buttons
|
||||||
|
#
|
||||||
|
self.ffe_button_tradfri_sleep = devices.tradfri_button(mqtt_client, topic="zigbee_og_e/input_device/og_east")
|
||||||
|
#
|
||||||
|
# Callback initialisation
|
||||||
|
#
|
||||||
|
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)
|
||||||
|
|
||||||
|
def devicelist(self):
|
||||||
|
raise Exception
|
||||||
|
# TODO: generate list by using getattr
|
||||||
|
if self.__devices__ is None:
|
||||||
|
self.__devices__ = []
|
||||||
|
for room in self.rooms:
|
||||||
|
for name, obj in inspect.getmembers(room):
|
||||||
|
if type(obj) in devices.DEVICE_TYPE_LIST():
|
||||||
|
self.__devices__.append(obj)
|
||||||
|
return self.__devices__
|
||||||
|
|
||||||
|
|
||||||
class room(object):
|
class room(object):
|
||||||
def gui_switch_feedback(self, device, key, data):
|
def gui_switch_feedback(self, device, key, data):
|
||||||
self.gui_switch_main_light.set_feedback(data)
|
self.gui_switch_main_light.set_feedback(data)
|
||||||
@ -87,6 +142,25 @@ class room_shelly_tradfri_light(room_shelly):
|
|||||||
self.main_light_tradfri.set_color_temp(data * 10)
|
self.main_light_tradfri.set_color_temp(data * 10)
|
||||||
|
|
||||||
|
|
||||||
|
class room_shelly_silvercrest_light(room_shelly_tradfri_light):
|
||||||
|
def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_brightness, topic_gui_color_temp):
|
||||||
|
super().__init__(mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_brightness, topic_gui_color_temp)
|
||||||
|
#
|
||||||
|
# Callback initialisation
|
||||||
|
#
|
||||||
|
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.get_initial_main_light_data)
|
||||||
|
#
|
||||||
|
self.main_light_shelly_last = None
|
||||||
|
|
||||||
|
def get_initial_main_light_data(self, device, key, data):
|
||||||
|
if data is True and self.main_light_shelly_last is not True:
|
||||||
|
self.send_init_message_main_light()
|
||||||
|
self.main_light_shelly_last = data
|
||||||
|
|
||||||
|
def send_init_message_main_light(self):
|
||||||
|
self.main_light_tradfri.mqtt_client.send(self.main_light_tradfri.topic + "/get", '{"state": ""}')
|
||||||
|
|
||||||
|
|
||||||
class first_floor_east_floor(room_shelly):
|
class first_floor_east_floor(room_shelly):
|
||||||
def __init__(self, mqtt_client):
|
def __init__(self, mqtt_client):
|
||||||
# http://shelly1l-3C6105E4E629
|
# http://shelly1l-3C6105E4E629
|
||||||
@ -269,41 +343,39 @@ class first_floor_east_living(room_shelly_tradfri_light):
|
|||||||
device.set_color_temp(data * 10)
|
device.set_color_temp(data * 10)
|
||||||
|
|
||||||
|
|
||||||
class all_functions(object):
|
class ground_floor_west_floor(room_shelly_silvercrest_light):
|
||||||
|
# https://shelly1l-84CCA8AD1148
|
||||||
def __init__(self, mqtt_client):
|
def __init__(self, mqtt_client):
|
||||||
self.rooms = {}
|
super().__init__(mqtt_client, "shellies/floor_eg_w", "gui/gfw_sw_floor",
|
||||||
self.__devices__ = None
|
"zigbee_eg_w/light/floor_eg_w/a", "gui/gfw_br_floor", "gui/gfw_ct_floor")
|
||||||
#
|
|
||||||
# first floor east
|
|
||||||
#
|
|
||||||
self.ffe_floor = first_floor_east_floor(mqtt_client)
|
|
||||||
self.ffe_kitchen = first_floor_east_kitchen(mqtt_client)
|
|
||||||
self.ffe_dining = first_floor_east_dining(mqtt_client)
|
|
||||||
self.ffe_sleep_madi = first_floor_east_sleep_madi(mqtt_client)
|
|
||||||
self.ffe_living = first_floor_east_living(mqtt_client)
|
|
||||||
#
|
|
||||||
# Input devices and Off Buttons
|
|
||||||
#
|
|
||||||
self.ffe_button_tradfri_sleep = devices.tradfri_button(mqtt_client, topic="zigbee_og_e/input_device/og_east")
|
|
||||||
#
|
#
|
||||||
# Callback initialisation
|
# Callback initialisation
|
||||||
#
|
#
|
||||||
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "toggle",
|
self.main_light_tradfri_2 = devices.tradfri_light(mqtt_client, "zigbee_eg_w/light/floor_eg_w/b")
|
||||||
self.ffe_sleep_madi.toggle_main_light)
|
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS,
|
||||||
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_up_click",
|
None, self.sync_brightness_main_light)
|
||||||
self.ffe_sleep_madi.toggle_bed_light_di)
|
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP,
|
||||||
self.ffe_button_tradfri_sleep.add_callback(devices.tradfri_button.KEY_ACTION, "brightness_down_click",
|
None, self.sync_color_temp_main_light)
|
||||||
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)
|
|
||||||
|
|
||||||
def devicelist(self):
|
def send_init_message_main_light(self):
|
||||||
raise Exception
|
return super().send_init_message_main_light()
|
||||||
# TODO: generate list by using getattr
|
self.main_light_tradfri_2.mqtt_client.send(self.main_light_tradfri_2.topic + "/get", '{"state": ""}')
|
||||||
if self.__devices__ is None:
|
|
||||||
self.__devices__ = []
|
def sync_brightness_main_light(self, device, key, data):
|
||||||
for room in self.rooms:
|
self.main_light_tradfri_2.set_brightness(data)
|
||||||
for name, obj in inspect.getmembers(room):
|
|
||||||
if type(obj) in devices.DEVICE_TYPE_LIST():
|
def sync_color_temp_main_light(self, device, key, data):
|
||||||
self.__devices__.append(obj)
|
self.main_light_tradfri_2.set_color_temp(data)
|
||||||
return self.__devices__
|
|
||||||
|
|
||||||
|
class ground_floor_west_marion(room_shelly):
|
||||||
|
# https://shelly1l-E8DB84A1E067
|
||||||
|
def __init__(self, mqtt_client):
|
||||||
|
super().__init__(mqtt_client, "shellies/marion", "gui/gfw_sw_marion")
|
||||||
|
|
||||||
|
|
||||||
|
class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||||
|
# https://shelly1l-3C6105E44F27
|
||||||
|
def __init__(self, mqtt_client):
|
||||||
|
super().__init__(mqtt_client, "shellies/dirk", "gui/gfw_sw_dirk",
|
||||||
|
"zigbee_eg_w/light/dirk", "gui/gfw_br_dirk", "gui/gfw_ct_dirk")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user