MQTT Home Emulation
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from devices.brennenstuhl import vlv as brennenstuhl_heatingvalve
  2. from devices.silvercrest import sw as silvercrest_powerplug
  3. from devices.silvercrest import sw_br_ct as livarno_sw_br_ct
  4. from devices.silvercrest import motion_sensor as silvercrest_motion_sensor
  5. from devices.my import powerplug as my_powerplug
  6. from devices.shelly import shelly_sw1
  7. from devices.tradfri import sw as tradfri_sw
  8. from devices.tradfri import sw_br as tradfri_sw_br
  9. from devices.tradfri import sw_br_ct as tradfri_sw_br_ct
  10. from devices.tradfri import button as tradfri_button
  11. audio_status = None
  12. remote = None
  13. my_ambient = None
  14. class group(object):
  15. def __init__(self, *args):
  16. self.device_group = args
  17. self.topic = self.device_group[0].topic
  18. #
  19. self.user_cmds = {}
  20. for key in self.device_group[0].user_cmds:
  21. self.user_cmds[key] = getattr(self, self.device_group[0].user_cmds[key].__name__)
  22. def power_on_action(self, *args, **kwargs):
  23. for gm in self.device_group:
  24. gm.power_on_action(*args, **kwargs)
  25. def __getattribute__(self, name):
  26. def group_execution(*args, **kwargs):
  27. for member in self.device_group[:]:
  28. m = getattr(member, name)
  29. m(*args, **kwargs)
  30. try:
  31. rv = super().__getattribute__(name)
  32. except AttributeError:
  33. if callable(getattr(self.device_group[0], name)):
  34. return group_execution
  35. else:
  36. return getattr(self.device_group[0], name)
  37. else:
  38. return rv