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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. from devices.base import base
  5. import json
  6. class brennenstuhl_heatingvalve(base):
  7. """ Communication (MQTT)
  8. brennenstuhl_heatingvalve {
  9. | "away_mode": ["ON", "OFF"]
  10. | "battery": [0...100] %
  11. | "child_lock": ["LOCK", "UNLOCK"]
  12. | "current_heating_setpoint": [5...30] °C
  13. | "linkquality": [0...255] lqi
  14. | "local_temperature": [numeric] °C
  15. | "preset": ["manual", ...]
  16. | "system_mode": ["heat", ...]
  17. | "valve_detection": ["ON", "OFF"]
  18. | "window_detection": ["ON", "OFF"]
  19. | }
  20. +- set {
  21. "away_mode": ["ON", "OFF", "TOGGLE"]
  22. "child_lock": ["LOCK", "UNLOCK"]
  23. "current_heating_setpoint": [5...30] °C
  24. "preset": ["manual", ...]
  25. "system_mode": ["heat", ...]
  26. "valve_detection": ["ON", "OFF", "TOGGLE"]
  27. "window_detection": ["ON", "OFF", "TOGGLE"]
  28. }
  29. """
  30. KEY_LINKQUALITY = "linkquality"
  31. KEY_BATTERY = "battery"
  32. KEY_HEATING_SETPOINT = "current_heating_setpoint"
  33. KEY_TEMPERATURE = "local_temperature"
  34. #
  35. KEY_AWAY_MODE = "away_mode"
  36. KEY_CHILD_LOCK = "child_lock"
  37. KEY_PRESET = "preset"
  38. KEY_SYSTEM_MODE = "system_mode"
  39. KEY_VALVE_DETECTION = "valve_detection"
  40. KEY_WINDOW_DETECTION = "window_detection"
  41. #
  42. TX_TYPE = base.TX_DICT
  43. #
  44. RX_KEYS = [KEY_LINKQUALITY, KEY_BATTERY, KEY_HEATING_SETPOINT, KEY_TEMPERATURE]
  45. RX_IGNORE_KEYS = [KEY_AWAY_MODE, KEY_CHILD_LOCK, KEY_PRESET, KEY_SYSTEM_MODE, KEY_VALVE_DETECTION, KEY_WINDOW_DETECTION]
  46. def __init__(self, mqtt_client, topic):
  47. super().__init__(mqtt_client, topic)
  48. self.mqtt_client.send(self.topic + '/' + self.TX_TOPIC, json.dumps({self.KEY_WINDOW_DETECTION: "ON",
  49. self.KEY_CHILD_LOCK: "UNLOCK", self.KEY_VALVE_DETECTION: "ON", self.KEY_SYSTEM_MODE: "heat", self.KEY_PRESET: "manual"}))
  50. def __state_logging__(self, inst, key, data):
  51. if key in [self.KEY_HEATING_SETPOINT, self.KEY_CHILD_LOCK, self.KEY_WINDOW_DETECTION, self.KEY_VALVE_DETECTION]:
  52. self.logger.info("State change of '%s' to '%s'", key, repr(data))
  53. #
  54. # RX
  55. #
  56. @property
  57. def linkqulity(self):
  58. return self.get(self.KEY_LINKQUALITY)
  59. @property
  60. def heating_setpoint(self):
  61. return self.get(self.KEY_HEATING_SETPOINT)
  62. @property
  63. def temperature(self):
  64. return self.get(self.KEY_TEMPERATURE)
  65. #
  66. # TX
  67. #
  68. def set_heating_setpoint(self, setpoint):
  69. self.send_command(self.KEY_HEATING_SETPOINT, setpoint)
  70. def set_heating_setpoint_mcb(self, device, key, data):
  71. self.set_heating_setpoint(data)