restructuring devices.nodered_gui* and the nodered_gui topics
This commit is contained in:
parent
836330640a
commit
fff16fd7d3
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -2,7 +2,7 @@
|
||||
"python.defaultInterpreterPath": "./venv/bin/python",
|
||||
"editor.formatOnSave": true,
|
||||
"autopep8.args": [
|
||||
"--max-line-length=120"
|
||||
"--max-line-length=150"
|
||||
],
|
||||
"editor.fontSize": 14,
|
||||
"emmet.includeLanguages": {
|
||||
|
@ -40,10 +40,6 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
BATTERY_WARN_LEVEL = 5
|
||||
|
||||
|
||||
def DEVICE_TYPE_LIST():
|
||||
return [shelly, silvercrest_powerplug, my_powerplug, tradfri_light, tradfri_button]
|
||||
|
||||
|
||||
def is_json(data):
|
||||
try:
|
||||
json.loads(data)
|
||||
@ -54,7 +50,7 @@ def is_json(data):
|
||||
|
||||
|
||||
class base(dict):
|
||||
TX_TOPIC = None
|
||||
TX_TOPIC = "set"
|
||||
TX_VALUE = 0
|
||||
TX_DICT = 1
|
||||
TX_TYPE = -1
|
||||
@ -98,11 +94,8 @@ class base(dict):
|
||||
self.__previous__[key] = prev_value
|
||||
# Filter, if needed
|
||||
self.unpack_filter(key)
|
||||
if prev_value != self.get(key):
|
||||
logger.info("Received new data for (%s) %s - %s", self.topic, key, str(self.get(key)))
|
||||
else:
|
||||
logger.debug("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], self.get(key) != self.__previous__.get(key))
|
||||
elif key not in self.RX_IGNORE_KEYS:
|
||||
logger.warning('Got a message from \"%s\" with unparsed content "%s"', self.topic, key)
|
||||
else:
|
||||
@ -147,24 +140,23 @@ class base(dict):
|
||||
logger.error(
|
||||
"Unknown tx type. Set TX_TYPE of class to a known value")
|
||||
else:
|
||||
logger.info("Sending data for (%s) %s - %s", self.topic, key, str(data))
|
||||
logger.debug("Sending data for (%s) %s - %s", self.topic, key, str(data))
|
||||
if self.TX_TYPE == self.TX_DICT:
|
||||
self.mqtt_client.send('/'.join([self.topic, self.TX_TOPIC]), json.dumps({key: data}))
|
||||
else:
|
||||
if type(data) not in [str, bytes]:
|
||||
data = json.dumps(data)
|
||||
self.mqtt_client.send('/'.join([self.topic, key, self.TX_TOPIC]
|
||||
if len(self.TX_TOPIC) > 0 else [self.topic, key]), data)
|
||||
self.mqtt_client.send('/'.join([self.topic, key, self.TX_TOPIC] if len(self.TX_TOPIC) > 0 else [self.topic, key]), data)
|
||||
else:
|
||||
logger.error(
|
||||
"Unknown tx toptic. Set TX_TOPIC of class to a known value")
|
||||
|
||||
def add_callback(self, key, data, callback):
|
||||
def add_callback(self, key, data, callback, on_change_only=False):
|
||||
"""
|
||||
key: key or None for all keys
|
||||
data: data or None for all data
|
||||
"""
|
||||
cb_tup = (key, data, callback)
|
||||
cb_tup = (key, data, callback, on_change_only)
|
||||
if cb_tup not in self.callback_list:
|
||||
self.callback_list.append(cb_tup)
|
||||
|
||||
@ -174,9 +166,10 @@ class base(dict):
|
||||
def warning_call_condition(self):
|
||||
return False
|
||||
|
||||
def callback_caller(self, key, data):
|
||||
for cb_key, cb_data, callback in self.callback_list:
|
||||
def callback_caller(self, key, data, value_changed):
|
||||
for cb_key, cb_data, callback, on_change_only in self.callback_list:
|
||||
if (cb_key == key or cb_key is None) and (cb_data == data or cb_data is None) and callback is not None:
|
||||
if not on_change_only or value_changed:
|
||||
callback(self, key, data)
|
||||
|
||||
def warning_caller(self):
|
||||
@ -202,19 +195,22 @@ class shelly(base):
|
||||
KEY_LONGPUSH_1 = "longpush/1"
|
||||
KEY_TEMPERATURE = "temperature"
|
||||
KEY_OVERTEMPERATURE = "overtemperature"
|
||||
KEY_ID = "id"
|
||||
KEY_MODEL = "model"
|
||||
KEY_MAC = "mac"
|
||||
KEY_IP = "ip"
|
||||
KEY_NEW_FIRMWARE = "new_fw"
|
||||
KEY_FIRMWARE_VERSION = "fw_ver"
|
||||
#
|
||||
TX_TOPIC = 'command'
|
||||
TX_TOPIC = "command"
|
||||
TX_TYPE = base.TX_VALUE
|
||||
TX_FILTER_DATA_KEYS = [KEY_OUTPUT_0, KEY_OUTPUT_1]
|
||||
#
|
||||
RX_KEYS = [KEY_OUTPUT_0, KEY_OUTPUT_1,
|
||||
KEY_INPUT_0, KEY_INPUT_1, KEY_LONGPUSH_0, KEY_LONGPUSH_1,
|
||||
KEY_OVERTEMPERATURE, KEY_TEMPERATURE]
|
||||
RX_IGNORE_TOPICS = [KEY_OUTPUT_0 + '/' + "energy", KEY_OUTPUT_1 + '/' + "energy",
|
||||
'input_event/0', 'input_event/1']
|
||||
RX_KEYS = [KEY_OUTPUT_0, KEY_OUTPUT_1, KEY_INPUT_0, KEY_INPUT_1, KEY_LONGPUSH_0, KEY_LONGPUSH_1, KEY_OVERTEMPERATURE, KEY_TEMPERATURE,
|
||||
KEY_ID, KEY_MODEL, KEY_MAC, KEY_IP, KEY_NEW_FIRMWARE, KEY_FIRMWARE_VERSION]
|
||||
RX_IGNORE_TOPICS = [KEY_OUTPUT_0 + '/' + "energy", KEY_OUTPUT_1 + '/' + "energy", 'input_event/0', 'input_event/1']
|
||||
RX_IGNORE_KEYS = ['temperature_f']
|
||||
RX_FILTER_DATA_KEYS = [KEY_INPUT_0, KEY_INPUT_1, KEY_LONGPUSH_0, KEY_LONGPUSH_1,
|
||||
KEY_OUTPUT_0, KEY_OUTPUT_1, KEY_OVERTEMPERATURE]
|
||||
RX_FILTER_DATA_KEYS = [KEY_INPUT_0, KEY_INPUT_1, KEY_LONGPUSH_0, KEY_LONGPUSH_1, KEY_OUTPUT_0, KEY_OUTPUT_1, KEY_OVERTEMPERATURE]
|
||||
|
||||
def __init__(self, mqtt_client, topic):
|
||||
super().__init__(mqtt_client, topic)
|
||||
@ -277,16 +273,31 @@ class shelly(base):
|
||||
"""state: [True, False, 'toggle']"""
|
||||
self.pack(self.KEY_OUTPUT_0, state)
|
||||
|
||||
def set_output_0_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.output_0 else logging.DEBUG, "%s: Changing output 0 to %s", self.topic, str(data))
|
||||
self.set_output_0(data)
|
||||
|
||||
def toggle_output_0_mcb(self, device, key, data):
|
||||
logger.info("%s: Toggeling output 0", self.topic)
|
||||
self.set_output_0('toggle')
|
||||
|
||||
def set_output_1(self, state):
|
||||
"""state: [True, False, 'toggle']"""
|
||||
self.pack(self.KEY_OUTPUT_1, state)
|
||||
|
||||
def set_output_1_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.output_1 else logging.DEBUG, "%s: Changing output 1 to %s", self.topic, str(data))
|
||||
self.set_output_1(data)
|
||||
|
||||
def toggle_output_1_mcb(self, device, key, data):
|
||||
logger.info("%s: Toggeling output 1", self.topic)
|
||||
self.set_output_1('toggle')
|
||||
|
||||
|
||||
class silvercrest_powerplug(base):
|
||||
KEY_LINKQUALITY = "linkquality"
|
||||
KEY_OUTPUT_0 = "state"
|
||||
#
|
||||
TX_TOPIC = 'set'
|
||||
TX_TYPE = base.TX_DICT
|
||||
TX_FILTER_DATA_KEYS = [KEY_OUTPUT_0]
|
||||
#
|
||||
@ -316,6 +327,14 @@ class silvercrest_powerplug(base):
|
||||
"""state: [True, False, 'toggle']"""
|
||||
self.pack(self.KEY_OUTPUT_0, state)
|
||||
|
||||
def set_output_0_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.output_0 else logging.DEBUG, "%s: Changing output 0 to %s", self.topic, str(data))
|
||||
self.set_output_0(data)
|
||||
|
||||
def toggle_output_0_mcb(self, device, key, data):
|
||||
logger.info("%s: Toggeling output 0", self.topic)
|
||||
self.set_output_0('toggle')
|
||||
|
||||
|
||||
class my_powerplug(base):
|
||||
KEY_OUTPUT_0 = "output/1"
|
||||
@ -325,7 +344,6 @@ class my_powerplug(base):
|
||||
KEY_OUTPUT_ALL = "output/all"
|
||||
KEY_OUTPUT_LIST = [KEY_OUTPUT_0, KEY_OUTPUT_1, KEY_OUTPUT_2, KEY_OUTPUT_3]
|
||||
#
|
||||
TX_TOPIC = 'set'
|
||||
TX_TYPE = base.TX_VALUE
|
||||
#
|
||||
RX_KEYS = [KEY_OUTPUT_0, KEY_OUTPUT_1, KEY_OUTPUT_2, KEY_OUTPUT_3]
|
||||
@ -369,22 +387,62 @@ class my_powerplug(base):
|
||||
"""state: [True, False, 'toggle']"""
|
||||
self.pack(self.KEY_OUTPUT_0, state)
|
||||
|
||||
def set_output_0_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.output_0 else logging.DEBUG, "%s: Changing output 0 to %s", self.topic, str(data))
|
||||
self.set_output_0(data)
|
||||
|
||||
def toggle_output_0_mcb(self, device, key, data):
|
||||
logger.info("%s: Toggeling output 0", self.topic)
|
||||
self.set_output_0('toggle')
|
||||
|
||||
def set_output_1(self, state):
|
||||
"""state: [True, False, 'toggle']"""
|
||||
self.pack(self.KEY_OUTPUT_1, state)
|
||||
|
||||
def set_output_1_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.output_1 else logging.DEBUG, "%s: Changing output 1 to %s", self.topic, str(data))
|
||||
self.set_output_1(data)
|
||||
|
||||
def toggle_output_1_mcb(self, device, key, data):
|
||||
logger.info("%s: Toggeling output 1", self.topic)
|
||||
self.set_output_1('toggle')
|
||||
|
||||
def set_output_2(self, state):
|
||||
"""state: [True, False, 'toggle']"""
|
||||
self.pack(self.KEY_OUTPUT_2, state)
|
||||
|
||||
def set_output_2_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.output_2 else logging.DEBUG, "%s: Changing output 2 to %s", self.topic, str(data))
|
||||
self.set_output_2(data)
|
||||
|
||||
def toggle_output_2_mcb(self, device, key, data):
|
||||
logger.info("%s: Toggeling output 2", self.topic)
|
||||
self.set_output_2('toggle')
|
||||
|
||||
def set_output_3(self, state):
|
||||
"""state: [True, False, 'toggle']"""
|
||||
self.pack(self.KEY_OUTPUT_3, state)
|
||||
|
||||
def set_output_3_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.output_3 else logging.DEBUG, "%s: Changing output 3 to %s", self.topic, str(data))
|
||||
self.set_output_3(data)
|
||||
|
||||
def toggle_output_3_mcb(self, device, key, data):
|
||||
logger.info("%s: Toggeling output 3", self.topic)
|
||||
self.set_output_3('toggle')
|
||||
|
||||
def set_output_all(self, state):
|
||||
"""state: [True, False, 'toggle']"""
|
||||
self.pack(self.KEY_OUTPUT_ALL, state)
|
||||
|
||||
def set_output_all_mcb(self, device, key, data):
|
||||
logger.info("%s: Changing all outputs to %s", self.topic, str(data))
|
||||
self.set_output_all(data)
|
||||
|
||||
def toggle_output_all_mcb(self, device, key, data):
|
||||
logger.info("%s: Toggeling all outputs", self.topic)
|
||||
self.set_output_0('toggle')
|
||||
|
||||
|
||||
class tradfri_light(base):
|
||||
KEY_LINKQUALITY = "linkquality"
|
||||
@ -393,7 +451,6 @@ class tradfri_light(base):
|
||||
KEY_COLOR_TEMP = "color_temp"
|
||||
KEY_BRIGHTNESS_FADE = "brightness_move"
|
||||
#
|
||||
TX_TOPIC = 'set'
|
||||
TX_TYPE = base.TX_DICT
|
||||
TX_FILTER_DATA_KEYS = [KEY_OUTPUT_0, KEY_BRIGHTNESS, KEY_COLOR_TEMP, KEY_BRIGHTNESS_FADE]
|
||||
#
|
||||
@ -408,7 +465,7 @@ class tradfri_light(base):
|
||||
if key == self.KEY_BRIGHTNESS:
|
||||
self[key] = (self[key] - 1) * 100 / 254
|
||||
elif key == self.KEY_COLOR_TEMP:
|
||||
self[key] = (self[key] - 250) * 100 / 204
|
||||
self[key] = (self[key] - 250) * 10 / 204
|
||||
else:
|
||||
super().unpack_filter(key)
|
||||
|
||||
@ -416,7 +473,7 @@ class tradfri_light(base):
|
||||
if key == self.KEY_BRIGHTNESS:
|
||||
return data * 254 / 100 + 1
|
||||
elif key == self.KEY_COLOR_TEMP:
|
||||
return data * 204 / 100 + 250
|
||||
return data * 204 / 10 + 250
|
||||
else:
|
||||
return super().pack_filter(key, data)
|
||||
|
||||
@ -435,12 +492,12 @@ class tradfri_light(base):
|
||||
|
||||
@property
|
||||
def brightness(self):
|
||||
"""rv: numeric value [0%, ..., 100%"""
|
||||
"""rv: numeric value [0%, ..., 100%]"""
|
||||
return self.get(self.KEY_BRIGHTNESS, 0)
|
||||
|
||||
@property
|
||||
def color_temp(self):
|
||||
"""rv: numeric value [0%, ..., 100%"""
|
||||
"""rv: numeric value [0, ..., 10]"""
|
||||
return self.get(self.KEY_COLOR_TEMP, 0)
|
||||
|
||||
#
|
||||
@ -450,10 +507,22 @@ class tradfri_light(base):
|
||||
"""state: [True, False, 'toggle']"""
|
||||
self.pack(self.KEY_OUTPUT_0, state)
|
||||
|
||||
def set_output_0_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.output_0 else logging.DEBUG, "%s: Changing output 0 to %s", self.topic, str(data))
|
||||
self.set_output_0(data)
|
||||
|
||||
def toggle_output_0_mcb(self, device, key, data):
|
||||
logger.info("%s: Toggeling output 0", self.topic)
|
||||
self.set_output_0('toggle')
|
||||
|
||||
def set_brightness(self, brightness):
|
||||
"""brightness: [0, ..., 100]"""
|
||||
self.pack(self.KEY_BRIGHTNESS, brightness)
|
||||
|
||||
def set_brightness_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.brightness else logging.DEBUG, "%s: Changing brightness to %s", self.topic, str(data))
|
||||
self.set_brightness(data)
|
||||
|
||||
def default_inc(self, speed=40):
|
||||
self.pack(self.KEY_BRIGHTNESS_FADE, speed)
|
||||
|
||||
@ -464,9 +533,13 @@ class tradfri_light(base):
|
||||
self.default_inc(0)
|
||||
|
||||
def set_color_temp(self, color_temp):
|
||||
"""color_temp: [0, ..., 100]"""
|
||||
"""color_temp: [0, ..., 10]"""
|
||||
self.pack(self.KEY_COLOR_TEMP, color_temp)
|
||||
|
||||
def set_color_temp_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.color_temp else logging.DEBUG, "%s: Changing color temperature to %s", self.topic, str(data))
|
||||
self.set_color_temp(data)
|
||||
|
||||
|
||||
class tradfri_button(base):
|
||||
ACTION_TOGGLE = "toggle"
|
||||
@ -488,8 +561,6 @@ class tradfri_button(base):
|
||||
KEY_ACTION = "action"
|
||||
KEY_ACTION_DURATION = "action_duration"
|
||||
#
|
||||
TX_TOPIC = ''
|
||||
#
|
||||
RX_KEYS = [KEY_LINKQUALITY, KEY_BATTERY, KEY_ACTION]
|
||||
RX_IGNORE_KEYS = ['update', KEY_ACTION_DURATION]
|
||||
|
||||
@ -514,7 +585,7 @@ class tradfri_button(base):
|
||||
return "Low battery level detected for %s. Battery level was %.0f%%." % (self.topic, self.get(self.KEY_BATTERY))
|
||||
|
||||
|
||||
class nodered_gui(base):
|
||||
class nodered_gui_heatvalve(base):
|
||||
KEY_FEEDBACK = "feedback"
|
||||
KEY_ENABLE = "enable"
|
||||
KEY_STATE = "state"
|
||||
@ -524,7 +595,6 @@ class nodered_gui(base):
|
||||
KEY_HEATING_SETPOINT = "heating_setpoint"
|
||||
KEY_OFF_BUTTON = "off_button"
|
||||
#
|
||||
TX_TOPIC = 'set'
|
||||
TX_TYPE = base.TX_VALUE
|
||||
#
|
||||
RX_KEYS = [KEY_STATE, KEY_BRIGHTNESS, KEY_COLOR_TEMP, KEY_HEATING_BOOST, KEY_HEATING_SETPOINT, KEY_OFF_BUTTON]
|
||||
@ -571,10 +641,114 @@ class nodered_gui(base):
|
||||
def set_feedback(self, data):
|
||||
self.pack(self.KEY_FEEDBACK, data)
|
||||
|
||||
def enable(self, data):
|
||||
|
||||
|
||||
class nodered_gui_button(base):
|
||||
KEY_STATE = "state"
|
||||
#
|
||||
RX_KEYS = [KEY_STATE]
|
||||
|
||||
#
|
||||
# RX
|
||||
#
|
||||
@property
|
||||
def state(self):
|
||||
"""rv: [True, False]"""
|
||||
return self.get(self.KEY_STATE)
|
||||
|
||||
|
||||
class nodered_gui_switch(nodered_gui_button):
|
||||
TX_TYPE = base.TX_VALUE
|
||||
|
||||
#
|
||||
# TX
|
||||
#
|
||||
def set_state(self, data):
|
||||
"""data: [True, False]"""
|
||||
self.pack(self.KEY_STATE, data)
|
||||
|
||||
def set_state_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.get(self.KEY_STATE) else logging.DEBUG, "%s: Changing data to %s", self.topic, str(data))
|
||||
self.set_state(data)
|
||||
|
||||
|
||||
class nodered_gui_brightness_color_temp(base):
|
||||
KEY_ENABLE = "enable"
|
||||
KEY_BRIGHTNESS = "brightness"
|
||||
KEY_COLOR_TEMP = "color_temp"
|
||||
#
|
||||
TX_TYPE = base.TX_VALUE
|
||||
#
|
||||
RX_KEYS = [KEY_ENABLE, KEY_BRIGHTNESS, KEY_COLOR_TEMP]
|
||||
|
||||
#
|
||||
# RX
|
||||
#
|
||||
@property
|
||||
def enable(self):
|
||||
"""rv: [True, False]"""
|
||||
return self.get(self.KEY_ENABLE)
|
||||
|
||||
@property
|
||||
def brightness(self):
|
||||
"""rv: [True, False]"""
|
||||
return self.get(self.KEY_BRIGHTNESS)
|
||||
|
||||
@property
|
||||
def color_temp(self):
|
||||
"""rv: [True, False]"""
|
||||
return self.get(self.KEY_COLOR_TEMP)
|
||||
|
||||
#
|
||||
# TX
|
||||
#
|
||||
def set_enable(self, data):
|
||||
"""data: [True, False]"""
|
||||
self.pack(self.KEY_ENABLE, data)
|
||||
|
||||
def set_enable_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.get(self.KEY_ENABLE) else logging.DEBUG, "%s: Changing enable to %s", self.topic, str(data))
|
||||
self.set_enable(data)
|
||||
|
||||
def set_brightness(self, data):
|
||||
"""data: [0%, ..., 100%]"""
|
||||
self.pack(self.KEY_BRIGHTNESS, data)
|
||||
|
||||
def set_brightness_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.get(self.KEY_BRIGHTNESS) else logging.DEBUG, "%s: Changing brightness to %s", self.topic, str(data))
|
||||
self.set_brightness(data)
|
||||
|
||||
def set_color_temp(self, data):
|
||||
"""data: [0, ..., 10]"""
|
||||
self.pack(self.KEY_COLOR_TEMP, data)
|
||||
|
||||
def set_color_temp_mcb(self, device, key, data):
|
||||
logger.log(logging.INFO if data != self.get(self.KEY_COLOR_TEMP) else logging.DEBUG,
|
||||
"%s: Changing color temperature to %s", self.topic, str(data))
|
||||
self.set_color_temp(data)
|
||||
|
||||
|
||||
class nodered_gui_leds(base):
|
||||
KEY_LED_0 = "led0"
|
||||
KEY_LED_1 = "led1"
|
||||
KEY_LED_2 = "led2"
|
||||
KEY_LED_3 = "led3"
|
||||
KEY_LED_4 = "led4"
|
||||
KEY_LED_5 = "led5"
|
||||
KEY_LED_6 = "led6"
|
||||
KEY_LED_7 = "led7"
|
||||
KEY_LED_8 = "led8"
|
||||
KEY_LED_9 = "led9"
|
||||
#
|
||||
TX_TYPE = base.TX_VALUE
|
||||
#
|
||||
RX_KEYS = [KEY_LED_0, KEY_LED_1, KEY_LED_2, KEY_LED_3, KEY_LED_4, KEY_LED_5, KEY_LED_6, KEY_LED_7, KEY_LED_8, KEY_LED_9]
|
||||
|
||||
def set_led(self, key, data):
|
||||
"""data: [True, False]"""
|
||||
logger.log(logging.INFO if data != self.get(key) else logging.DEBUG, "%s: Changing led state for %s to %s", self.topic, key, str(data))
|
||||
self.pack(key, data)
|
||||
|
||||
|
||||
class brennenstuhl_heatingvalve(base):
|
||||
KEY_LINKQUALITY = "linkquality"
|
||||
@ -589,17 +763,15 @@ class brennenstuhl_heatingvalve(base):
|
||||
KEY_VALVE_DETECTION = "valve_detection"
|
||||
KEY_WINDOW_DETECTION = "window_detection"
|
||||
#
|
||||
TX_TOPIC = 'set'
|
||||
TX_TYPE = base.TX_DICT
|
||||
#
|
||||
RX_KEYS = [KEY_LINKQUALITY, KEY_BATTERY, KEY_HEATING_SETPOINT, KEY_TEMPERATURE]
|
||||
RX_IGNORE_KEYS = [KEY_AWAY_MODE, KEY_CHILD_LOCK, KEY_PRESET,
|
||||
KEY_SYSTEM_MODE, KEY_VALVE_DETECTION, KEY_WINDOW_DETECTION]
|
||||
RX_IGNORE_KEYS = [KEY_AWAY_MODE, KEY_CHILD_LOCK, KEY_PRESET, KEY_SYSTEM_MODE, KEY_VALVE_DETECTION, KEY_WINDOW_DETECTION]
|
||||
|
||||
def __init__(self, mqtt_client, topic):
|
||||
super().__init__(mqtt_client, topic)
|
||||
self.mqtt_client.send(self.topic + '/' + self.TX_TOPIC, json.dumps(
|
||||
{self.KEY_WINDOW_DETECTION: "ON", self.KEY_CHILD_LOCK: "UNLOCK", self.KEY_VALVE_DETECTION: "ON", self.KEY_SYSTEM_MODE: "heat"}))
|
||||
self.mqtt_client.send(self.topic + '/' + self.TX_TOPIC, json.dumps({self.KEY_WINDOW_DETECTION: "ON",
|
||||
self.KEY_CHILD_LOCK: "UNLOCK", self.KEY_VALVE_DETECTION: "ON", self.KEY_SYSTEM_MODE: "heat"}))
|
||||
|
||||
def warning_call_condition(self):
|
||||
return self.get(self.KEY_BATTERY) <= BATTERY_WARN_LEVEL
|
||||
@ -628,6 +800,10 @@ class brennenstuhl_heatingvalve(base):
|
||||
def set_heating_setpoint(self, setpoint):
|
||||
self.pack(self.KEY_HEATING_SETPOINT, setpoint)
|
||||
|
||||
def set_heating_setpoint_mcb(self, device, key, data):
|
||||
logger.info("%s: Changing heating setpoint to %s", self.topic, str(data))
|
||||
self.set_heating_setpoint(data)
|
||||
|
||||
|
||||
class remote(base):
|
||||
KEY_CD = "CD"
|
||||
@ -643,19 +819,19 @@ class remote(base):
|
||||
#
|
||||
RX_IGNORE_TOPICS = [KEY_CD, KEY_LINE1, KEY_LINE3, KEY_MUTE, KEY_POWER, KEY_VOLUP, KEY_VOLDOWN]
|
||||
|
||||
def set_cd(self):
|
||||
def set_cd(self, device=None, key=None, data=None):
|
||||
self.pack(self.KEY_CD, None)
|
||||
|
||||
def set_line1(self):
|
||||
def set_line1(self, device=None, key=None, data=None):
|
||||
self.pack(self.KEY_LINE1, None)
|
||||
|
||||
def set_line3(self):
|
||||
def set_line3(self, device=None, key=None, data=None):
|
||||
self.pack(self.KEY_LINE3, None)
|
||||
|
||||
def set_mute(self):
|
||||
def set_mute(self, device=None, key=None, data=None):
|
||||
self.pack(self.KEY_MUTE, None)
|
||||
|
||||
def set_power(self):
|
||||
def set_power(self, device=None, key=None, data=None):
|
||||
self.pack(self.KEY_POWER, None)
|
||||
|
||||
def set_volume_up(self, data=False):
|
||||
@ -666,20 +842,19 @@ class remote(base):
|
||||
"""data: [True, False]"""
|
||||
self.pack(self.KEY_VOLDOWN, data)
|
||||
|
||||
def default_inc(self):
|
||||
def default_inc(self, device=None, key=None, data=None):
|
||||
self.set_volume_up(True)
|
||||
|
||||
def default_dec(self):
|
||||
def default_dec(self, device=None, key=None, data=None):
|
||||
self.set_volume_down(True)
|
||||
|
||||
def default_stop(self):
|
||||
def default_stop(self, device=None, key=None, data=None):
|
||||
self.set_volume_up(False)
|
||||
|
||||
|
||||
class status(base):
|
||||
KEY_STATE = "state"
|
||||
#
|
||||
TX_TOPIC = 'set'
|
||||
TX_TYPE = base.TX_VALUE
|
||||
#
|
||||
RX_KEYS = [KEY_STATE]
|
||||
@ -688,6 +863,10 @@ class status(base):
|
||||
"""data: [True, False]"""
|
||||
self.pack(self.KEY_STATE + "/" + str(num), data)
|
||||
|
||||
def set_state_mcb(self, device, key, data):
|
||||
logger.info("%s: Changing state to %s", self.topic, str(data))
|
||||
self.set_state(data)
|
||||
|
||||
|
||||
class audio_status(status):
|
||||
KEY_TITLE = "title"
|
||||
|
@ -4,7 +4,7 @@
|
||||
import devices
|
||||
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
|
||||
from function.first_floor_east import first_floor_east_floor, first_floor_east_kitchen, first_floor_east_dining, first_floor_east_sleep, first_floor_east_living
|
||||
from function.common import common_heating, common_circulation_pump
|
||||
import inspect
|
||||
import logging
|
||||
@ -15,7 +15,10 @@ except ImportError:
|
||||
ROOT_LOGGER_NAME = 'root'
|
||||
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
|
||||
# TODO: usage of implementation strategy from gfw_dirk for ffe_sleep_madi
|
||||
# TODO: change topics for all zigbee devices to <type|[shellies, zigbee_*, gui, ...]>/<area|gfw, ffw, ffe>/<room>/<target|[main_light, floorlamp, ...]>/<function>
|
||||
# TODO: usage of implementation strategy from gfw_dirk for ffe_sleep
|
||||
# TODO: implement improved devices.nodered_gui_heatvalve incl. setpoint, boost, ... and functions from funtion.module
|
||||
# implement nodered_gui_timer for circulation pump
|
||||
# TODO: implement garland (incl. day events like sunset, sunrise, ...)
|
||||
# TODO: implement warning message
|
||||
|
||||
@ -26,7 +29,7 @@ class all_functions(object):
|
||||
#
|
||||
self.__devices__ = None
|
||||
# heating and warm water
|
||||
self.common_heat_sleep_madi = common_heating(self.mqtt_client)
|
||||
self.common_ffe_heat_sleep = common_heating(self.mqtt_client)
|
||||
self.common_circulation_pump = common_circulation_pump(self.mqtt_client)
|
||||
# ground floor west
|
||||
self.gfw_floor = ground_floor_west_floor(self.mqtt_client)
|
||||
@ -39,7 +42,7 @@ class all_functions(object):
|
||||
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_sleep = first_floor_east_sleep(self.mqtt_client)
|
||||
self.ffe_living = first_floor_east_living(self.mqtt_client)
|
||||
#
|
||||
# Interactions
|
||||
@ -53,22 +56,20 @@ class all_functions(object):
|
||||
|
||||
def init_off_functionality(self):
|
||||
# Off Buttons
|
||||
self.gui_button_all_off = devices.nodered_gui(self.mqtt_client, topic="gui/button_all_off")
|
||||
self.gui_button_gfw_off = devices.nodered_gui(self.mqtt_client, topic="gui/button_gfw_off")
|
||||
self.gui_button_ffw_off = devices.nodered_gui(self.mqtt_client, topic="gui/button_ffw_off")
|
||||
self.gui_button_ffe_off = devices.nodered_gui(self.mqtt_client, topic="gui/button_ffe_off")
|
||||
self.gui_button_all_off = devices.nodered_gui_button(self.mqtt_client, topic="gui/all/common/off/button")
|
||||
self.gui_button_gfw_off = devices.nodered_gui_button(self.mqtt_client, topic="gui/gfw/common/off/button")
|
||||
self.gui_button_ffw_off = devices.nodered_gui_button(self.mqtt_client, topic="gui/ffw/common/off/button")
|
||||
self.gui_button_ffe_off = devices.nodered_gui_button(self.mqtt_client, topic="gui/ffe/common/off/button")
|
||||
#
|
||||
self.gui_button_all_off.add_callback(devices.nodered_gui.KEY_OFF_BUTTON, True, self.all_off)
|
||||
self.gui_button_gfw_off.add_callback(devices.nodered_gui.KEY_OFF_BUTTON, True, self.gfw_off)
|
||||
self.gui_button_ffw_off.add_callback(devices.nodered_gui.KEY_OFF_BUTTON, True, self.ffw_off)
|
||||
self.gui_button_ffe_off.add_callback(devices.nodered_gui.KEY_OFF_BUTTON, True, self.ffe_off)
|
||||
self.gui_button_all_off.add_callback(devices.nodered_gui_button.KEY_STATE, True, self.all_off)
|
||||
self.gui_button_gfw_off.add_callback(devices.nodered_gui_button.KEY_STATE, True, self.gfw_off)
|
||||
self.gui_button_ffw_off.add_callback(devices.nodered_gui_button.KEY_STATE, True, self.ffw_off)
|
||||
self.gui_button_ffe_off.add_callback(devices.nodered_gui_button.KEY_STATE, True, self.ffe_off)
|
||||
# Long push ffe_floor
|
||||
self.ffe_floor.main_light_shelly.add_callback(
|
||||
devices.shelly.KEY_LONGPUSH_0, True, self.ffe_floor.all_off_feedback)
|
||||
self.ffe_floor.main_light_shelly.add_callback(devices.shelly.KEY_LONGPUSH_0, True, self.ffe_floor.all_off_feedback)
|
||||
self.ffe_floor.main_light_shelly.add_callback(devices.shelly.KEY_LONGPUSH_0, True, self.ffe_off)
|
||||
# Long push input device
|
||||
self.ffe_sleep_madi.button_tradfri.add_callback(
|
||||
devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG, self.ffe_off)
|
||||
self.ffe_sleep.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG, self.ffe_off)
|
||||
|
||||
def getmembers(self, prefix):
|
||||
rv = []
|
||||
@ -107,18 +108,17 @@ class all_functions(object):
|
||||
# shelly dirk input 1
|
||||
self.last_gfw_dirk_input_1 = None
|
||||
self.gfw_dirk.main_light_shelly.add_callback(devices.shelly.KEY_INPUT_1, None, self.gfw_dirk_input_1)
|
||||
# tradfri button sleep madi right click
|
||||
self.ffe_sleep_madi.button_tradfri.add_callback(
|
||||
devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT, self.ffe_floor.toggle_main_light)
|
||||
# tradfri button ffe_sleep right click
|
||||
self.ffe_sleep.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION,
|
||||
devices.tradfri_button.ACTION_RIGHT, self.ffe_floor.main_light_shelly.toggle_output_0_mcb)
|
||||
|
||||
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)
|
||||
self.common_circulation_pump.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.ffe_kitchen.flash_main_light)
|
||||
|
||||
def gfw_dirk_input_1(self, device, key, data):
|
||||
if self.last_gfw_dirk_input_1 is not None:
|
||||
if self.last_gfw_dirk_input_1 != data:
|
||||
self.gfw_floor.toggle_main_light(device, key, data)
|
||||
self.gfw_floor.main_light_shelly.toggle_main_light(device, key, data)
|
||||
self.last_gfw_dirk_input_1 = data
|
||||
|
||||
def devicelist(self):
|
||||
|
@ -19,11 +19,11 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
class common_circulation_pump(room_shelly):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1-E89F6D85A466
|
||||
super().__init__(mqtt_client, "shellies/circulation_pump", "gui/common_sw_circulation_pump")
|
||||
super().__init__(mqtt_client, "shellies/circulation_pump", "gui/none/common/circulation_pump/switch")
|
||||
#
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.circ_pump_actions)
|
||||
#
|
||||
self.gui_timer_view = devices.nodered_gui(mqtt_client, "gui/ffe_circ_pump_timer")
|
||||
self.gui_timer_view = devices.nodered_gui_heatvalve(mqtt_client, "gui/ffe_circ_pump_timer")
|
||||
self.gui_timer_view.set_feedback('-')
|
||||
#
|
||||
self.cvi = changed_value_indicator()
|
||||
|
@ -18,127 +18,83 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
class first_floor_east_floor(room_shelly):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-3C6105E4E629
|
||||
super().__init__(mqtt_client, "shellies/floor_madi", "gui/ffe_sw_floor")
|
||||
super().__init__(mqtt_client, "shellies/floor_madi", "gui/ffe/floor/main_light/switch")
|
||||
|
||||
|
||||
class first_floor_east_kitchen(room_shelly):
|
||||
# TODO: add circulation pump (switch, time)
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-8CAAB5616C01
|
||||
super().__init__(mqtt_client, "shellies/kitchen", "gui/ffe_sw_kitchen")
|
||||
super().__init__(mqtt_client, "shellies/kitchen", "gui/ffe/kitchen/main_light/switch")
|
||||
|
||||
|
||||
class first_floor_east_dining(room_shelly):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-84CCA8ADD055
|
||||
super().__init__(mqtt_client, "shellies/diningroom", "gui/ffe_sw_diningroom")
|
||||
super().__init__(mqtt_client, "shellies/diningroom", "gui/ffe/diningroom/main_light/switch")
|
||||
self.floorlamp_powerplug = devices.silvercrest_powerplug(mqtt_client, "zigbee_og_e/powerplug/dining_floorlamp")
|
||||
if config.CHRISTMAS:
|
||||
self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, topic="zigbee_og_e/powerplug/aux")
|
||||
#
|
||||
self.gui_switch_floorlamp = devices.nodered_gui(mqtt_client, topic="gui/ffe_sw_dining_floorlamp")
|
||||
self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, topic="gui/ffe/diningroom/floorlamp/switch")
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_synchronisation)
|
||||
self.gui_switch_floorlamp.add_callback(devices.nodered_gui.KEY_STATE, None, self.gui_switch_command_floorlamp)
|
||||
self.floorlamp_powerplug.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0,
|
||||
None, self.gui_switch_feedback_floorlamp)
|
||||
#
|
||||
self.cvi = changed_value_indicator()
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_powerplug.set_output_0_mcb, True)
|
||||
self.gui_switch_floorlamp.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.floorlamp_powerplug.set_output_0_mcb)
|
||||
self.floorlamp_powerplug.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_switch_floorlamp.set_state_mcb)
|
||||
|
||||
def all_off(self, device=None, key=None, data=None):
|
||||
super().all_off(device, key, data)
|
||||
self.floorlamp_powerplug.set_output_0(False)
|
||||
|
||||
def floorlamp_synchronisation(self, device, key, data):
|
||||
if self.cvi.changed_here(device.topic, key, data) and device.previous_value(key) is not None:
|
||||
logger.info("Syncing \"%s\" floorlamp with main light (%s)", type(self).__name__, str(data))
|
||||
self.floorlamp_powerplug.set_output_0(data)
|
||||
|
||||
def gui_switch_command_floorlamp(self, device, key, data):
|
||||
logger.info("Switching \"%s\" floorlamp: %s", type(self).__name__, str(data))
|
||||
self.floorlamp_powerplug.set_output_0(data)
|
||||
|
||||
def gui_switch_feedback_floorlamp(self, device, key, data):
|
||||
self.gui_switch_floorlamp.set_feedback(data)
|
||||
if config.CHRISTMAS:
|
||||
self.garland_powerplug.set_output_0(False)
|
||||
|
||||
|
||||
class first_floor_east_sleep_madi(room_shelly_tradfri_light):
|
||||
class first_floor_east_sleep(room_shelly_tradfri_light):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-E8DB84A254C7
|
||||
super().__init__(mqtt_client, "shellies/sleep_madi", "gui/ffe_sw_sleep_madi",
|
||||
"zigbee_og_e/light/sleep_madi", "gui/ffe_br_sleep_madi", "gui/ffe_ct_sleep_madi")
|
||||
super().__init__(mqtt_client, "shellies/sleep_madi", "gui/ffe/sleep/main_light/switch",
|
||||
"zigbee_og_e/light/sleep_madi", "gui/ffe/sleep/main_light/br_ct")
|
||||
#
|
||||
self.bed_light_di_tradfri = devices.tradfri_light(mqtt_client, topic="zigbee_og_e/light/sleep_bed_di")
|
||||
#
|
||||
self.gui_switch_bed_light_di = devices.nodered_gui(mqtt_client, "gui/ffe_sw_bed_light_di")
|
||||
self.gui_brightness_bed_light_di = devices.nodered_gui(mqtt_client, "gui/ffe_br_bed_light_di")
|
||||
self.gui_brightness_bed_light_di.enable(False)
|
||||
self.gui_brightness_bed_light_di.set_feedback(0)
|
||||
self.gui_switch_bed_light_di = devices.nodered_gui_switch(mqtt_client, "gui/ffe/sleep/bed_light_di/switch")
|
||||
self.gui_br_ct_bed_light_di = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/ffe/sleep/bed_light_di/br_ct")
|
||||
self.gui_led_active_device = devices.nodered_gui_leds(mqtt_client, "gui/ffe/sleep/active_device_state/led")
|
||||
#
|
||||
self.button_tradfri = devices.tradfri_button(mqtt_client, topic="zigbee_og_e/input_device/og_east")
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
self.init_bed_light_functions()
|
||||
self.init_fade_function()
|
||||
#
|
||||
# button
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_TOGGLE,
|
||||
self.toggle_main_light)
|
||||
self.main_light_shelly.toggle_output_0_mcb)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_BRIGHTNESS_UP,
|
||||
self.toggle_bed_light_di)
|
||||
self.bed_light_di_tradfri.toggle_output_0_mcb)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_BRIGHTNESS_DOWN,
|
||||
self.toggle_bed_light_di)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, None,
|
||||
self.fade_light)
|
||||
self.bed_light_di_tradfri.toggle_output_0_mcb)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, None, self.fade_light)
|
||||
|
||||
# bed light
|
||||
# switch
|
||||
self.gui_switch_bed_light_di.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.bed_light_di_tradfri.set_output_0_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_switch_bed_light_di.set_state_mcb)
|
||||
# brightness and color temperature
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_br_ct_bed_light_di.set_enable_mcb)
|
||||
self.gui_br_ct_bed_light_di.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS,
|
||||
None, self.bed_light_di_tradfri.set_brightness_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_br_ct_bed_light_di.set_enable_mcb)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_ct_bed_light_di.set_brightness_mcb)
|
||||
|
||||
# fade function
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.state_machine_last_activated_device)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.state_machine_last_activated_device)
|
||||
self.last_activated_device = None
|
||||
|
||||
def all_off(self, device=None, key=None, data=None):
|
||||
super().all_off(device, key, data)
|
||||
self.bed_light_di_tradfri.set_output_0(False)
|
||||
|
||||
# bed light
|
||||
def init_bed_light_functions(self):
|
||||
self.gui_switch_bed_light_di.add_callback(
|
||||
devices.nodered_gui.KEY_STATE, None, self.gui_switch_command_bed_light_di)
|
||||
self.bed_light_di_tradfri.add_callback(
|
||||
devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_switch_feedback_bed_light_di)
|
||||
self.bed_light_di_tradfri.add_callback(
|
||||
devices.tradfri_light.KEY_BRIGHTNESS, None, self.set_gui_brightness_bed_light_di)
|
||||
self.gui_brightness_bed_light_di.add_callback(
|
||||
devices.nodered_gui.KEY_BRIGHTNESS, None, self.set_brightness_bed_light_di)
|
||||
|
||||
def gui_switch_command_bed_light_di(self, device, key, data):
|
||||
logger.info("Switching \"%s\" bed light dirk: %s", type(self).__name__, str(data))
|
||||
self.bed_light_di_tradfri.set_output_0(data)
|
||||
|
||||
def gui_switch_feedback_bed_light_di(self, device, key, data):
|
||||
self.gui_switch_bed_light_di.set_feedback(data)
|
||||
self.gui_brightness_bed_light_di.enable(data)
|
||||
if data is False:
|
||||
self.gui_brightness_bed_light_di.set_feedback(0)
|
||||
else:
|
||||
self.gui_brightness_bed_light_di.set_feedback(self.bed_light_di_tradfri.brightness)
|
||||
|
||||
def set_gui_brightness_bed_light_di(self, device, key, data):
|
||||
self.gui_brightness_bed_light_di.set_feedback(data)
|
||||
|
||||
def set_brightness_bed_light_di(self, device, key, data):
|
||||
logger.info("Setting brightness \"%s\" bed light dirk: %.1f", type(self).__name__, data)
|
||||
self.bed_light_di_tradfri.set_brightness(data)
|
||||
|
||||
def toggle_bed_light_di(self, device, key, data):
|
||||
logger.info("Toggeling \"%s\" bed light dirk", type(self).__name__)
|
||||
self.bed_light_di_tradfri.set_output_0("toggle")
|
||||
|
||||
# fade
|
||||
def init_fade_function(self):
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.state_machine_last_activated_device)
|
||||
self.bed_light_di_tradfri.add_callback(devices.tradfri_light.KEY_OUTPUT_0,
|
||||
None, self.state_machine_last_activated_device)
|
||||
#
|
||||
self.last_activated_device = None
|
||||
|
||||
def state_machine_last_activated_device(self, device, topic, data):
|
||||
if data is True:
|
||||
self.last_activated_device = device.topic
|
||||
@ -149,10 +105,8 @@ class first_floor_east_sleep_madi(room_shelly_tradfri_light):
|
||||
self.last_activated_device = self.main_light_shelly.topic
|
||||
else:
|
||||
self.last_activated_device = None
|
||||
self.mqtt_client.send("gui/ffe_led_main_light_sleep/set",
|
||||
json.dumps(self.last_activated_device == self.main_light_shelly.topic))
|
||||
self.mqtt_client.send("gui/ffe_led_bed_light_sleep_di/set",
|
||||
json.dumps(self.last_activated_device == self.bed_light_di_tradfri.topic))
|
||||
self.gui_led_active_device.set_led(devices.nodered_gui_leds.KEY_LED_0, self.last_activated_device == self.main_light_shelly.topic)
|
||||
self.gui_led_active_device.set_led(devices.nodered_gui_leds.KEY_LED_1, self.last_activated_device == self.bed_light_di_tradfri.topic)
|
||||
|
||||
def fade_light(self, device, topic, data):
|
||||
if self.last_activated_device == self.main_light_shelly.topic:
|
||||
@ -175,45 +129,40 @@ class first_floor_east_sleep_madi(room_shelly_tradfri_light):
|
||||
class first_floor_east_living(room_shelly_tradfri_light):
|
||||
def __init__(self, mqtt_client):
|
||||
# http://shelly1l-3C6105E3F910
|
||||
super().__init__(mqtt_client, "shellies/livingroom", "gui/ffe_sw_livingroom",
|
||||
"zigbee_og_e/light/livingroom", "gui/ffe_br_livingroom", "gui/ffe_ct_livingroom")
|
||||
super().__init__(mqtt_client, "shellies/livingroom", "gui/ffe/livingroom/main_light/switch",
|
||||
"zigbee_og_e/light/livingroom", "gui/ffe/livingroom/main_light/br_ct")
|
||||
for i in range(1, 7):
|
||||
setattr(self, 'floorlamp_tradfri_%d' % i,
|
||||
devices.tradfri_light(mqtt_client, topic="zigbee_og_e/light/living_floorlamp_%d" % i))
|
||||
setattr(self, 'floorlamp_tradfri_%d' % i, devices.tradfri_light(mqtt_client, topic="zigbee_og_e/light/living_floorlamp_%d" % i))
|
||||
#
|
||||
if config.CHRISTMAS:
|
||||
self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, "zigbee_og_e/powerplug/xmas-tree")
|
||||
self.powerplug_xmas_star = devices.silvercrest_powerplug(mqtt_client, "zigbee_og_e/powerplug/xmas-star")
|
||||
#
|
||||
self.gui_switch_floorlamp = devices.nodered_gui(mqtt_client, topic="gui/ffe_sw_living_floorlamp")
|
||||
self.gui_brightness_floorlamp = devices.nodered_gui(mqtt_client, "gui/ffe_br_livingroom_floorlamp")
|
||||
self.gui_brightness_floorlamp.enable(False)
|
||||
self.gui_brightness_floorlamp.set_feedback(0)
|
||||
self.gui_color_temp_floorlamp = devices.nodered_gui(mqtt_client, "gui/ffe_ct_livingroom_floorlamp")
|
||||
self.gui_color_temp_floorlamp.enable(False)
|
||||
self.gui_color_temp_floorlamp.set_feedback(0)
|
||||
self.gui_switch_floorlamp = devices.nodered_gui_switch(mqtt_client, topic="gui/ffe/livingroom/floorlamp/switch")
|
||||
self.gui_br_ct_floorlamp = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/ffe/livingroom/floorlamp/br_ct")
|
||||
#
|
||||
if config.CHRISTMAS:
|
||||
self.gui_switch_xmas_tree = devices.nodered_gui(mqtt_client, "gui/ffe_sw_livingroom_xmas_tree")
|
||||
self.gui_switch_xmas_tree = devices.nodered_gui_switch(mqtt_client, "gui/ffe/livingroom/xmas_tree/switch")
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_synchronisation)
|
||||
self.gui_switch_floorlamp.add_callback(devices.nodered_gui.KEY_STATE, None, self.gui_switch_command_floorlamp)
|
||||
self.floorlamp_tradfri_1.add_callback(
|
||||
devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_switch_feedback_floorlamp)
|
||||
self.floorlamp_tradfri_1.add_callback(
|
||||
devices.tradfri_light.KEY_BRIGHTNESS, None, self.set_gui_brightness_floorlamp)
|
||||
self.floorlamp_tradfri_1.add_callback(
|
||||
devices.tradfri_light.KEY_COLOR_TEMP, None, self.set_gui_color_temp_floorlamp)
|
||||
self.gui_brightness_floorlamp.add_callback(
|
||||
devices.nodered_gui.KEY_BRIGHTNESS, None, self.set_brightness_floorlamp)
|
||||
self.gui_color_temp_floorlamp.add_callback(
|
||||
devices.nodered_gui.KEY_COLOR_TEMP, None, self.set_color_temp_floorlamp)
|
||||
|
||||
# floor lamp
|
||||
for device in self.__floorlamp_devices__():
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, device.set_output_0_mcb, True)
|
||||
self.gui_switch_floorlamp.add_callback(devices.nodered_gui_switch.KEY_STATE, None, device.set_output_0_mcb)
|
||||
self.gui_br_ct_floorlamp.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS, None, device.set_brightness_mcb)
|
||||
self.gui_br_ct_floorlamp.add_callback(devices.nodered_gui_brightness_color_temp.KEY_COLOR_TEMP, None, device.set_color_temp_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_switch_floorlamp.set_state_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_OUTPUT_0, None, self.gui_br_ct_floorlamp.set_enable_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_ct_floorlamp.set_brightness_mcb)
|
||||
self.floorlamp_tradfri_1.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_br_ct_floorlamp.set_color_temp_mcb)
|
||||
#
|
||||
if config.CHRISTMAS:
|
||||
self.powerplug_xmas_tree.add_callback(
|
||||
devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.powerplug_xmas_action)
|
||||
self.gui_switch_xmas_tree.add_callback(devices.nodered_gui.KEY_STATE, None, self.gui_switch_command_xmas)
|
||||
self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.gui_switch_xmas_tree.set_state_mcb)
|
||||
self.gui_switch_xmas_tree.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_xmas_tree.set_output_0_mcb)
|
||||
#
|
||||
self.powerplug_xmas_tree.add_callback(devices.silvercrest_powerplug.KEY_OUTPUT_0, None, self.powerplug_xmas_star.set_output_0_mcb)
|
||||
#
|
||||
self.cvi = changed_value_indicator()
|
||||
|
||||
@ -221,55 +170,12 @@ class first_floor_east_living(room_shelly_tradfri_light):
|
||||
super().all_off(device, key, data)
|
||||
for floorlamp in self.__floorlamp_devices__():
|
||||
floorlamp.set_output_0(False)
|
||||
if config.CHRISTMAS:
|
||||
self.powerplug_xmas_tree.set_output_0(False)
|
||||
self.powerplug_xmas_star.set_output_0(False)
|
||||
|
||||
def __floorlamp_devices__(self):
|
||||
rv = []
|
||||
for i in range(1, 7):
|
||||
rv.append(getattr(self, 'floorlamp_tradfri_%d' % i))
|
||||
return rv
|
||||
|
||||
def floorlamp_synchronisation(self, device, key, data):
|
||||
if self.cvi.changed_here(device.topic, key, data) and device.previous_value(key) is not None:
|
||||
logger.info("Syncing \"%s\" floorlamp with main light (%s)", type(self).__name__, str(data))
|
||||
for device in self.__floorlamp_devices__():
|
||||
device.set_output_0(data)
|
||||
|
||||
def gui_switch_command_floorlamp(self, device, key, data):
|
||||
logger.info("Switching \"%s\" floorlamp: %s", type(self).__name__, str(data))
|
||||
for device in self.__floorlamp_devices__():
|
||||
device.set_output_0(data)
|
||||
|
||||
def gui_switch_feedback_floorlamp(self, device, key, data):
|
||||
self.gui_switch_floorlamp.set_feedback(data)
|
||||
self.gui_brightness_floorlamp.enable(data)
|
||||
self.gui_color_temp_floorlamp.enable(data)
|
||||
if data is False:
|
||||
self.gui_brightness_floorlamp.set_feedback(0)
|
||||
self.gui_color_temp_floorlamp.set_feedback(0)
|
||||
else:
|
||||
self.gui_brightness_floorlamp.set_feedback(self.floorlamp_tradfri_1.brightness)
|
||||
self.gui_color_temp_floorlamp.set_feedback(self.floorlamp_tradfri_1.color_temp / 10)
|
||||
|
||||
def set_gui_brightness_floorlamp(self, device, key, data):
|
||||
self.gui_brightness_floorlamp.set_feedback(data)
|
||||
|
||||
def set_gui_color_temp_floorlamp(self, device, key, data):
|
||||
self.gui_color_temp_floorlamp.set_feedback(data / 10)
|
||||
|
||||
def set_brightness_floorlamp(self, device, key, data):
|
||||
logger.info("Setting brightness \"%s\" floorlamp: %.1f", type(self).__name__, data)
|
||||
for device in self.__floorlamp_devices__():
|
||||
device.set_brightness(data)
|
||||
|
||||
def set_color_temp_floorlamp(self, device, key, data):
|
||||
logger.info("Setting color_temp \"%s\" floorlamp: %.1f", type(self).__name__, data)
|
||||
for device in self.__floorlamp_devices__():
|
||||
device.set_color_temp(data * 10)
|
||||
|
||||
def powerplug_xmas_action(self, device, key, data):
|
||||
self.gui_switch_xmas_tree.set_feedback(data)
|
||||
self.powerplug_xmas_star.set_output_0(data)
|
||||
|
||||
def gui_switch_command_xmas(self, device, key, data):
|
||||
logger.info("Switching \"%s\" xmas-tree: %s", type(self).__name__, data)
|
||||
self.powerplug_xmas_tree.set_output_0(data)
|
||||
|
@ -15,11 +15,10 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
class first_floor_west_julian(room_shelly_tradfri_light):
|
||||
# http://shelly1l-3C6105E43452
|
||||
def __init__(self, mqtt_client):
|
||||
super().__init__(mqtt_client, "shellies/julian", "gui/ffw_sw_julian",
|
||||
"zigbee_og_e/light/julian", "gui/ffw_br_julian", "gui/ffw_ct_julian")
|
||||
super().__init__(mqtt_client, "shellies/julian", "gui/ffw/julian/main_light/switch", "zigbee_og_e/light/julian", "gui/ffw/julian/main_light/br_ct")
|
||||
|
||||
|
||||
class first_floor_west_living(room_shelly):
|
||||
# http://shelly1l-84CCA8ACE6A1
|
||||
def __init__(self, mqtt_client):
|
||||
super().__init__(mqtt_client, "shellies/living_mika", "gui/ffw_sw_living")
|
||||
super().__init__(mqtt_client, "shellies/living_mika", "gui/ffw/living/main_light/swicht")
|
||||
|
@ -18,32 +18,23 @@ logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
|
||||
class ground_floor_west_floor(room_shelly_silvercrest_light):
|
||||
# https://shelly1l-84CCA8AD1148
|
||||
def __init__(self, mqtt_client):
|
||||
super().__init__(mqtt_client, "shellies/floor_eg_w", "gui/gfw_sw_floor",
|
||||
"zigbee_eg_w/light/floor_eg_w/a", "gui/gfw_br_floor", "gui/gfw_ct_floor")
|
||||
super().__init__(mqtt_client, "shellies/floor_eg_w", "gui/gfw/floor/main_light/switch", "zigbee_eg_w/light/floor_eg_w/a", "gui/gfw/floor/main_light/br_ct")
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
self.main_light_tradfri_2 = devices.tradfri_light(mqtt_client, "zigbee_eg_w/light/floor_eg_w/b")
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS,
|
||||
None, self.sync_brightness_main_light)
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP,
|
||||
None, self.sync_color_temp_main_light)
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.main_light_tradfri_2.set_brightness_mcb)
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.main_light_tradfri_2.set_color_temp_mcb)
|
||||
|
||||
def send_init_message_main_light(self):
|
||||
return super().send_init_message_main_light()
|
||||
super().send_init_message_main_light()
|
||||
self.main_light_tradfri_2.mqtt_client.send(self.main_light_tradfri_2.topic + "/get", '{"state": ""}')
|
||||
|
||||
def sync_brightness_main_light(self, device, key, data):
|
||||
self.main_light_tradfri_2.set_brightness(data)
|
||||
|
||||
def sync_color_temp_main_light(self, device, key, data):
|
||||
self.main_light_tradfri_2.set_color_temp(data)
|
||||
|
||||
|
||||
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")
|
||||
super().__init__(mqtt_client, "shellies/marion", "gui/gfw/marion/main_light/switch")
|
||||
|
||||
|
||||
class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
@ -52,6 +43,10 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
STATE_ACTIVE_DEVICE_AMPLIFIER = 2
|
||||
STATE_ACTIVE_DEVICE_MAX_VALUE = STATE_ACTIVE_DEVICE_AMPLIFIER
|
||||
#
|
||||
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
|
||||
#
|
||||
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
|
||||
@ -60,33 +55,24 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
AUDIO_SOURCE_PC = 0
|
||||
AUDIO_SOURCE_CD = 1
|
||||
AUDIO_SOURCE_RASPI = 2
|
||||
#
|
||||
KEY_SPOTIFY = "hifi/spotify/state"
|
||||
KEY_MPD = "hifi/mpd/state"
|
||||
|
||||
# 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")
|
||||
super().__init__(mqtt_client, "shellies/dirk", "gui/gfw/dirk/main_light/switch", "zigbee_eg_w/light/dirk", "gui/gfw/dirk/main_light/br_ct")
|
||||
#
|
||||
self.powerplug_common = devices.my_powerplug(mqtt_client, "powerplug/dirk")
|
||||
self.desk_light_tradfri = devices.tradfri_light(mqtt_client, "zigbee_eg_w/light/dirk_desk")
|
||||
self.button_tradfri = devices.tradfri_button(mqtt_client, "zigbee_eg_w/input_device/dirk")
|
||||
#
|
||||
self.gui_switch_desk_light = devices.nodered_gui(mqtt_client, "gui/gfw_sw_desk_light")
|
||||
self.gui_brightness_desk_light = devices.nodered_gui(mqtt_client, "gui/gfw_br_desk_light")
|
||||
self.gui_brightness_desk_light.enable(False)
|
||||
self.gui_brightness_desk_light.set_feedback(0)
|
||||
self.gui_color_temp_desk_light = devices.nodered_gui(mqtt_client, "gui/gfw_ct_desk_light")
|
||||
self.gui_color_temp_desk_light.enable(False)
|
||||
self.gui_color_temp_desk_light.set_feedback(0)
|
||||
self.gui_switch_desk_light = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/desk_light/switch")
|
||||
self.gui_br_cr_desk_light = devices.nodered_gui_brightness_color_temp(mqtt_client, "gui/gfw/dirk/desk_light/br_ct")
|
||||
#
|
||||
self.gui_switch_amplifier = devices.nodered_gui(mqtt_client, "gui/gfw_sw_amplifier")
|
||||
self.gui_switch_cd_player = devices.nodered_gui(mqtt_client, "gui/gfw_sw_cd_player")
|
||||
self.gui_switch_pc_dock = devices.nodered_gui(mqtt_client, "gui/gfw_sw_pc_dock")
|
||||
self.gui_switch_amplifier = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/amplifier/switch")
|
||||
self.gui_switch_cd_player = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/cd_player/switch")
|
||||
self.gui_switch_pc_dock = devices.nodered_gui_switch(mqtt_client, "gui/gfw/dirk/pc_dock/switch")
|
||||
#
|
||||
self.remote_amplifier = devices.remote(mqtt_client, "hifi/remote/RAS5")
|
||||
self.active_device_state_led = devices.status(mqtt_client, "gui/gfw_active_device_state")
|
||||
self.gui_led_active_device = devices.nodered_gui_leds(mqtt_client, "gui/gfw/dirk/active_device_state/led")
|
||||
#
|
||||
self.spotify_state = devices.audio_status(mqtt_client, "hifi/spotify")
|
||||
self.mpd_state = devices.audio_status(mqtt_client, "hifi/mpd")
|
||||
@ -95,75 +81,69 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
#
|
||||
self.cvi = changed_value_indicator()
|
||||
#
|
||||
self.powerplug_common.add_callback(None, None, self.powerplug_gui_feedback_actions)
|
||||
# Callback initialisation
|
||||
#
|
||||
|
||||
# main light
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_TOGGLE,
|
||||
self.main_light_shelly.toggle_output_0_mcb)
|
||||
|
||||
# desk light
|
||||
# switch
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT,
|
||||
self.powerplug_common.toggle_output_1_mcb)
|
||||
self.gui_switch_desk_light.add_callback(devices.nodered_gui_switch.KEY_STATE, None, self.powerplug_common.set_output_1_mcb)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_DESK_LIGHT, None, self.gui_switch_desk_light.set_state_mcb)
|
||||
# brightness and color temp
|
||||
self.gui_br_cr_desk_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS,
|
||||
None, self.desk_light_tradfri.set_brightness_mcb)
|
||||
self.gui_br_cr_desk_light.add_callback(devices.nodered_gui_brightness_color_temp.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_br_cr_desk_light.set_enable_mcb)
|
||||
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_cr_desk_light.set_brightness_mcb)
|
||||
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_br_cr_desk_light.set_color_temp_mcb)
|
||||
|
||||
# amplifier
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT_LONG,
|
||||
self.powerplug_common.toggle_output_0_mcb)
|
||||
self.gui_switch_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_switch_amplifier.set_state_mcb)
|
||||
# amplifier auto on
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.cd_amplifier_synchronisation)
|
||||
self.spotify_state.add_callback(devices.status.KEY_STATE, None, self.raspi_amplifier_synchronisation)
|
||||
self.mpd_state.add_callback(devices.status.KEY_STATE, None, self.raspi_amplifier_synchronisation)
|
||||
#
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION,
|
||||
devices.tradfri_button.ACTION_TOGGLE, self.toggle_main_light)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION,
|
||||
devices.tradfri_button.ACTION_RIGHT, self.desk_light_switch_action)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION,
|
||||
devices.tradfri_button.ACTION_LEFT_LONG, self.amplifier_switch_action)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION,
|
||||
devices.tradfri_button.ACTION_RIGHT_LONG, self.cd_player_switch_action)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION,
|
||||
devices.tradfri_button.ACTION_LEFT, self.pc_dock_switch_action)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, None, self.brightness_action)
|
||||
#
|
||||
self.gui_switch_desk_light.add_callback(devices.nodered_gui.KEY_STATE, None, self.desk_light_switch_action)
|
||||
self.gui_brightness_desk_light.add_callback(
|
||||
devices.nodered_gui.KEY_BRIGHTNESS, None, self.desk_light_set_action)
|
||||
self.gui_color_temp_desk_light.add_callback(
|
||||
devices.nodered_gui.KEY_COLOR_TEMP, None, self.desk_light_set_action)
|
||||
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS,
|
||||
None, self.desk_light_set_gui_params_action)
|
||||
self.desk_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP,
|
||||
None, self.desk_light_set_gui_params_action)
|
||||
#
|
||||
self.gui_switch_amplifier.add_callback(devices.nodered_gui.KEY_STATE, None, self.amplifier_switch_action)
|
||||
self.gui_switch_cd_player.add_callback(devices.nodered_gui.KEY_STATE, None, self.cd_player_switch_action)
|
||||
self.gui_switch_pc_dock.add_callback(devices.nodered_gui.KEY_STATE, None, self.pc_dock_switch_action)
|
||||
#
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.device_chooser_action)
|
||||
self.powerplug_common.add_callback(None, None, self.device_chooser_action)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION,
|
||||
devices.tradfri_button.ACTION_BRIGHTNESS_UP, self.choose_next_device)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION,
|
||||
devices.tradfri_button.ACTION_BRIGHTNESS_DOWN, self.choose_prev_device)
|
||||
#
|
||||
# audio source
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_AMPLIFIER, None, self.audio_source_selector)
|
||||
self.powerplug_common.add_callback(self.KEY_POWERPLUG_CD_PLAYER, None, self.audio_source_selector)
|
||||
self.spotify_state.add_callback(devices.status.KEY_STATE, None, self.audio_source_selector)
|
||||
self.mpd_state.add_callback(devices.status.KEY_STATE, None, self.audio_source_selector)
|
||||
#
|
||||
self.active_device_state = None
|
||||
#
|
||||
self.audio_source = self.AUDIO_SOURCE_PC
|
||||
|
||||
# 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)
|
||||
self.gui_switch_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_switch_cd_player.set_state_mcb)
|
||||
|
||||
# pc dock
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT,
|
||||
self.powerplug_common.toggle_output_3_mcb)
|
||||
self.gui_switch_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_switch_pc_dock.set_state_mcb)
|
||||
|
||||
# brightness
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, None, self.brightness_action)
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.device_chooser_action)
|
||||
self.powerplug_common.add_callback(None, None, self.device_chooser_action)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_BRIGHTNESS_UP, self.choose_next_device)
|
||||
self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_BRIGHTNESS_DOWN, self.choose_prev_device)
|
||||
self.active_device_state = None
|
||||
self.update_active_device_led()
|
||||
|
||||
def all_off(self, device=None, key=None, data=None):
|
||||
super().all_off(device, key, data)
|
||||
self.powerplug_common.set_output_all(False)
|
||||
|
||||
def powerplug_gui_feedback_actions(self, device, key, data):
|
||||
if key == self.KEY_POWERPLUG_AMPLIFIER:
|
||||
self.gui_switch_amplifier.set_feedback(data)
|
||||
elif key == self.KEY_POWERPLUG_DESK_LIGHT:
|
||||
self.gui_switch_desk_light.set_feedback(data)
|
||||
self.gui_brightness_desk_light.enable(data)
|
||||
self.gui_color_temp_desk_light.enable(data)
|
||||
if not data:
|
||||
self.gui_brightness_desk_light.set_feedback(0)
|
||||
self.gui_color_temp_desk_light.set_feedback(0)
|
||||
else:
|
||||
self.gui_brightness_desk_light.set_feedback(self.desk_light_tradfri.brightness)
|
||||
self.gui_color_temp_desk_light.set_feedback(self.desk_light_tradfri.color_temp / 10)
|
||||
elif key == self.KEY_POWERPLUG_CD_PLAYER:
|
||||
self.gui_switch_cd_player.set_feedback(data)
|
||||
elif key == self.KEY_POWERPLUG_PC_DOCK:
|
||||
self.gui_switch_pc_dock.set_feedback(data)
|
||||
|
||||
def cd_amplifier_synchronisation(self, device, key, data):
|
||||
if self.cvi.changed_here(device.topic, key, data) and device.previous_value(key) is not None:
|
||||
logger.info("Syncing \"%s\" amplifier with cd player: %s", type(self).__name__, data)
|
||||
@ -174,73 +154,26 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
logger.info("Syncing \"%s\" amplifier with raspi player: %s", type(self).__name__, data)
|
||||
self.powerplug_common.set_output(self.KEY_POWERPLUG_AMPLIFIER, data)
|
||||
|
||||
def desk_light_switch_action(self, device, key, data):
|
||||
if device == self.button_tradfri:
|
||||
logger.info("Toggeling \"%s\" desk light to %s", type(self).__name__,
|
||||
not self.powerplug_common.get(self.KEY_POWERPLUG_DESK_LIGHT))
|
||||
self.powerplug_common.set_output(self.KEY_POWERPLUG_DESK_LIGHT, "toggle")
|
||||
else:
|
||||
logger.info("Setting \"%s\" desk light: %s", type(self).__name__, data)
|
||||
self.powerplug_common.set_output(self.KEY_POWERPLUG_DESK_LIGHT, data)
|
||||
|
||||
def desk_light_set_gui_params_action(self, device, key, data):
|
||||
if key == devices.nodered_gui.KEY_BRIGHTNESS:
|
||||
self.gui_brightness_desk_light.set_feedback(data)
|
||||
elif key == devices.nodered_gui.KEY_COLOR_TEMP:
|
||||
self.gui_color_temp_desk_light.set_feedback(data / 10)
|
||||
|
||||
def desk_light_set_action(self, device, key, data):
|
||||
if key == devices.nodered_gui.KEY_BRIGHTNESS:
|
||||
logger.info("Setting brightness \"%s\" desk light: %s", type(self).__name__, data)
|
||||
self.desk_light_tradfri.set_brightness(data)
|
||||
elif key == devices.nodered_gui.KEY_COLOR_TEMP:
|
||||
logger.info("Setting color_temp \"%s\" desk light: %s", type(self).__name__, data)
|
||||
self.desk_light_tradfri.set_color_temp(data * 10)
|
||||
|
||||
def amplifier_switch_action(self, device, key, data):
|
||||
if device == self.button_tradfri:
|
||||
logger.info("Toggeling \"%s\" amplifier to %s", type(self).__name__,
|
||||
not self.powerplug_common.get(self.KEY_POWERPLUG_AMPLIFIER))
|
||||
self.powerplug_common.set_output(self.KEY_POWERPLUG_AMPLIFIER, "toggle")
|
||||
else:
|
||||
logger.info("Setting \"%s\" amplifier: %s", type(self).__name__, data)
|
||||
self.powerplug_common.set_output(self.KEY_POWERPLUG_AMPLIFIER, data)
|
||||
|
||||
def cd_player_switch_action(self, device, key, data):
|
||||
if device == self.button_tradfri:
|
||||
logger.info("Toggeling \"%s\" cd_player to %s", type(self).__name__,
|
||||
not self.powerplug_common.get(self.KEY_POWERPLUG_CD_PLAYER))
|
||||
self.powerplug_common.set_output(self.KEY_POWERPLUG_CD_PLAYER, "toggle")
|
||||
else:
|
||||
logger.info("Setting \"%s\" cd_player: %s", type(self).__name__, data)
|
||||
self.powerplug_common.set_output(self.KEY_POWERPLUG_CD_PLAYER, data)
|
||||
|
||||
def pc_dock_switch_action(self, device, key, data):
|
||||
if device == self.button_tradfri:
|
||||
logger.info("Toggeling \"%s\" pc_dock to %s", type(self).__name__,
|
||||
not self.powerplug_common.get(self.KEY_POWERPLUG_PC_DOCK))
|
||||
self.powerplug_common.set_output(self.KEY_POWERPLUG_PC_DOCK, "toggle")
|
||||
else:
|
||||
logger.info("Setting \"%s\" pc_dock: %s", type(self).__name__, data)
|
||||
self.powerplug_common.set_output(self.KEY_POWERPLUG_PC_DOCK, data)
|
||||
|
||||
def device_chooser_action(self, device, key, data):
|
||||
if device == self.main_light_shelly:
|
||||
if self.cvi.changed_here(device.topic, key, data):
|
||||
if data is True:
|
||||
self.active_device_state = self.STATE_ACTIVE_DEVICE_MAIN_LIGHT
|
||||
self.update_active_device_led()
|
||||
else:
|
||||
self.choose_next_device()
|
||||
elif device == self.powerplug_common and key == self.KEY_POWERPLUG_DESK_LIGHT:
|
||||
if self.cvi.changed_here(device.topic, key, data):
|
||||
if data is True:
|
||||
self.active_device_state = self.STATE_ACTIVE_DEVICE_DESK_LIGHT
|
||||
self.update_active_device_led()
|
||||
else:
|
||||
self.choose_next_device()
|
||||
elif device == self.powerplug_common and key == self.KEY_POWERPLUG_AMPLIFIER:
|
||||
if self.cvi.changed_here(device.topic, key, data):
|
||||
if data is True:
|
||||
self.active_device_state = self.STATE_ACTIVE_DEVICE_AMPLIFIER
|
||||
self.update_active_device_led()
|
||||
else:
|
||||
self.choose_next_device()
|
||||
|
||||
@ -252,6 +185,11 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
elif state == self.STATE_ACTIVE_DEVICE_AMPLIFIER:
|
||||
return self.powerplug_common.get(self.KEY_POWERPLUG_AMPLIFIER)
|
||||
|
||||
def update_active_device_led(self):
|
||||
self.gui_led_active_device.set_led(self.LED_ACTIVE_DEVICE_AMPLIFIER, self.active_device_state == self.STATE_ACTIVE_DEVICE_AMPLIFIER)
|
||||
self.gui_led_active_device.set_led(self.LED_ACTIVE_DEVICE_MAIN_LIGHT, self.active_device_state == self.STATE_ACTIVE_DEVICE_MAIN_LIGHT)
|
||||
self.gui_led_active_device.set_led(self.LED_ACTIVE_DEVICE_DESK_LIGHT, self.active_device_state == self.STATE_ACTIVE_DEVICE_DESK_LIGHT)
|
||||
|
||||
def choose_prev_device(self, device=None, key=None, data=None):
|
||||
if self.active_device_state is not None:
|
||||
start_value = self.active_device_state
|
||||
@ -259,10 +197,10 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
target_state = (start_value + i + 1) % (self.STATE_ACTIVE_DEVICE_MAX_VALUE + 1)
|
||||
if self.get_activity_state(target_state):
|
||||
self.active_device_state = target_state
|
||||
for num in range(0, self.STATE_ACTIVE_DEVICE_MAX_VALUE + 1):
|
||||
self.active_device_state_led.set_state(num, self.active_device_state == num)
|
||||
self.update_active_device_led()
|
||||
return
|
||||
self.active_device_state = None
|
||||
self.update_active_device_led()
|
||||
|
||||
def choose_next_device(self, device=None, key=None, data=None):
|
||||
if self.active_device_state is not None:
|
||||
@ -271,10 +209,10 @@ class ground_floor_west_dirk(room_shelly_tradfri_light):
|
||||
target_state = (start_value - i - 1) % (self.STATE_ACTIVE_DEVICE_MAX_VALUE + 1)
|
||||
if self.get_activity_state(target_state):
|
||||
self.active_device_state = target_state
|
||||
for num in range(0, self.STATE_ACTIVE_DEVICE_MAX_VALUE + 1):
|
||||
self.active_device_state_led.set_state(num, self.active_device_state == num)
|
||||
self.update_active_device_led()
|
||||
return
|
||||
self.active_device_state = None
|
||||
self.update_active_device_led()
|
||||
|
||||
def brightness_action(self, device, key, data):
|
||||
if self.active_device_state is not None:
|
||||
|
@ -28,14 +28,14 @@ class heating_function_brennenstuhl(object):
|
||||
self.heating_valve.add_callback(
|
||||
devices.brennenstuhl_heatingvalve.KEY_HEATING_SETPOINT, None, self.heating_setpoint_actions)
|
||||
|
||||
self.gui_value_temp_setp = devices.nodered_gui(mqtt_client, topic_setpoint)
|
||||
self.gui_value_temp_setp = devices.nodered_gui_heatvalve(mqtt_client, topic_setpoint)
|
||||
self.gui_value_temp_setp.add_callback(
|
||||
devices.nodered_gui.KEY_HEATING_SETPOINT, None, self.heating_setpoint_actions)
|
||||
devices.nodered_gui_heatvalve.KEY_HEATING_SETPOINT, None, self.heating_setpoint_actions)
|
||||
|
||||
self.gui_button_boost = devices.nodered_gui(mqtt_client, topic_boost)
|
||||
self.gui_button_boost = devices.nodered_gui_heatvalve(mqtt_client, topic_boost)
|
||||
self.gui_button_boost.add_callback(None, None, self.boost_actions)
|
||||
|
||||
self.gui_led_boost = devices.nodered_gui(mqtt_client, topic_led)
|
||||
self.gui_led_boost = devices.nodered_gui_heatvalve(mqtt_client, topic_led)
|
||||
|
||||
#
|
||||
self.return_to_default_timer = None
|
||||
@ -71,8 +71,7 @@ class heating_function_brennenstuhl(object):
|
||||
self.gui_led_boost.set_feedback(False)
|
||||
|
||||
def boost_actions(self, davice, key, data):
|
||||
logger.info('Starting boost mode \"%s\" with setpoint %.1f°C.',
|
||||
self.topic, self.default_temperature + self.BOOST_TEMP_OFFSET)
|
||||
logger.info('Starting boost mode \"%s\" with setpoint %.1f°C.', self.topic, self.default_temperature + self.BOOST_TEMP_OFFSET)
|
||||
self.heating_valve.set_heating_setpoint(self.default_temperature + self.BOOST_TEMP_OFFSET)
|
||||
|
||||
def cyclic_task(self, rt):
|
||||
|
@ -17,25 +17,22 @@ class room(object):
|
||||
def __init__(self, mqtt_client):
|
||||
self.mqtt_client = mqtt_client
|
||||
|
||||
def gui_switch_feedback(self, device, key, data):
|
||||
self.gui_switch_main_light.set_feedback(data)
|
||||
|
||||
|
||||
class room_shelly(room):
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui_switch):
|
||||
super().__init__(mqtt_client)
|
||||
self.main_light_shelly = devices.shelly(mqtt_client, topic=topic_shelly)
|
||||
#
|
||||
self.gui_switch_main_light = devices.nodered_gui(mqtt_client, topic=topic_gui_switch)
|
||||
self.gui_switch_main_light = devices.nodered_gui_switch(mqtt_client, topic=topic_gui_switch)
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
self.gui_switch_main_light.add_callback(devices.nodered_gui.KEY_STATE, None, self.gui_switch_command)
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_switch_feedback)
|
||||
self.gui_switch_main_light.add_callback(devices.nodered_gui_switch.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_switch_main_light.set_state_mcb)
|
||||
#
|
||||
self.block_all_off = False
|
||||
self.last_flash_data = None
|
||||
self.delayed_task = task.delayed(.25, self.toggle_main_light, None, None, None)
|
||||
self.delayed_task = task.delayed(.25, self.main_light_shelly.toggle_output_0_mcb, None, None, None)
|
||||
|
||||
def all_off(self, device=None, key=None, data=None):
|
||||
if not self.block_all_off:
|
||||
@ -51,85 +48,35 @@ class room_shelly(room):
|
||||
self.block_all_off = True
|
||||
self.delayed_task.run()
|
||||
|
||||
def gui_switch_command(self, device, key, data):
|
||||
logger.info("Switching \"%s\" main light: %s", type(self).__name__, str(data))
|
||||
self.main_light_shelly.set_output_0(data)
|
||||
|
||||
def toggle_main_light(self, device, key, data):
|
||||
logger.info("Toggeling \"%s\" main light", type(self).__name__)
|
||||
self.main_light_shelly.set_output_0("toggle")
|
||||
|
||||
def flash_main_light(self, device, key, data):
|
||||
if self.last_flash_data != data and data is True:
|
||||
logger.info("Flashing \"%s\" main light", type(self).__name__)
|
||||
self.toggle_main_light(device, key, data)
|
||||
self.main_light_shelly.toggle_output_0_mcb(device, key, data)
|
||||
self.delayed_task.run()
|
||||
self.last_flash_data = data
|
||||
|
||||
|
||||
class room_shelly_tradfri_light(room_shelly):
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_brightness, topic_gui_color_temp):
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct):
|
||||
super().__init__(mqtt_client, topic_shelly, topic_gui_switch)
|
||||
self.main_light_tradfri = devices.tradfri_light(mqtt_client, topic=topic_tradfri_light)
|
||||
#
|
||||
self.gui_brightness_main_light = devices.nodered_gui(mqtt_client, topic=topic_gui_brightness)
|
||||
self.gui_brightness_main_light.enable(False)
|
||||
self.gui_brightness_main_light.set_feedback(0)
|
||||
self.gui_color_temp_main_light = devices.nodered_gui(mqtt_client, topic=topic_gui_color_temp)
|
||||
self.gui_color_temp_main_light.enable(False)
|
||||
self.gui_color_temp_main_light.set_feedback(0)
|
||||
self.gui_br_ct_main_light = devices.nodered_gui_brightness_color_temp(mqtt_client, topic_gui_br_ct)
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.enable_brightness_n_colortemp)
|
||||
self.main_light_tradfri.add_callback(
|
||||
devices.tradfri_light.KEY_BRIGHTNESS, None, self.set_gui_brightness_main_light)
|
||||
self.main_light_tradfri.add_callback(
|
||||
devices.tradfri_light.KEY_COLOR_TEMP, None, self.set_gui_color_temp_main_light)
|
||||
self.gui_brightness_main_light.add_callback(
|
||||
devices.nodered_gui.KEY_BRIGHTNESS, None, self.set_brightness_main_light)
|
||||
self.gui_color_temp_main_light.add_callback(
|
||||
devices.nodered_gui.KEY_COLOR_TEMP, None, self.set_color_temp_main_light)
|
||||
|
||||
def enable_brightness_n_colortemp(self, devive, key, data):
|
||||
self.gui_brightness_main_light.enable(data)
|
||||
self.gui_color_temp_main_light.enable(data)
|
||||
if data is False:
|
||||
self.gui_brightness_main_light.set_feedback(0)
|
||||
self.gui_color_temp_main_light.set_feedback(0)
|
||||
else:
|
||||
self.gui_brightness_main_light.set_feedback(self.main_light_tradfri.brightness)
|
||||
self.gui_color_temp_main_light.set_feedback(self.main_light_tradfri.color_temp / 10)
|
||||
|
||||
def set_gui_brightness_main_light(self, device, key, data):
|
||||
self.gui_brightness_main_light.set_feedback(data)
|
||||
|
||||
def set_gui_color_temp_main_light(self, device, key, data):
|
||||
self.gui_color_temp_main_light.set_feedback(data / 10)
|
||||
|
||||
def set_brightness_main_light(self, device, key, data):
|
||||
logger.info("Setting brightness \"%s\" main light: %.1f", type(self).__name__, data)
|
||||
self.main_light_tradfri.set_brightness(data)
|
||||
|
||||
def set_color_temp_main_light(self, device, key, data):
|
||||
logger.info("Setting color_temp \"%s\" main light: %.1f", type(self).__name__, data)
|
||||
self.main_light_tradfri.set_color_temp(data * 10)
|
||||
|
||||
def fade_light(self, device, topic, data):
|
||||
if (data == 'brightness_up_hold'):
|
||||
logger.info("Increasing brightness \"%s\" main light", type(self).__name__)
|
||||
self.main_light_tradfri.brightness_inc()
|
||||
elif (data == 'brightness_down_hold'):
|
||||
logger.info("Decreasing brightness \"%s\" main light", type(self).__name__)
|
||||
self.main_light_tradfri.brightness_dec()
|
||||
elif (data.startswith('brightness') and data.endswith('release')):
|
||||
logger.info("Stoping brightness change \"%s\" main light", type(self).__name__)
|
||||
self.main_light_tradfri.brightness_stop()
|
||||
self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_br_ct_main_light.set_enable_mcb)
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_BRIGHTNESS, None, self.gui_br_ct_main_light.set_brightness_mcb)
|
||||
self.main_light_tradfri.add_callback(devices.tradfri_light.KEY_COLOR_TEMP, None, self.gui_br_ct_main_light.set_color_temp_mcb)
|
||||
self.gui_br_ct_main_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_BRIGHTNESS,
|
||||
None, self.main_light_tradfri.set_brightness_mcb)
|
||||
self.gui_br_ct_main_light.add_callback(devices.nodered_gui_brightness_color_temp.KEY_COLOR_TEMP,
|
||||
None, self.main_light_tradfri.set_color_temp_mcb)
|
||||
|
||||
|
||||
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)
|
||||
def __init__(self, mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct):
|
||||
super().__init__(mqtt_client, topic_shelly, topic_gui_switch, topic_tradfri_light, topic_gui_br_ct)
|
||||
#
|
||||
# Callback initialisation
|
||||
#
|
||||
@ -138,7 +85,7 @@ class room_shelly_silvercrest_light(room_shelly_tradfri_light):
|
||||
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:
|
||||
if data is True and self.main_light_shelly_last != data:
|
||||
self.send_init_message_main_light()
|
||||
self.main_light_shelly_last = data
|
||||
|
||||
|
@ -10,14 +10,12 @@ logger = logging.getLogger(config.APP_NAME)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if config.DEBUG:
|
||||
report.appLoggingConfigure(None, None, ((config.APP_NAME, logging.DEBUG), ),
|
||||
fmt=report.SHORT_FMT, host='localhost', port=19996)
|
||||
report.appLoggingConfigure(None, None, ((config.APP_NAME, logging.DEBUG), ), fmt=report.SHORT_FMT, host='localhost', port=19996)
|
||||
else:
|
||||
report.stdoutLoggingConfigure(((config.APP_NAME, logging.INFO),
|
||||
(config.APP_NAME+'.devices', logging.WARNING)), report.SHORT_FMT)
|
||||
report.stdoutLoggingConfigure(((config.APP_NAME, logging.INFO), (config.APP_NAME+'.devices', logging.WARNING)), report.SHORT_FMT)
|
||||
#
|
||||
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT,
|
||||
username=config.MQTT_USER, password=config.MQTT_PASSWORD, name=config.APP_NAME)
|
||||
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
|
||||
password=config.MQTT_PASSWORD, name=config.APP_NAME)
|
||||
|
||||
func = function.all_functions(mc)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user