Return only the first element, not in an array, if status() was called with only one device

This commit is contained in:
Fabio Manganiello 2019-12-04 09:29:29 +01:00
parent 25894d3c00
commit 10ab1751d8

View file

@ -109,7 +109,7 @@ class SwitchWemoPlugin(SwitchPlugin):
def status(self, device=None, *args, **kwargs): def status(self, device=None, *args, **kwargs):
devices = {device: device} if device else self._devices.copy() devices = {device: device} if device else self._devices.copy()
return [ ret = [
{ {
'id': addr, 'id': addr,
'ip': addr, 'ip': addr,
@ -119,6 +119,8 @@ class SwitchWemoPlugin(SwitchPlugin):
for (name, addr) in self._devices.items() for (name, addr) in self._devices.items()
] ]
return ret[0] if device else ret
@action @action
def on(self, device: str, **kwargs): def on(self, device: str, **kwargs):
""" """