Smarthome Functionen
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

common.py 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import devices
  5. from function.rooms import room_shelly
  6. from function.modules import heating_function_brennenstuhl
  7. from function.helpers import changed_value_indicator
  8. import logging
  9. import task
  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 common_circulation_pump(room_shelly):
  16. def __init__(self, mqtt_client):
  17. # http://shelly1-E89F6D85A466
  18. super().__init__(mqtt_client, "shellies/circulation_pump", "gui/common_sw_circulation_pump")
  19. #
  20. self.main_light_shelly.add_callback(devices.shelly.KEY_OUTPUT_0, None, self.circ_pump_actions)
  21. #
  22. self.gui_timer_view = devices.nodered_gui(mqtt_client, "gui/ffe_circ_pump_timer")
  23. self.gui_timer_view.set_feedback('-')
  24. #
  25. self.cvi = changed_value_indicator()
  26. self.ct = task.periodic(6, self.cyclic_task)
  27. self.pump_timer = None
  28. #
  29. self.ct.run()
  30. def circ_pump_actions(self, device, key, data):
  31. if self.cvi.changed_here(device.topic, key, data) and data is True:
  32. self.pump_timer = 10
  33. self.gui_timer_view.set_feedback(self.pump_timer)
  34. elif data is False:
  35. self.pump_timer = None
  36. self.gui_timer_view.set_feedback('-')
  37. def cyclic_task(self, rt):
  38. if self.pump_timer is not None:
  39. if self.pump_timer <= 0:
  40. self.pump_timer = None
  41. self.gui_timer_view.set_feedback('-')
  42. else:
  43. self.gui_timer_view.set_feedback(self.pump_timer)
  44. self.pump_timer -= self.ct.cycle_time / 60
  45. class common_heating(object):
  46. def __init__(self, mqtt_client):
  47. self.ffe_heating_sleep_madi = heating_function_brennenstuhl(
  48. mqtt_client, "zigbee_og_e/radiator/sleep_madi", 20, "gui/ffe_bo_sleep_madi", "gui/ffe_ts_sleep_madi", "gui/ffe_bl_sleep_madi")
  49. def all_off(self):
  50. pass # dummy method for compatibility reasons