Added method to get WeMo available devices

This commit is contained in:
Fabio Manganiello 2018-05-08 09:14:02 +02:00
parent bd761d420e
commit 36c9437172

View file

@ -20,6 +20,20 @@ class SwitchWemoPlugin(SwitchPlugin):
self.env.discover(seconds=self.discovery_seconds)
self.devices = self.env.devices
def get_devices(self):
self.refresh_devices()
return Response(
output = { 'devices': {
name: {
'host': dev.host,
'state': dev.get_state(),
'model': dev.model,
'serialnumber': dev.serialnumber,
}
for (name, dev) in self.devices.items()
} }
)
def _exec(self, method, device, *args, **kwargs):
if device not in self.devices:
self.refresh_devices()