Smarthome Functionen
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

first_floor_west.py 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import config
  5. from devdi import topic as props
  6. from function.db import get_radiator_data, set_radiator_data
  7. from function.modules import heating_function
  8. from function.rooms import room, room_collection
  9. from function.videv import videv_switch_brightness, videv_switch_brightness_color_temp, videv_heating
  10. import logging
  11. try:
  12. from config import APP_NAME as ROOT_LOGGER_NAME
  13. except ImportError:
  14. ROOT_LOGGER_NAME = 'root'
  15. logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
  16. loc = props.LOC_FFW
  17. class first_floor_west(room_collection):
  18. def __init__(self, mqtt_client, pd, vd):
  19. super().__init__(mqtt_client, pd, vd)
  20. self.bath = first_floor_west_bath(mqtt_client, pd, vd)
  21. self.julian = first_floor_west_julian(mqtt_client, pd, vd)
  22. self.livingroom = first_floor_west_living(mqtt_client, pd, vd)
  23. self.sleep = first_floor_west_sleep(mqtt_client, pd, vd)
  24. class first_floor_west_julian(room):
  25. def __init__(self, mqtt_client, pd, vd):
  26. roo = props.ROO_JUL
  27. #
  28. # Device initialisation
  29. #
  30. # http://shelly1l-3C6105E43452
  31. # main light
  32. self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  33. self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
  34. # heating function
  35. self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
  36. super().__init__(mqtt_client, pd, vd)
  37. #
  38. # Functionality initialisation
  39. #
  40. # heating function
  41. self.heating_function = heating_function(
  42. self.heating_valve,
  43. config.DEFAULT_TEMPERATURE,
  44. **get_radiator_data(self.heating_valve.topic)
  45. )
  46. self.heating_function.add_callback(None, None, set_radiator_data, True)
  47. #
  48. # Virtual Device Interface
  49. #
  50. # main light
  51. self.main_light_videv = videv_switch_brightness_color_temp(
  52. mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_VIDEV,
  53. self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
  54. self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS,
  55. self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP
  56. )
  57. # heating function
  58. self.heating_function_videv = videv_heating(
  59. mqtt_client, config.TOPIC_FFW_JULIAN_HEATING_VALVE_VIDEV,
  60. self.heating_function
  61. )
  62. class first_floor_west_bath(room):
  63. def __init__(self, mqtt_client, pd, vd):
  64. roo = props.ROO_BAT
  65. #
  66. # Device initialisation
  67. #
  68. # heating function
  69. self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
  70. super().__init__(mqtt_client, pd, vd)
  71. #
  72. # Functionality initialisation
  73. #
  74. # heating function
  75. self.heating_function = heating_function(
  76. self.heating_valve,
  77. config.DEFAULT_TEMPERATURE,
  78. **get_radiator_data(self.heating_valve.topic)
  79. )
  80. self.heating_function.add_callback(None, None, set_radiator_data, True)
  81. #
  82. # Virtual Device Interface
  83. #
  84. # heating function
  85. self.heating_function_videv = videv_heating(
  86. mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_VIDEV,
  87. self.heating_function
  88. )
  89. class first_floor_west_living(room):
  90. def __init__(self, mqtt_client, pd, vd):
  91. roo = props.ROO_LIV
  92. #
  93. # Device initialisation
  94. #
  95. # http://shelly1l-84CCA8ACE6A1
  96. # main light
  97. self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  98. self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
  99. # # heating function
  100. # self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
  101. super().__init__(mqtt_client, pd, vd)
  102. #
  103. # Functionality initialisation
  104. #
  105. # # heating function
  106. # self.heating_function = heating_function(
  107. # self.heating_valve,
  108. # config.DEFAULT_TEMPERATURE[self.heating_valve.topic],
  109. # **get_radiator_data(self.heating_valve.topic)
  110. # )
  111. # self.heating_function.add_callback(None, None, set_radiator_data, True)
  112. #
  113. # Virtual Device Interface
  114. #
  115. # main light
  116. self.main_light_videv = videv_switch_brightness_color_temp(
  117. mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_VIDEV,
  118. self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
  119. self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS,
  120. self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP
  121. )
  122. # # heating function
  123. # self.heating_function_videv = videv_heating(
  124. # mqtt_client, config.TOPIC_FFW_LIVINGROOM_HEATING_VALVE_VIDEV,
  125. # self.heating_function
  126. # )
  127. class first_floor_west_sleep(room):
  128. def __init__(self, mqtt_client, pd, vd):
  129. roo = props.ROO_SLP
  130. #
  131. # Device initialisation
  132. #
  133. # http://shelly1-3494546A51F2
  134. # main light
  135. self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  136. self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
  137. # heating function
  138. self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
  139. super().__init__(mqtt_client, pd, vd)
  140. #
  141. # Functionality initialisation
  142. #
  143. # heating function
  144. self.heating_function = heating_function(
  145. self.heating_valve,
  146. config.DEFAULT_TEMPERATURE,
  147. **get_radiator_data(self.heating_valve.topic)
  148. )
  149. self.heating_function.add_callback(None, None, set_radiator_data, True)
  150. #
  151. # Virtual Device Interface
  152. #
  153. # main light
  154. self.main_light_videv = videv_switch_brightness(
  155. mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_VIDEV,
  156. self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
  157. self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS
  158. )
  159. # heating function
  160. self.heating_function_videv = videv_heating(
  161. mqtt_client, config.TOPIC_FFW_SLEEP_HEATING_VALVE_VIDEV,
  162. self.heating_function
  163. )