home_emulation/devices/__init__.py

43 lines
1.5 KiB
Python
Raw Normal View History

2023-10-29 15:10:52 +01:00
from devices.brennenstuhl import vlv as brennenstuhl_heatingvalve
2023-12-25 07:47:37 +01:00
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
2023-10-29 15:10:52 +01:00
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
2023-12-25 07:47:37 +01:00
from devices.tradfri import button as tradfri_button
2023-08-03 20:43:41 +02:00
2023-10-29 15:10:52 +01:00
audio_status = None
remote = None
2023-08-03 20:43:41 +02:00
2023-10-29 15:10:52 +01:00
class group(object):
def __init__(self, *args):
self.device_group = args
self.topic = self.device_group[0].topic
2023-10-31 18:25:19 +01:00
#
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__)
2023-10-29 15:10:52 +01:00
def power_on_action(self, *args, **kwargs):
for gm in self.device_group:
gm.power_on_action(*args, **kwargs)
2023-10-31 18:25:19 +01:00
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