From 158c41ef0ee6535972275097444e7eb90bb20d05 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Tue, 26 Aug 2025 21:12:45 +0200 Subject: [PATCH] gar changed to new devdi concept --- devdi | 2 +- devices/__init__.py | 1 + function/__init__.py | 2 +- function/garden.py | 56 ++++++++++---------------------------------- function/videv.py | 6 ----- 5 files changed, 16 insertions(+), 51 deletions(-) diff --git a/devdi b/devdi index 31c0025..f13cdfd 160000 --- a/devdi +++ b/devdi @@ -1 +1 @@ -Subproject commit 31c00259ded5a8a1204b73b48010b7766989e615 +Subproject commit f13cdfdcb7dcc543d3a882351bd817fa2da5fe01 diff --git a/devices/__init__.py b/devices/__init__.py index 08b58e0..1000959 100644 --- a/devices/__init__.py +++ b/devices/__init__.py @@ -48,6 +48,7 @@ from function.videv import videv_switch_brightness as videv_sw_br from function.videv import videv_switch_brightness_color_temp as videv_sw_br_ct from function.videv import videv_switching_timer as videv_sw_tm from function.videv import videv_heating as videv_hea +from function.videv import videv_pure_switch from function.videv import videv_multistate try: diff --git a/function/__init__.py b/function/__init__.py index 33225ea..544a31c 100644 --- a/function/__init__.py +++ b/function/__init__.py @@ -30,7 +30,7 @@ class all_functions(room_collection): # Rooms # # garden - self.gar = garden(self.mqtt_client, pd) + self.gar = garden(self.mqtt_client) # stairway self.stw = stairway(self.mqtt_client, pd) # ground floor west diff --git a/function/garden.py b/function/garden.py index ea9815c..b15deff 100644 --- a/function/garden.py +++ b/function/garden.py @@ -2,11 +2,9 @@ # -*- coding: utf-8 -*- # -import config -import devdi.topic as props +from devdi import rooms from function.helpers import day_event from function.rooms import room, room_collection -from function.videv import videv_switching, videv_pure_switch import logging try: @@ -15,56 +13,28 @@ except ImportError: ROOT_LOGGER_NAME = 'root' logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__) -loc = props.LOC_GAR - class garden(room_collection): - def __init__(self, mqtt_client, pd): + def __init__(self, mqtt_client): super().__init__(mqtt_client) - self.garden = garden_garden(mqtt_client, pd) + self.garden = garden_garden(mqtt_client) -class garden_garden(room): - def __init__(self, mqtt_client, pd): - roo = props.ROO_GAR - # - # Device initialisation +class garden_garden(rooms.gar_garden, room): + def __init__(self, mqtt_client): + super().__init__(mqtt_client) + room.__init__(self, mqtt_client) # self.day_events = day_event((6, 0), (22, 0), 30, -30) - - # garden powerplugs - self.garland_powerplug = pd.get(props.STG_ZGW, loc, roo, props.FUN_GAR) - # repeater - self.repeater = pd.get(props.STG_ZGW, loc, roo, props.FUN_REP) - - super().__init__(mqtt_client) - - # - # Functionality initialisation - # self.day_events.add_callback(None, True, self.__day_events__, True) - # - # 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, - self.garland_powerplug, self.garland_powerplug.KEY_OUTPUT_0 - ) - # repeater - self.repeater_videv = videv_switching( - mqtt_client, config.TOPIC_GAR_GARDEN_REPEATER_VIDEV, - self.repeater, self.repeater.KEY_OUTPUT_0 - ) + # xxx <-> videv + self.videv_garland_light.connect_sw_device(self.switch_garland_light, self.switch_garland_light.KEY_OUTPUT_0) + self.videv_repeater.connect_sw_device(self.switch_repeater, self.switch_repeater.KEY_OUTPUT_0) def __day_events__(self, device, key, data): - if self.mode_videv.get(self.mode_videv.KEY_STATE): + if self.videv_mode.get(self.videv_mode.KEY_STATE): if key in (self.day_events.KEY_SUNSET, self.day_events.KEY_START_OF_DAY): - self.garland_powerplug.set_output_0(True) + self.switch_garland_light.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) + self.switch_garland_light.set_output_0(False) diff --git a/function/videv.py b/function/videv.py index d20546f..8ce2a6f 100644 --- a/function/videv.py +++ b/function/videv.py @@ -12,12 +12,6 @@ Targets: from base import videv_base from function.rooms import room, room_collection -import time - -try: - from config import APP_NAME as ROOT_LOGGER_NAME -except ImportError: - ROOT_LOGGER_NAME = 'root' class videv_pure_switch(videv_base):