Added pssibility to disable all_off functionality of output devices. Disabled all_off for ffe.sleep.wardrobe_light

This commit is contained in:
Dirk Alders 2024-09-05 07:13:59 +02:00
parent 248e9432d1
commit c9bf036591
6 changed files with 30 additions and 13 deletions

View File

@ -116,3 +116,19 @@ class base(mqtt_base):
self.mqtt_client.send('/'.join([self.topic, key, self.TX_TOPIC] if len(self.TX_TOPIC) > 0 else [self.topic, key]), data)
else:
self.logger.error("Unknown tx toptic. Set TX_TOPIC of class to a known value")
class base_output(base):
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic)
self.__all_off_enabled__ = True
def disable_all_off(self, state=True):
self.__all_off_enabled__ = not state
def all_off(self):
if self.__all_off_enabled__:
try:
self.__all_off__()
except (AttributeError, TypeError) as e:
self.logger.warning("Method all_off was used, but __all_off__ method wasn't callable: %s", repr(e))

View File

@ -1,11 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from devices.base import base
from devices.base import base, base_output
import logging
class powerplug(base):
class powerplug(base_output):
""" Communication (MQTT)
my_powerplug
@ -115,7 +115,7 @@ class powerplug(base):
def set_output_all_mcb(self, device, key, data):
self.set_output_all(data)
def all_off(self):
def __all_off__(self):
self.set_output_all(False)

View File

@ -1,12 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from devices.base import base
from devices.base import base_output
import logging
import task
class shelly(base):
class shelly(base_output):
""" Communication (MQTT)
shelly
@ -52,7 +52,7 @@ class shelly(base):
KEY_FIRMWARE_VERSION = "fw_ver"
#
TX_TOPIC = "command"
TX_TYPE = base.TX_VALUE
TX_TYPE = base_output.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,
@ -161,7 +161,7 @@ class shelly(base):
self.toggle_output_1_mcb(device, key, data)
self.delayed_flash_task.run()
def all_off(self):
def __all_off__(self):
if self.flash_active:
self.all_off_requested = True
else:

View File

@ -1,11 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from devices.base import base
from devices.base import base, base_output
import logging
class silvercrest_powerplug(base):
class silvercrest_powerplug(base_output):
""" Communication (MQTT)
silvercrest_powerplug {
@ -58,7 +58,7 @@ class silvercrest_powerplug(base):
def toggle_output_0_mcb(self, device, key, data):
self.set_output_0(not self.output_0)
def all_off(self):
def __all_off__(self):
if self.output_0:
self.set_output_0(False)

View File

@ -1,11 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from devices.base import base
from devices.base import base, base_output
import logging
class tradfri_light(base):
class tradfri_light(base_output):
""" Communication (MQTT)
tradfri_light {
@ -124,7 +124,7 @@ class tradfri_light(base):
def set_color_temp_mcb(self, device, key, data):
self.set_color_temp(data)
def all_off(self):
def __all_off__(self):
if self.output_0:
self.set_output_0(False)

View File

@ -193,6 +193,7 @@ class first_floor_east_sleep(room):
self.button_tradfri = pd.get(props.STG_ZFE, loc, roo, props.FUN_INP)
# wardrobe light
self.wardrobe_light = pd.get(props.STG_ZFE, loc, roo, props.FUN_WLI)
self.wardrobe_light.disable_all_off() # Always on - Off by light sensor
super().__init__(mqtt_client, pd, vd)