Fix incomfort invalid setpoint if override is reported as 0.0 (#125694)

This commit is contained in:
Jan Bouwhuis 2024-09-10 22:04:53 +02:00 committed by GitHub
parent 688da5389c
commit 5c2d7b8fa5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 85 additions and 4 deletions

View File

@ -90,8 +90,10 @@ class InComfortClimate(IncomfortEntity, ClimateEntity):
As we set the override, we report back the override. The actual set point is
is returned at a later time.
Some older thermostats return 0.0 as override, in that case we fallback to
the actual setpoint.
"""
return self._room.override
return self._room.override or self._room.setpoint
async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set a new target temperature for this zone."""

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_setup_platform[climate.thermostat_1-entry]
# name: test_setup_platform[legacy_thermostat][climate.thermostat_1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -38,7 +38,73 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_platform[climate.thermostat_1-state]
# name: test_setup_platform[legacy_thermostat][climate.thermostat_1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 21.4,
'friendly_name': 'Thermostat 1',
'hvac_action': <HVACAction.IDLE: 'idle'>,
'hvac_modes': list([
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30.0,
'min_temp': 5.0,
'status': dict({
'override': 0.0,
'room_temp': 21.42,
'setpoint': 18.0,
}),
'supported_features': <ClimateEntityFeature: 1>,
'temperature': 18.0,
}),
'context': <ANY>,
'entity_id': 'climate.thermostat_1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'heat',
})
# ---
# name: test_setup_platform[new_thermostat][climate.thermostat_1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.HEAT: 'heat'>,
]),
'max_temp': 30.0,
'min_temp': 5.0,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.thermostat_1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': None,
'platform': 'incomfort',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 1>,
'translation_key': None,
'unique_id': 'c0ffeec0ffee_1',
'unit_of_measurement': None,
})
# ---
# name: test_setup_platform[new_thermostat][climate.thermostat_1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 21.4,

View File

@ -2,6 +2,7 @@
from unittest.mock import MagicMock, patch
import pytest
from syrupy import SnapshotAssertion
from homeassistant.config_entries import ConfigEntry
@ -13,6 +14,14 @@ from tests.common import snapshot_platform
@patch("homeassistant.components.incomfort.PLATFORMS", [Platform.CLIMATE])
@pytest.mark.parametrize(
"mock_room_status",
[
{"room_temp": 21.42, "setpoint": 18.0, "override": 18.0},
{"room_temp": 21.42, "setpoint": 18.0, "override": 0.0},
],
ids=["new_thermostat", "legacy_thermostat"],
)
async def test_setup_platform(
hass: HomeAssistant,
mock_incomfort: MagicMock,
@ -20,6 +29,10 @@ async def test_setup_platform(
snapshot: SnapshotAssertion,
mock_config_entry: ConfigEntry,
) -> None:
"""Test the incomfort entities are set up correctly."""
"""Test the incomfort entities are set up correctly.
Legacy thermostats report 0.0 as override if no override is set,
but new thermostat sync the override with the actual setpoint instead.
"""
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)