MQTT Home Emulation
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.

__init__.py 1.4KB

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