Skip to content

Commit f8f7d9f

Browse files
gh #192 updated the co pilot review suggestions
1 parent aea0575 commit f8f7d9f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

framework/core/powerModules/tapoControl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def powerOn(self):
158158
else:
159159
self._performCommand("on")
160160
self._get_state()
161-
if self._is_on == False:
161+
if not self._is_on:
162162
self._log.error(" Power On Failed")
163163
return self._is_on
164164

@@ -172,7 +172,7 @@ def _get_state(self):
172172
# == Smart Plug 1 (P304M) ==
173173
# == Primary features ==
174174
# State(state): True
175-
if result.find('Children') > 1: # smart extension plug with multiple outlets
175+
if 'Children' in result: # smart extension plug with multiple outlets
176176
all_states = re.findall(r"^\s*State\s*\(state\)\s*:\s*(True|False)\s*$",
177177
result, flags=re.IGNORECASE | re.MULTILINE)
178178
self._is_on = all_states[int(self._outlet)] == 'True'
@@ -246,7 +246,7 @@ def _discover_device(self):
246246
self._device_type = "UNKNOWN"
247247
elif result.get("get_child_device_list", {}).get('child_device_list', []):
248248
child_devices = result.get("get_child_device_list", {}).get('child_device_list', [])
249-
if len(child_devices) >= int(self._outlet) + 1:
249+
if len(child_devices) > int(self._outlet):
250250
self._device_type = child_devices[int(self._outlet)].get("type", "UNKNOWN")
251251
elif result.get('get_device_info'):
252252
self._device_type = result.get("get_device_info").get("type", "UNKNOWN")
@@ -292,4 +292,4 @@ def getPowerLevel(self):
292292
if watt is not None:
293293
return watt
294294

295-
raise KeyError("The dictionary returned by the Tapo device does not contain a valid 'power_mw' value.")
295+
raise KeyError("The dictionary returned by the Tapo device does not contain a valid 'current_power' value.")

0 commit comments

Comments
 (0)