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,15 +320,13 @@ 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
sysinfo = await self._send_tplink_command("info") if len(self.addr) == 2:
out_cmd["context"] = { sysinfo = await self._send_tplink_command("info")
'child_ids' : dev_id = sysinfo["system"]["get_sysinfo"]["deviceId"]
[ out_cmd["context"] = {
sysinfo["system"]["get_sysinfo"]["deviceId"] 'child_ids': [f"{dev_id}{int(self.addr[1]):02}"]
+ '%02d'%int(self.addr[1]) }
]
}
elif command == "info": elif command == "info":
out_cmd = {'system': {'get_sysinfo': {}}} out_cmd = {'system': {'get_sysinfo': {}}}
else: else:
@ -388,11 +386,12 @@ 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:
self.state = "error" self.state = "error"
msg = f"Error Refeshing Device Status: {self.name}" msg = f"Error Refeshing Device Status: {self.name}"