From 36c9437172e71df591f1976e434551c7448d3804 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 8 May 2018 09:14:02 +0200 Subject: [PATCH] Added method to get WeMo available devices --- platypush/plugins/switch/wemo/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/platypush/plugins/switch/wemo/__init__.py b/platypush/plugins/switch/wemo/__init__.py index a4109f95..8608630f 100644 --- a/platypush/plugins/switch/wemo/__init__.py +++ b/platypush/plugins/switch/wemo/__init__.py @@ -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()