#!/usr/bin/env python # -*- coding: utf-8 -*- # import config import devices import logging from function.modules import motion_sensor_light from function.rooms import room from function.videv import videv_switching_motion 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 stairway(room): def __init__(self, mqtt_client): # # Device initialisation # # http://shelly1-3494546A9364 self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_SHELLY) self.motion_sensor_gf = devices.silvercrest_motion_sensor(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_GF) self.motion_sensor_ff = devices.silvercrest_motion_sensor(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_MOTION_SENSOR_FF) super().__init__(mqtt_client) # # Functionality initialisation # self.motion_sensor_light = motion_sensor_light( self.main_light_shelly, self.main_light_shelly.set_output_0, self.motion_sensor_gf, self.motion_sensor_ff, timer_value=config.USER_ON_TIME_STAIRWAYS ) ##### TEMPORARY ################################################################################################################### self.gui_main_light = devices.nodered_gui_light(mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_GUI) self.gui_main_light.add_callback(devices.nodered_gui_light.KEY_STATE, None, self.main_light_shelly.set_output_0_mcb) self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.gui_main_light.set_state_mcb) self.motion_sensor_light.add_callback(motion_sensor_light.KEY_TIMER, None, self.gui_main_light.set_timer_mcb) def set_led(device, key, data): if key == motion_sensor_light.KEY_MOTION_SENSOR_0: self.gui_main_light.set_led(devices.nodered_gui_light.KEY_LED_0, data) if key == motion_sensor_light.KEY_MOTION_SENSOR_1: self.gui_main_light.set_led(devices.nodered_gui_light.KEY_LED_1, data) self.motion_sensor_light.add_callback(motion_sensor_light.KEY_MOTION_SENSOR_0, None, set_led) self.motion_sensor_light.add_callback(motion_sensor_light.KEY_MOTION_SENSOR_1, None, set_led) ##### TEMPORARY ################################################################################################################### # # Virtual Device Interface # self.main_light_videv = videv_switching_motion( mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_VIDEV, self.main_light_shelly, devices.shelly.KEY_OUTPUT_0, self.motion_sensor_light )