Fix energy module calling get_current_power (#798)

This commit is contained in:
Steven B 2024-02-28 17:57:02 +00:00 committed by GitHub
parent 24344b71f5
commit 0306e05fb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,12 +43,12 @@ class EnergyModule(SmartModule):
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):
@ -58,7 +58,9 @@ class EnergyModule(SmartModule):
@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):