1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import config
- import devices
- from function.stairway import stairway
- from function.ground_floor_west import ground_floor_west
- from function.first_floor_west import first_floor_west
- from function.first_floor_east import first_floor_east
- from function.rooms import room_collection
- from function.videv import all_off
- import inspect
- 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__)
-
- # TODO: implement garland (incl. day events like sunset, sunrise, ...)
- # TODO: implement warning message
-
-
- class all_functions(room_collection):
- def __init__(self, mqtt_client):
- super().__init__(mqtt_client)
- #
- # Rooms
- #
- # stairway
- self.stw = stairway(self.mqtt_client)
- # ground floor west
- self.gfw = ground_floor_west(self.mqtt_client)
- # first floor west
- self.ffw = first_floor_west(self.mqtt_client)
- # first floor east
- self.ffe = first_floor_east(self.mqtt_client)
- #
- # Interactions
- #
- # cross_room_interactions
- self.init_cross_room_interactions()
- # Off Buttons
- self.init_off_functionality()
-
- def init_cross_room_interactions(self):
- # shelly dirk input 1
- self.last_gfw_dirk_input_1 = None
- self.gfw.dirk.main_light_shelly.add_callback(devices.shelly.KEY_INPUT_1, None, self.gfw_dirk_input_1)
- # tradfri button ffe_sleep right click
- self.ffe.sleep.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION,
- devices.tradfri_button.ACTION_RIGHT, self.ffe.floor.main_light_shelly.toggle_output_0_mcb)
-
- def init_off_functionality(self):
- # ALL OFF - Virtual device
- self.videv_all_off = all_off(self.mqtt_client, config.TOPIC_ALL_OFF_VIDEV, self)
-
- # ALL OFF - Long push stairway
- self.stw.stairway.main_light_shelly.add_callback(devices.shelly.KEY_LONGPUSH_0, True, self.stw.stairway.main_light_shelly.flash_0_mcb)
- self.stw.stairway.main_light_shelly.add_callback(devices.shelly.KEY_LONGPUSH_0, True, self.all_off)
-
- # FFE ALL OFF - Long push ffe_floor
- self.ffe.floor.main_light_shelly.add_callback(devices.shelly.KEY_LONGPUSH_0, True, self.ffe.floor.main_light_shelly.flash_0_mcb)
- self.ffe.floor.main_light_shelly.add_callback(devices.shelly.KEY_LONGPUSH_0, True, self.ffe.all_off)
-
- # FFE ALL OFF - Long push input device
- self.ffe.sleep.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG, self.ffe.all_off)
-
- def gfw_dirk_input_1(self, device, key, data):
- if self.last_gfw_dirk_input_1 is not None:
- if self.last_gfw_dirk_input_1 != data:
- self.gfw.floor.main_light_shelly.toggle_output_0_mcb(device, key, data)
- self.last_gfw_dirk_input_1 = data
|