FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix energy module calling get_current_power by sdb9696 · Pull Request #798 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 7 additions & 5 deletions kasa/smart/modules/energymodule.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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,
Comment thread
rytilahti marked this conversation as resolved.
}
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

Back | FazBrowse Home | New Git URL