Rename current_consumption to power

- Note: This is a breaking change.
- Fix: Rename `current_consumption` to `power` in energy modules, to deconflict and clarify.
- Fix: Report `0` instead of `None` for current when current is zero.
- Fix: Report `0` instead of `None` for voltage when voltage is zero (not that this was possible to see).
This commit is contained in:
Ryan Nitcher
2024-12-06 20:48:16 -07:00
parent cb89342be1
commit 1c250913b6
8 changed files with 22 additions and 21 deletions

View File

@@ -195,10 +195,10 @@ class StripEmeter(IotModule, Energy):
return {}
@property
def current_consumption(self) -> float | None:
def power(self) -> float | None:
"""Get the current power consumption in watts."""
return sum(
v if (v := plug.modules[Module.Energy].current_consumption) else 0.0
v if (v := plug.modules[Module.Energy].power) else 0.0
for plug in self._device.children
)

View File

@@ -51,8 +51,8 @@ class Emeter(Usage, EnergyInterface):
return data.get(current_month, 0.0)
@property
def current_consumption(self) -> float | None:
"""Get the current power consumption in Watt."""
def power(self) -> float | None:
"""Get the current power draw in Watts."""
return self.status.power
@property