mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-14 11:28:02 +00:00
Pick commit a044063526
from #1054
Instead of trying to use the first state when multiple are reported,
iterate over the known states and pick the first matching.
This will fix an issue where the device reports extra states (like
`low_battery`) while having a known mode active.
Related to home-assistant/core#121335
This commit is contained in:
@@ -94,7 +94,7 @@ async def test_temperature_offset(dev):
|
||||
),
|
||||
pytest.param(
|
||||
ThermostatState.Heating,
|
||||
[ThermostatState.Heating],
|
||||
["heating"],
|
||||
False,
|
||||
id="heating is heating",
|
||||
),
|
||||
@@ -135,3 +135,11 @@ async def test_thermostat_mode_warnings(dev, mode, states, msg, caplog):
|
||||
temp_module.data["trv_states"] = states
|
||||
assert temp_module.mode is mode
|
||||
assert msg in caplog.text
|
||||
|
||||
|
||||
@thermostats_smart
|
||||
async def test_thermostat_heating_with_low_battery(dev):
|
||||
"""Test that mode is reported correctly with extra states."""
|
||||
temp_module: TemperatureControl = dev.modules["TemperatureControl"]
|
||||
temp_module.data["trv_states"] = ["low_battery", "heating"]
|
||||
assert temp_module.mode is ThermostatState.Heating
|
||||
|
Reference in New Issue
Block a user