1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
-
- 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
- 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)
|