from devices.brennenstuhl import vlv as brennenstuhl_heatingvalve from devices.silvercrest import sw as silvercrest_powerplug from devices.silvercrest import sw_br_ct as livarno_sw_br_ct from devices.silvercrest import motion_sensor as silvercrest_motion_sensor from devices.my import powerplug as my_powerplug from devices.shelly import shelly_sw1 from devices.tradfri import sw as tradfri_sw from devices.tradfri import sw_br as tradfri_sw_br from devices.tradfri import sw_br_ct as tradfri_sw_br_ct from devices.tradfri import button as tradfri_button audio_status = None remote = None my_ambient = None class group(object): def __init__(self, *args): self.device_group = args self.topic = self.device_group[0].topic # self.user_cmds = {} for key in self.device_group[0].user_cmds: self.user_cmds[key] = getattr(self, self.device_group[0].user_cmds[key].__name__) def power_on_action(self, *args, **kwargs): for gm in self.device_group: gm.power_on_action(*args, **kwargs) def __getattribute__(self, name): def group_execution(*args, **kwargs): for member in self.device_group[:]: m = getattr(member, name) m(*args, **kwargs) try: rv = super().__getattribute__(name) except AttributeError: if callable(getattr(self.device_group[0], name)): return group_execution else: return getattr(self.device_group[0], name) else: return rv