Global Summer and Winter Mode

This commit is contained in:
Dirk Alders 2024-04-20 16:56:13 +02:00
parent 48313a2245
commit d613c1db5c
4 changed files with 42 additions and 1 deletions

View File

@ -9,7 +9,7 @@ from function.ground_floor_west import ground_floor_west
from function.first_floor_west import first_floor_west
from function.first_floor_east import first_floor_east
from function.rooms import room_collection
from function.videv import all_off
from function.videv import all_off, videv_pure_switch
import logging
try:
@ -42,6 +42,8 @@ class all_functions(room_collection):
self.init_cross_room_interactions()
# Off Buttons
self.init_off_functionality()
# Summer / Winter mode
self.init_sumer_winter_mode()
def init_cross_room_interactions(self):
# shelly dirk input 1
@ -69,6 +71,14 @@ class all_functions(room_collection):
# FFE ALL OFF - Long push input device
self.ffe.sleep.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG, self.ffe.all_off)
def init_sumer_winter_mode(self):
# ALL summer/winter mode
self.videv_summer_mode = videv_pure_switch(self.mqtt_client, config.TOPIC_ALL_SUMMER_WINTER_MODE)
self.videv_summer_mode.add_callback(self.videv_summer_mode.KEY_STATE, None, self.gfw.summer_mode)
self.videv_summer_mode.add_callback(self.videv_summer_mode.KEY_STATE, None, self.ffw.summer_mode)
self.videv_summer_mode.add_callback(self.videv_summer_mode.KEY_STATE, None, self.ffe.summer_mode)
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:

View File

@ -27,6 +27,12 @@ class room(object):
except AttributeError:
pass # not a module or has no method all_off
def summer_mode(self, enable):
for name, obj in inspect.getmembers(self):
if obj.__class__.__name__ == 'heating_function':
if obj.__module__ == 'function.modules':
obj.set(obj.KEY_SUMMER_MODE, enable)
class room_collection(object):
ALLOWED_CLASSES = ("room", "room_collection")
@ -45,6 +51,15 @@ class room_collection(object):
if sub.__class__.__bases__[0].__name__ in self.ALLOWED_CLASSES:
sub.all_off()
def summer_mode(self, device=None, key=None, data=None):
logger.info("Changing to %s \"%s\"", "summer mode" if data else "winter_mode", type(self).__name__)
for sub_name in dir(self):
# attribute name is not private
if not sub_name.startswith("__"):
sub = getattr(self, sub_name)
if sub.__class__.__bases__[0].__name__ in self.ALLOWED_CLASSES:
sub.summer_mode(data)
def all_devices(self, object_to_analyse=None, depth=0):
target = object_to_analyse or self
#

View File

@ -20,6 +20,20 @@ except ImportError:
ROOT_LOGGER_NAME = 'root'
class videv_pure_switch(videv_base):
KEY_STATE = 'state'
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic)
self[self.KEY_STATE] = False
#
self.mqtt_client.add_callback(self.topic + '/state/set', self.state)
def state(self, mqtt_client, tbd, message):
self.set(self.KEY_STATE, message.payload == b'true')
self.__tx__(self.KEY_STATE, message.payload == b'true')
class videv_switching(videv_base):
KEY_STATE = 'state'

View File

@ -3,6 +3,8 @@
#
TOPIC_WARNINGS = "videv/warnings"
TOPIC_ALL_OFF_VIDEV = "videv/off"
TOPIC_ALL_SUMMER_WINTER_MODE = "videv/summer_mode"
# ground floor west
# floor
TOPIC_GFW_FLOOR_MAIN_LIGHT_VIDEV = "videv/gfw/floor/main_light"