power: fix whitespace issues

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-03-31 20:32:57 -04:00
parent 8724d5e9ed
commit aa3ffdbaaf
1 changed files with 12 additions and 13 deletions

View File

@ -320,14 +320,12 @@ class TPLinkSmartPlug(PowerDevice):
out_cmd = { out_cmd = {
'system': {'set_relay_state': {'state': int(command == "on")}} 'system': {'set_relay_state': {'state': int(command == "on")}}
} }
if len(self.addr) == 2: # TPLink device controls multiple devices # TPLink device controls multiple devices
if len(self.addr) == 2:
sysinfo = await self._send_tplink_command("info") sysinfo = await self._send_tplink_command("info")
dev_id = sysinfo["system"]["get_sysinfo"]["deviceId"]
out_cmd["context"] = { out_cmd["context"] = {
'child_ids' : 'child_ids': [f"{dev_id}{int(self.addr[1]):02}"]
[
sysinfo["system"]["get_sysinfo"]["deviceId"]
+ '%02d'%int(self.addr[1])
]
} }
elif command == "info": elif command == "info":
out_cmd = {'system': {'get_sysinfo': {}}} out_cmd = {'system': {'get_sysinfo': {}}}
@ -388,9 +386,10 @@ class TPLinkSmartPlug(PowerDevice):
async def refresh_status(self): async def refresh_status(self):
try: try:
res = await self._send_tplink_command("info") res = await self._send_tplink_command("info")
if len(self.addr) == 2: # TPLink device controls multiple devices if len(self.addr) == 2:
state = res['system']['get_sysinfo']['children'][ # TPLink device controls multiple devices
int(self.addr[1])]['state'] children = res['system']['get_sysinfo']['children']
state = children[int(self.addr[1])]['state']
else: else:
state = res['system']['get_sysinfo']['relay_state'] state = res['system']['get_sysinfo']['relay_state']
except Exception: except Exception: