From 814e0ee1b29f4a25c30193c13a2253c063807d0b Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sat, 23 Dec 2023 07:38:14 +0100 Subject: [PATCH] garden added --- devdi | 2 +- function/__init__.py | 3 ++ function/first_floor_east.py | 2 +- function/garden.py | 59 ++++++++++++++++++++++++++++++++++++ function/helpers.py | 2 +- 5 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 function/garden.py diff --git a/devdi b/devdi index 773d0a6..7e4f92a 160000 --- a/devdi +++ b/devdi @@ -1 +1 @@ -Subproject commit 773d0a6679810b365bbd4537156c513b0f496c5a +Subproject commit 7e4f92aaf1cd1dd2626e2b3337277eddfc37578e diff --git a/function/__init__.py b/function/__init__.py index 5fee2fe..2089508 100644 --- a/function/__init__.py +++ b/function/__init__.py @@ -3,6 +3,7 @@ # import config import devices +from function.garden import garden from function.stairway import stairway from function.ground_floor_west import ground_floor_west from function.first_floor_west import first_floor_west @@ -24,6 +25,8 @@ class all_functions(room_collection): # # Rooms # + # garden + self.gar = garden(self.mqtt_client, pd, vd) # stairway self.stw = stairway(self.mqtt_client, pd, vd) # ground floor west diff --git a/function/first_floor_east.py b/function/first_floor_east.py index 3a0534f..704d8fb 100644 --- a/function/first_floor_east.py +++ b/function/first_floor_east.py @@ -61,7 +61,7 @@ class first_floor_east_kitchen(room): # http://shelly1l-8CAAB5616C01 # main light self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL) - # http://shelly1-e89f6d85a466/ + # http://shelly1-e89f6d85a466 # circulation pump self.circulation_pump_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_CIR) # heating function diff --git a/function/garden.py b/function/garden.py new file mode 100644 index 0000000..f4fae3e --- /dev/null +++ b/function/garden.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# + +import config +import devdi.props 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 +import logging + +try: + from config import APP_NAME as ROOT_LOGGER_NAME +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, vd): + super().__init__(mqtt_client, pd, vd) + self.garden = garden_garden(mqtt_client, pd, vd) + + +class garden_garden(room): + def __init__(self, mqtt_client, pd, vd): + roo = props.ROO_GAR + # + # Device initialisation + # + self.day_events = day_event((6, 0), (22, 0), 30, -30) + + self.garland_powerplug = pd.get(props.STG_ZGW, loc, roo, props.FUN_GAR) + super().__init__(mqtt_client, pd, vd) + + # + # Functionality initialisation + # + self.day_events.add_callback(None, True, self.__day_events__, True) + + # + # Virtual Device Interface + # + # garland + self.garland_videv = videv_switching( + mqtt_client, config.TOPIC_GAR_GARDEN_GARLAND_VIDEV, + self.garland_powerplug, self.garland_powerplug.KEY_OUTPUT_0 + ) + + 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) diff --git a/function/helpers.py b/function/helpers.py index 3efbb52..382bb0a 100644 --- a/function/helpers.py +++ b/function/helpers.py @@ -99,7 +99,7 @@ class day_event(day_state): :type time_start_of_day: int """ - def __init__(self, time_start_of_day=(6, 0), time_start_of_night=(22, 0), time_offset_sunrise=30, time_offset_sunset=-30): + def __init__(self, time_start_of_day=(5, 0), time_start_of_night=(22, 0), time_offset_sunrise=30, time_offset_sunset=-30): super().__init__(time_start_of_day, time_start_of_night, time_offset_sunrise, time_offset_sunset) # current_day_state = self.get_state()