Smarthome Functionen
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

first_floor_west.py 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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, videv_switching
  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.floor = first_floor_west_floor(mqtt_client, pd, vd)
  21. self.bath = first_floor_west_bath(mqtt_client, pd, vd)
  22. self.julian = first_floor_west_julian(mqtt_client, pd, vd)
  23. self.livingroom = first_floor_west_living(mqtt_client, pd, vd)
  24. self.sleep = first_floor_west_sleep(mqtt_client, pd, vd)
  25. class first_floor_west_floor(room):
  26. def __init__(self, mqtt_client, pd, vd):
  27. roo = props.ROO_FLO
  28. #
  29. # Device initialisation
  30. #
  31. # http://shelly1-58BF25D848EA
  32. # main light
  33. self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  34. super().__init__(mqtt_client, pd, vd)
  35. #
  36. # Virtual Device Interface
  37. #
  38. # main light
  39. self.main_light = videv_switching(
  40. mqtt_client, config.TOPIC_FFW_FLOOR_MAIN_LIGHT_VIDEV,
  41. self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0
  42. )
  43. class first_floor_west_julian(room):
  44. def __init__(self, mqtt_client, pd, vd):
  45. roo = props.ROO_JUL
  46. #
  47. # Device initialisation
  48. #
  49. # http://shelly1l-3C6105E43452
  50. # main light
  51. self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  52. self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
  53. # heating function
  54. self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
  55. super().__init__(mqtt_client, pd, vd)
  56. #
  57. # Functionality initialisation
  58. #
  59. # heating function
  60. self.heating_function = heating_function(
  61. self.heating_valve,
  62. config.DEFAULT_TEMPERATURE,
  63. **get_radiator_data(self.heating_valve.topic)
  64. )
  65. self.heating_function.add_callback(None, None, set_radiator_data, True)
  66. #
  67. # Virtual Device Interface
  68. #
  69. # main light
  70. self.main_light_videv = videv_switch_brightness_color_temp(
  71. mqtt_client, config.TOPIC_FFW_JULIAN_MAIN_LIGHT_VIDEV,
  72. self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
  73. self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS,
  74. self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP
  75. )
  76. # heating function
  77. self.heating_function_videv = videv_heating(
  78. mqtt_client, config.TOPIC_FFW_JULIAN_HEATING_VALVE_VIDEV,
  79. self.heating_function
  80. )
  81. class first_floor_west_bath(room):
  82. def __init__(self, mqtt_client, pd, vd):
  83. roo = props.ROO_BAT
  84. #
  85. # Device initialisation
  86. #
  87. # http://shelly1-58BF25D84219
  88. # main light
  89. self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  90. # heating function
  91. self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
  92. super().__init__(mqtt_client, pd, vd)
  93. #
  94. # Functionality initialisation
  95. #
  96. # heating function
  97. self.heating_function = heating_function(
  98. self.heating_valve,
  99. config.DEFAULT_TEMPERATURE,
  100. **get_radiator_data(self.heating_valve.topic)
  101. )
  102. self.heating_function.add_callback(None, None, set_radiator_data, True)
  103. #
  104. # Virtual Device Interface
  105. #
  106. # main light
  107. self.main_light = videv_switching(
  108. mqtt_client, config.TOPIC_FFW_BATH_MAIN_LIGHT_VIDEV,
  109. self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0
  110. )
  111. # heating function
  112. self.heating_function_videv = videv_heating(
  113. mqtt_client, config.TOPIC_FFW_BATH_HEATING_VALVE_VIDEV,
  114. self.heating_function
  115. )
  116. class first_floor_west_living(room):
  117. def __init__(self, mqtt_client, pd, vd):
  118. roo = props.ROO_LIV
  119. #
  120. # Device initialisation
  121. #
  122. # http://shelly1l-84CCA8ACE6A1
  123. # main light
  124. self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  125. self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
  126. # heating function
  127. self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
  128. super().__init__(mqtt_client, pd, vd)
  129. #
  130. # Functionality initialisation
  131. #
  132. # heating function
  133. self.heating_function = heating_function(
  134. self.heating_valve,
  135. config.DEFAULT_TEMPERATURE,
  136. **get_radiator_data(self.heating_valve.topic)
  137. )
  138. self.heating_function.add_callback(None, None, set_radiator_data, True)
  139. #
  140. # Virtual Device Interface
  141. #
  142. # main light
  143. self.main_light_videv = videv_switch_brightness_color_temp(
  144. mqtt_client, config.TOPIC_FFW_LIVINGROOM_MAIN_LIGHT_VIDEV,
  145. self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
  146. self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS,
  147. self.main_light_tradfri, self.main_light_tradfri.KEY_COLOR_TEMP
  148. )
  149. # heating function
  150. self.heating_function_videv = videv_heating(
  151. mqtt_client, config.TOPIC_FFW_LIVINGROOM_HEATING_VALVE_VIDEV,
  152. self.heating_function
  153. )
  154. class first_floor_west_sleep(room):
  155. def __init__(self, mqtt_client, pd, vd):
  156. roo = props.ROO_SLP
  157. #
  158. # Device initialisation
  159. #
  160. # http://shelly1-3494546A51F2
  161. # main light
  162. self.main_light_shelly = pd.get(props.STG_SHE, loc, roo, props.FUN_MAL)
  163. self.main_light_tradfri = pd.get(props.STG_ZFW, loc, roo, props.FUN_MAL)
  164. # heating function
  165. self.heating_valve = pd.get(props.STG_ZFW, loc, roo, props.FUN_HEA)
  166. super().__init__(mqtt_client, pd, vd)
  167. #
  168. # Functionality initialisation
  169. #
  170. # heating function
  171. self.heating_function = heating_function(
  172. self.heating_valve,
  173. config.DEFAULT_TEMPERATURE,
  174. **get_radiator_data(self.heating_valve.topic)
  175. )
  176. self.heating_function.add_callback(None, None, set_radiator_data, True)
  177. #
  178. # Virtual Device Interface
  179. #
  180. # main light
  181. self.main_light_videv = videv_switch_brightness(
  182. mqtt_client, config.TOPIC_FFW_SLEEP_MAIN_LIGHT_VIDEV,
  183. self.main_light_shelly, self.main_light_shelly.KEY_OUTPUT_0,
  184. self.main_light_tradfri, self.main_light_tradfri.KEY_BRIGHTNESS
  185. )
  186. # heating function
  187. self.heating_function_videv = videv_heating(
  188. mqtt_client, config.TOPIC_FFW_SLEEP_HEATING_VALVE_VIDEV,
  189. self.heating_function
  190. )