#!/usr/bin/env python # -*- coding: utf-8 -*- # from devdi import rooms from function.helpers import day_event from function.rooms import room, room_collection 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__) class garden(room_collection): def __init__(self, mqtt_client): super().__init__(mqtt_client) self.garden = garden_garden(mqtt_client) 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) self.day_events.add_callback(None, True, self.__day_events__, True) # 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.videv_mode.get(self.videv_mode.KEY_STATE): if key in (self.day_events.KEY_SUNSET, self.day_events.KEY_START_OF_DAY): self.switch_garland_light.set_output_0(True) elif key in (self.day_events.KEY_START_OF_NIGHT, self.day_events.KEY_SUNRISE): self.switch_garland_light.set_output_0(False)