smart_brain/function/stairway.py

55 lines
1.7 KiB
Python
Raw Normal View History

2022-12-28 08:48:07 +01:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import config
2023-12-23 07:50:24 +01:00
from devdi import topic as props
2022-12-28 08:48:07 +01:00
import logging
from function.modules import motion_sensor_light
2023-01-31 19:17:10 +01:00
from function.rooms import room, room_collection
from function.videv import videv_switching_motion
2023-01-20 08:03:06 +01:00
2022-12-28 08:48:07 +01:00
try:
from config import APP_NAME as ROOT_LOGGER_NAME
except ImportError:
ROOT_LOGGER_NAME = 'root'
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
2023-10-29 15:10:06 +01:00
loc = props.LOC_STW
2022-12-28 08:48:07 +01:00
2023-01-31 19:17:10 +01:00
class stairway(room_collection):
2023-10-29 15:10:06 +01:00
def __init__(self, mqtt_client, pd, vd):
super().__init__(mqtt_client, pd, vd)
self.stairway = stairway_stairway(mqtt_client, pd, vd)
2023-01-31 19:17:10 +01:00
class stairway_stairway(room):
2023-10-29 15:10:06 +01:00
def __init__(self, mqtt_client, pd, vd):
#
# Device initialisation
#
2022-12-28 10:47:57 +01:00
# http://shelly1-3494546A9364
2023-10-29 15:10:06 +01:00
self.main_light_shelly = pd.get(props.STG_SHE, loc, props.ROO_STF, props.FUN_MAL)
self.motion_sensor_ff = pd.get(props.STG_ZFE, loc, props.ROO_STF, props.FUN_MSE)
self.motion_sensor_gf = pd.get(props.STG_ZGW, loc, props.ROO_STG, props.FUN_MSE)
super().__init__(mqtt_client, pd, vd)
#
# 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
)
#
# Virtual Device Interface
2023-01-20 08:03:06 +01:00
#
self.main_light_videv = videv_switching_motion(
2023-01-20 08:03:06 +01:00
mqtt_client, config.TOPIC_STW_STAIRWAY_MAIN_LIGHT_VIDEV,
2023-10-29 15:10:06 +01:00
self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
self.motion_sensor_light
2023-01-20 08:03:06 +01:00
)