diff --git a/function/garden.py b/function/garden.py index 6bf7d41..cf8b42c 100644 --- a/function/garden.py +++ b/function/garden.py @@ -4,12 +4,9 @@ import config import devdi.topic as props -from devices import group -from function.db import get_radiator_data, set_radiator_data from function.helpers import day_event -from function.modules import brightness_choose_n_action, timer_on_activation, heating_function from function.rooms import room, room_collection -from function.videv import videv_switching, videv_switch_brightness, videv_switching_timer, videv_switch_brightness_color_temp, videv_heating, videv_multistate +from function.videv import videv_switching, videv_pure_switch import logging try: @@ -46,6 +43,10 @@ class garden_garden(room): # # Virtual Device Interface # + # mode + self.mode_videv = videv_pure_switch( + mqtt_client, config.TOPIC_GAR_GARDEN_MODE_VIDEV + ) # garland self.garland_videv = videv_switching( mqtt_client, config.TOPIC_GAR_GARDEN_GARLAND_VIDEV, @@ -53,7 +54,8 @@ class garden_garden(room): ) def __day_events__(self, device, key, data): - if key in (self.day_events.KEY_SUNSET, self.day_events.KEY_START_OF_DAY): - self.garland_powerplug.set_output_0(True) - elif key in (self.day_events.KEY_START_OF_NIGHT, self.day_events.KEY_SUNRISE): - self.garland_powerplug.set_output_0(False) + if self.mode_videv.get(self.mode_videv.KEY_STATE): + if key in (self.day_events.KEY_SUNSET, self.day_events.KEY_START_OF_DAY): + self.garland_powerplug.set_output_0(True) + elif key in (self.day_events.KEY_START_OF_NIGHT, self.day_events.KEY_SUNRISE): + self.garland_powerplug.set_output_0(False) diff --git a/function/videv.py b/function/videv.py index ec847e6..93b2f76 100644 --- a/function/videv.py +++ b/function/videv.py @@ -27,9 +27,9 @@ class videv_pure_switch(videv_base): super().__init__(mqtt_client, topic) self[self.KEY_STATE] = False # - self.mqtt_client.add_callback(self.topic + '/state/set', self.state) + self.mqtt_client.add_callback(self.topic + '/state/set', self.__state__) - def state(self, mqtt_client, tbd, message): + def __state__(self, mqtt_client, userdata, message): self.set(self.KEY_STATE, message.payload == b'true') self.__tx__(self.KEY_STATE, message.payload == b'true') diff --git a/topics.py b/topics.py index cfd296c..d1a2b95 100644 --- a/topics.py +++ b/topics.py @@ -22,6 +22,9 @@ TOPIC_GFW_DIRK_PC_DOCK_VIDEV = "videv/gfw/dirk/pc_dock" TOPIC_GFW_DIRK_ACTIVE_BRIGHTNESS_DEVICE_VIDEV = "videv/gfw/dirk/active_brightness_device" TOPIC_GFW_DIRK_AUDIO_PLAYER_VIDEV = "videv/gfw/dirk/audio_player" TOPIC_GFW_DIRK_HEATING_VALVE_VIDEV = "videv/gfw/dirk/heating_valve" + +# garden +TOPIC_GAR_GARDEN_MODE_VIDEV = 'videv/gar/garden/mode' TOPIC_GAR_GARDEN_GARLAND_VIDEV = 'videv/gar/garden/garland' # first floor west