Smarthome Functionen
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

first_floor_east.py 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import config
  5. import devices
  6. from function.modules import brightness_choose_n_action, timer_on_activation, heating_function
  7. from function.rooms import room
  8. from function.videv import videv_switching, videv_switch_brightness, videv_switching_timer, videv_switch_brightness_color_temp, videv_heating, videv_multistate
  9. import logging
  10. try:
  11. from config import APP_NAME as ROOT_LOGGER_NAME
  12. except ImportError:
  13. ROOT_LOGGER_NAME = 'root'
  14. logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
  15. class first_floor_east_floor(room):
  16. def __init__(self, mqtt_client):
  17. #
  18. # Device initialisation
  19. #
  20. # http://shelly1l-3C6105E4E629
  21. self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_SHELLY)
  22. super().__init__(mqtt_client)
  23. #
  24. # Virtual Device Interface
  25. #
  26. self.main_light = videv_switching(
  27. mqtt_client, config.TOPIC_FFE_FLOOR_MAIN_LIGHT_VIDEV,
  28. self.main_light_shelly, devices.shelly.KEY_OUTPUT_0
  29. )
  30. class first_floor_east_kitchen(room):
  31. def __init__(self, mqtt_client):
  32. #
  33. # Device initialisation
  34. #
  35. # http://shelly1l-8CAAB5616C01
  36. self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_SHELLY)
  37. # http://shelly1-e89f6d85a466/
  38. self.circulation_pump_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_SHELLY)
  39. super().__init__(mqtt_client)
  40. #
  41. # Functionality initialisation
  42. #
  43. self.circulation_pump = timer_on_activation(self.circulation_pump_shelly, devices.shelly.KEY_OUTPUT_0, 10*60)
  44. self.circulation_pump_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, True, self.main_light_shelly.flash_0_mcb, True)
  45. #
  46. # Virtual Device Interface
  47. #
  48. self.main_light_videv = videv_switching(
  49. mqtt_client, config.TOPIC_FFE_KITCHEN_MAIN_LIGHT_VIDEV,
  50. self.main_light_shelly, devices.shelly.KEY_OUTPUT_0
  51. )
  52. self.circulation_pump_videv = videv_switching_timer(
  53. mqtt_client, config.TOPIC_FFE_KITCHEN_CIRCULATION_PUMP_VIDEV,
  54. self.circulation_pump_shelly, devices.shelly.KEY_OUTPUT_0,
  55. self.circulation_pump, timer_on_activation.KEY_TIMER
  56. )
  57. class first_floor_east_dining(room):
  58. def __init__(self, mqtt_client):
  59. #
  60. # Device initialisation
  61. #
  62. # http://shelly1l-84CCA8ADD055
  63. self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_SHELLY)
  64. self.floorlamp_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_POWERPLUG)
  65. if config.CHRISTMAS:
  66. self.garland_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_POWERPLUG)
  67. super().__init__(mqtt_client)
  68. #
  69. # Functionality initialisation
  70. #
  71. self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_powerplug.set_output_0_mcb, True)
  72. #
  73. # Virtual Device Interface
  74. #
  75. self.main_light_videv = videv_switching(
  76. mqtt_client, config.TOPIC_FFE_DININGROOM_MAIN_LIGHT_VIDEV,
  77. self.main_light_shelly, devices.shelly.KEY_OUTPUT_0
  78. )
  79. self.floorlamp_videv = videv_switching(
  80. mqtt_client, config.TOPIC_FFE_DININGROOM_FLOOR_LAMP_VIDEV,
  81. self.floorlamp_powerplug, devices.silvercrest_powerplug.KEY_OUTPUT_0
  82. )
  83. if config.CHRISTMAS:
  84. self.garland_videv = videv_switching(
  85. mqtt_client, config.TOPIC_FFE_DININGROOM_GARLAND_VIDEV,
  86. self.garland_powerplug, devices.silvercrest_powerplug.KEY_OUTPUT_0
  87. )
  88. class first_floor_east_sleep(room):
  89. def __init__(self, mqtt_client):
  90. #
  91. # Device initialisation
  92. #
  93. # http://shelly1l-E8DB84A254C7
  94. self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_SHELLY)
  95. self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_ZIGBEE)
  96. self.bed_light_di_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_ZIGBEE)
  97. self.bed_light_ma_powerplug = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_POWERPLUG)
  98. self.heating_valve = devices.brennenstuhl_heatingvalve(mqtt_client, config.TOPIC_FFE_SLEEP_HEATING_VALVE_ZIGBEE)
  99. self.button_tradfri = devices.tradfri_button(mqtt_client, config.TOPIC_FFE_SLEEP_INPUT_DEVICE)
  100. super().__init__(mqtt_client)
  101. #
  102. # Functionality initialisation
  103. #
  104. # button / brightness function
  105. self.brightness_functions = brightness_choose_n_action(self.button_tradfri)
  106. self.brightness_functions.add(self.main_light_tradfri, self.main_light_shelly, devices.shelly.KEY_OUTPUT_0)
  107. self.brightness_functions.add(self.bed_light_di_tradfri, self.bed_light_di_tradfri, devices.tradfri_light.KEY_OUTPUT_0)
  108. # button / main light
  109. self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_TOGGLE,
  110. self.main_light_shelly.toggle_output_0_mcb)
  111. # button / bed light
  112. self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT,
  113. self.bed_light_di_tradfri.toggle_output_0_mcb)
  114. self.button_tradfri.add_callback(devices.tradfri_button.KEY_ACTION, devices.tradfri_button.ACTION_LEFT_LONG,
  115. self.bed_light_ma_powerplug.toggle_output_0_mcb)
  116. # heating function
  117. self.heating_function = heating_function(self.heating_valve, config.DEFAULT_TEMPERATURE_FFE_SLEEP)
  118. #
  119. # Virtual Device Interface
  120. #
  121. self.main_light_videv = videv_switch_brightness_color_temp(
  122. mqtt_client, config.TOPIC_FFE_SLEEP_MAIN_LIGHT_VIDEV,
  123. self.main_light_shelly, devices.shelly.KEY_OUTPUT_0,
  124. self.main_light_tradfri, devices.tradfri_light.KEY_BRIGHTNESS,
  125. self.main_light_tradfri, devices.tradfri_light.KEY_COLOR_TEMP
  126. )
  127. self.bed_light_di_videv = videv_switch_brightness(
  128. mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_DI_VIDEV,
  129. self.bed_light_di_tradfri, devices.tradfri_light.KEY_OUTPUT_0,
  130. self.bed_light_di_tradfri, devices.tradfri_light.KEY_BRIGHTNESS,
  131. )
  132. self.bed_light_ma_videv = videv_switching(
  133. mqtt_client, config.TOPIC_FFE_SLEEP_BED_LIGHT_MA_VIDEV,
  134. self.bed_light_ma_powerplug, devices.silvercrest_powerplug.KEY_OUTPUT_0
  135. )
  136. self.heating_function_videv = videv_heating(
  137. mqtt_client, config.TOPIC_FFE_SLEEP_HEATING_VALVE_VIDEV,
  138. self.heating_function
  139. )
  140. self.brightness_functions_device_videv = videv_multistate(
  141. mqtt_client, config.TOPIC_FFE_SLEEP_ACTIVE_BRIGHTNESS_DEVICE_VIDEV,
  142. brightness_choose_n_action.KEY_ACTIVE_DEVICE, self.brightness_functions, 2
  143. )
  144. class first_floor_east_living(room):
  145. def __init__(self, mqtt_client):
  146. #
  147. # Device initialisation
  148. #
  149. # http://shelly1l-3C6105E3F910
  150. self.main_light_shelly = devices.shelly(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_SHELLY)
  151. self.main_light_tradfri = devices.tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_ZIGBEE)
  152. self.floorlamp_tradfri = devices.group(
  153. *[devices.tradfri_light(mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_ZIGBEE % i) for i in range(1, 7)])
  154. if config.CHRISTMAS:
  155. self.powerplug_xmas_tree = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_POWERPLUG)
  156. self.powerplug_xmas_star = devices.silvercrest_powerplug(mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_STAR_POWERPLUG)
  157. super().__init__(mqtt_client)
  158. #
  159. # Functionality initialisation
  160. #
  161. # floor lamp synchronisation with main_light
  162. self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.floorlamp_tradfri.set_output_0_mcb, True)
  163. #
  164. # Virtual Device Interface
  165. #
  166. self.main_light_videv = videv_switch_brightness_color_temp(
  167. mqtt_client, config.TOPIC_FFE_LIVINGROOM_MAIN_LIGHT_VIDEV,
  168. self.main_light_shelly, devices.shelly.KEY_OUTPUT_0,
  169. self.main_light_tradfri, devices.tradfri_light.KEY_BRIGHTNESS,
  170. self.main_light_tradfri, devices.tradfri_light.KEY_COLOR_TEMP
  171. )
  172. self.floorlamp_videv = videv_switch_brightness_color_temp(
  173. mqtt_client, config.TOPIC_FFE_LIVINGROOM_FLOOR_LAMP_VIDEV,
  174. self.floorlamp_tradfri, devices.tradfri_light.KEY_OUTPUT_0,
  175. self.floorlamp_tradfri, devices.tradfri_light.KEY_BRIGHTNESS,
  176. self.floorlamp_tradfri, devices.tradfri_light.KEY_COLOR_TEMP
  177. )
  178. if config.CHRISTMAS:
  179. self.xmas_tree_videv = videv_switching(
  180. mqtt_client, config.TOPIC_FFE_LIVINGROOM_XMAS_TREE_VIDEV,
  181. self.powerplug_xmas_tree, devices.silvercrest_powerplug.KEY_OUTPUT_0
  182. )