Smarthome Functionen
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import config
  5. import devices
  6. from function.garden import garden
  7. from function.stairway import stairway
  8. from function.ground_floor_west import ground_floor_west
  9. from function.first_floor_west import first_floor_west
  10. from function.first_floor_east import first_floor_east
  11. from function.rooms import room_collection
  12. from function.videv import all_off, videv_pure_switch
  13. import logging
  14. try:
  15. from config import APP_NAME as ROOT_LOGGER_NAME
  16. except ImportError:
  17. ROOT_LOGGER_NAME = 'root'
  18. logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
  19. class all_functions(room_collection):
  20. def __init__(self, mqtt_client, pd, vd):
  21. super().__init__(mqtt_client, pd, vd)
  22. #
  23. # Rooms
  24. #
  25. # garden
  26. self.gar = garden(self.mqtt_client, pd, vd)
  27. # stairway
  28. self.stw = stairway(self.mqtt_client, pd, vd)
  29. # ground floor west
  30. self.gfw = ground_floor_west(self.mqtt_client, pd, vd)
  31. # first floor west
  32. self.ffw = first_floor_west(self.mqtt_client, pd, vd)
  33. # first floor east
  34. self.ffe = first_floor_east(self.mqtt_client, pd, vd)
  35. #
  36. # Interactions
  37. #
  38. # cross_room_interactions
  39. self.init_cross_room_interactions()
  40. # Off Buttons
  41. self.init_off_functionality()
  42. # Summer / Winter mode
  43. self.init_sumer_winter_mode()
  44. def init_cross_room_interactions(self):
  45. # shelly dirk input 1
  46. self.last_gfw_dirk_input_1 = None
  47. self.gfw.dirk.main_light_shelly.add_callback(self.gfw.dirk.main_light_shelly.KEY_INPUT_1, None, self.gfw_dirk_input_1)
  48. # tradfri button ffe_sleep right click
  49. self.ffe.sleep.button_tradfri.add_callback(self.ffe.sleep.button_tradfri.KEY_ACTION,
  50. self.ffe.sleep.button_tradfri.ACTION_RIGHT,
  51. self.ffe.floor.main_light_shelly.toggle_output_0_mcb)
  52. def init_off_functionality(self):
  53. # ALL OFF - Virtual device
  54. self.videv_all_off = all_off(self.mqtt_client, config.TOPIC_ALL_OFF_VIDEV, self)
  55. # ALL OFF - Long push stairway
  56. self.stw.stairway.main_light_shelly.add_callback(self.stw.stairway.main_light_shelly.KEY_LONGPUSH_0,
  57. True, self.stw.stairway.main_light_shelly.flash_0_mcb)
  58. self.stw.stairway.main_light_shelly.add_callback(self.stw.stairway.main_light_shelly.KEY_LONGPUSH_0, True, self.all_off)
  59. # FFE ALL OFF - Long push ffe_floor
  60. self.ffe.floor.main_light_shelly.add_callback(self.ffe.floor.main_light_shelly.KEY_LONGPUSH_0,
  61. True, self.ffe.floor.main_light_shelly.flash_0_mcb)
  62. self.ffe.floor.main_light_shelly.add_callback(self.ffe.floor.main_light_shelly.KEY_LONGPUSH_0, True, self.ffe.all_off)
  63. # FFE ALL OFF - Long push input device
  64. self.ffe.sleep.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_RIGHT_LONG, self.ffe.all_off)
  65. # FFW ALL OFF - Long push ffw_floor
  66. self.ffw.floor.main_light_shelly.add_callback(self.ffw.floor.main_light_shelly.KEY_LONGPUSH_0,
  67. True, self.ffw.floor.main_light_shelly.flash_0_mcb)
  68. self.ffw.floor.main_light_shelly.add_callback(self.ffw.floor.main_light_shelly.KEY_LONGPUSH_0, True, self.ffw.all_off)
  69. def init_sumer_winter_mode(self):
  70. # ALL summer/winter mode
  71. self.videv_summer_mode = videv_pure_switch(self.mqtt_client, config.TOPIC_ALL_SUMMER_WINTER_MODE)
  72. self.videv_summer_mode.add_callback(self.videv_summer_mode.KEY_STATE, None, self.gfw.summer_mode)
  73. self.videv_summer_mode.add_callback(self.videv_summer_mode.KEY_STATE, None, self.ffw.summer_mode)
  74. self.videv_summer_mode.add_callback(self.videv_summer_mode.KEY_STATE, None, self.ffe.summer_mode)
  75. def gfw_dirk_input_1(self, device, key, data):
  76. if self.last_gfw_dirk_input_1 is not None:
  77. if self.last_gfw_dirk_input_1 != data:
  78. self.gfw.floor.main_light_shelly.toggle_output_0_mcb(device, key, data)
  79. self.last_gfw_dirk_input_1 = data