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

@@ -133,9 +133,9 @@ async def test_erase_emeter_stats(dev):
@has_emeter_iot
async def test_current_consumption(dev):
async def test_power(dev):
emeter = dev.modules[Module.Energy]
x = emeter.current_consumption
x = emeter.power
assert isinstance(x, float)
assert x >= 0.0

View File

@@ -352,7 +352,7 @@ async def test_update_module_query_errors(
if mod.name == "Energy":
emod = cast(Energy, mod)
with pytest.raises(KasaException, match="Module update error"):
assert emod.current_consumption is not None
assert emod.power is not None
else:
assert mod.disabled is False
assert mod._error_count == 0
@@ -360,7 +360,7 @@ async def test_update_module_query_errors(
# Test one of the raise_if_update_error doesn't raise
if mod.name == "Energy":
emod = cast(Energy, mod)
assert emod.current_consumption is not None
assert emod.power is not None
async def test_get_modules():

View File

@@ -159,4 +159,4 @@ async def test_children_energy(dev: Device):
energy = plug.modules[Module.Energy]
assert "voltage" in energy._module_features
assert "current" in energy._module_features
assert "current_consumption" in energy._module_features
assert "power" in energy._module_features