Skip to content

Commit

Permalink
Fix energy module calling get_current_power (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdb9696 committed Feb 28, 2024
1 parent 24344b7 commit 0306e05
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions kasa/smart/modules/energymodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def __init__(self, device: "SmartDevice", module: str):

def query(self) -> Dict:
"""Query to execute during the update cycle."""
return {
req = {
"get_energy_usage": None,
# The current_power in get_energy_usage is more precise (mw vs. w),
# making this rather useless, but maybe there are version differences?
"get_current_power": None,
}
if self.supported_version > 1:
req["get_current_power"] = None
return req

@property
def current_power(self):
Expand All @@ -58,7 +58,9 @@ def current_power(self):
@property
def energy(self):
"""Return get_energy_usage results."""
return self.data["get_energy_usage"]
if en := self.data.get("get_energy_usage"):
return en
return self.data

@property
def emeter_realtime(self):
Expand Down

0 comments on commit 0306e05

Please sign in to comment.