mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-01-09 06:17:08 +00:00
Fix energy module calling get_current_power (#798)
This commit is contained in:
parent
24344b71f5
commit
0306e05fb9
@ -43,12 +43,12 @@ class EnergyModule(SmartModule):
|
|||||||
|
|
||||||
def query(self) -> Dict:
|
def query(self) -> Dict:
|
||||||
"""Query to execute during the update cycle."""
|
"""Query to execute during the update cycle."""
|
||||||
return {
|
req = {
|
||||||
"get_energy_usage": None,
|
"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
|
@property
|
||||||
def current_power(self):
|
def current_power(self):
|
||||||
@ -58,7 +58,9 @@ class EnergyModule(SmartModule):
|
|||||||
@property
|
@property
|
||||||
def energy(self):
|
def energy(self):
|
||||||
"""Return get_energy_usage results."""
|
"""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
|
@property
|
||||||
def emeter_realtime(self):
|
def emeter_realtime(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user