From b4dbb0c5a6753b38a3b7a25b5f5c3da53e55f7ca Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 4 Dec 2019 02:39:11 +0100 Subject: [PATCH] Overridden status method in switch.wemo --- platypush/plugins/switch/wemo/__init__.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/platypush/plugins/switch/wemo/__init__.py b/platypush/plugins/switch/wemo/__init__.py index 18ea523bb..0286735f8 100644 --- a/platypush/plugins/switch/wemo/__init__.py +++ b/platypush/plugins/switch/wemo/__init__.py @@ -66,12 +66,8 @@ class SwitchWemoPlugin(SwitchPlugin): """ return [ - { - 'ip': addr, - 'name': name if name != addr else self.get_name(addr), - 'on': self.get_state(addr), - } - for (name, addr) in self._devices.items() + self.status(device).output + for device in self._devices.values() ] def _exec(self, device: str, action: SwitchAction, port: int = _default_port, value=None): @@ -109,6 +105,19 @@ class SwitchWemoPlugin(SwitchPlugin): dom = parseString(response.text) return dom.getElementsByTagName(state_name).item(0).firstChild.data + @action + def status(self, device=None, *args, **kwargs): + devices = {device: device} if device else self._devices.copy() + + return [ + { + 'ip': addr, + 'name': name if name != addr else self.get_name(addr).output, + 'on': self.get_state(addr).output, + } + for (name, addr) in self._devices.items() + ] + @action def on(self, device: str, **kwargs): """