12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import config
- import devices
- from function.garden import garden
- 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, videv_pure_switch
- 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 all_functions(room_collection):
- def __init__(self, mqtt_client, pd, vd):
- super().__init__(mqtt_client, pd, vd)
- #
- # Rooms
- #
- # garden
- self.gar = garden(self.mqtt_client, pd, vd)
- # stairway
- self.stw = stairway(self.mqtt_client, pd, vd)
- # ground floor west
- self.gfw = ground_floor_west(self.mqtt_client, pd, vd)
- # first floor west
- self.ffw = first_floor_west(self.mqtt_client, pd, vd)
- # first floor east
- self.ffe = first_floor_east(self.mqtt_client, pd, vd)
- #
- # Interactions
- #
- # cross_room_interactions
- self.init_cross_room_interactions()
- # Off Buttons
- self.init_off_functionality()
- # Summer / Winter mode
- self.init_sumer_winter_mode()
-
- 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(self.gfw.dirk.main_light_shelly.KEY_INPUT_1, None, self.gfw_dirk_input_1)
- # tradfri button ffe_sleep right click
- self.ffe.sleep.button_tradfri.add_callback(self.ffe.sleep.button_tradfri.KEY_ACTION,
- self.ffe.sleep.button_tradfri.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(self.stw.stairway.main_light_shelly.KEY_LONGPUSH_0,
- True, self.stw.stairway.main_light_shelly.flash_0_mcb)
- self.stw.stairway.main_light_shelly.add_callback(self.stw.stairway.main_light_shelly.KEY_LONGPUSH_0, True, self.all_off)
-
- # FFE ALL OFF - Long push ffe_floor
- self.ffe.floor.main_light_shelly.add_callback(self.ffe.floor.main_light_shelly.KEY_LONGPUSH_0,
- True, self.ffe.floor.main_light_shelly.flash_0_mcb)
- self.ffe.floor.main_light_shelly.add_callback(self.ffe.floor.main_light_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)
-
- # FFW ALL OFF - Long push ffw_floor
- self.ffw.floor.main_light_shelly.add_callback(self.ffw.floor.main_light_shelly.KEY_LONGPUSH_0,
- True, self.ffw.floor.main_light_shelly.flash_0_mcb)
- self.ffw.floor.main_light_shelly.add_callback(self.ffw.floor.main_light_shelly.KEY_LONGPUSH_0, True, self.ffw.all_off)
-
- def init_sumer_winter_mode(self):
- # ALL summer/winter mode
- self.videv_summer_mode = videv_pure_switch(self.mqtt_client, config.TOPIC_ALL_SUMMER_WINTER_MODE)
-
- self.videv_summer_mode.add_callback(self.videv_summer_mode.KEY_STATE, None, self.gfw.summer_mode)
- self.videv_summer_mode.add_callback(self.videv_summer_mode.KEY_STATE, None, self.ffw.summer_mode)
- self.videv_summer_mode.add_callback(self.videv_summer_mode.KEY_STATE, None, self.ffe.summer_mode)
-
- 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
|