FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix thermostat idle reporting on low battery by rytilahti · Pull Request #1598 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 4 additions & 2 deletions kasa/smart/modules/temperaturecontrol.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ def mode(self) -> ThermostatState:

states = self.states

# Discard known non-mode states
states.discard("low_battery")

# If the states is empty, the device is idling
if not states:
return ThermostatState.Idle

# Discard known extra states, and report on unknown extra states
states.discard("low_battery")
# Report on unknown extra states
if len(states) > 1:
_LOGGER.warning("Got multiple states: %s", states)

Expand Down
10 changes: 10 additions & 0 deletions tests/smart/modules/test_temperaturecontrol.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,13 @@ async def test_thermostat_heating_with_low_battery(dev):
temp_module: TemperatureControl = dev.modules["TemperatureControl"]
temp_module.data["trv_states"] = ["low_battery", "heating"]
assert temp_module.mode is ThermostatState.Heating


@thermostats_smart
async def test_thermostat_idle_with_low_battery(dev, caplog):
"""Test that mode is reported correctly with extra states."""
temp_module: TemperatureControl = dev.modules["TemperatureControl"]
temp_module.data["trv_states"] = ["low_battery"]
with caplog.at_level(logging.WARNING):
assert temp_module.mode is ThermostatState.Idle
assert not caplog.records
Loading

Back | FazBrowse Home | New Git URL