Skip to content

Commit ec9fb98

Browse files
authored
Add current humidity to Airobot climate entity (home-assistant#157209)
1 parent 30451e3 commit ec9fb98

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

homeassistant/components/airobot/climate.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,19 @@ def _settings(self) -> ThermostatSettings:
7575

7676
@property
7777
def current_temperature(self) -> float | None:
78-
"""Return the current temperature."""
78+
"""Return the current temperature.
79+
80+
If floor temperature is available, thermostat is set up for floor heating.
81+
"""
82+
if self._status.temp_floor is not None:
83+
return self._status.temp_floor
7984
return self._status.temp_air
8085

86+
@property
87+
def current_humidity(self) -> float | None:
88+
"""Return the current humidity."""
89+
return self._status.hum_air
90+
8191
@property
8292
def target_temperature(self) -> float | None:
8393
"""Return the target temperature."""
@@ -126,6 +136,13 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
126136

127137
await self.coordinator.async_request_refresh()
128138

139+
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
140+
"""Set HVAC mode.
141+
142+
This thermostat only supports HEAT mode. The climate platform validates
143+
that only supported modes are passed, so this method is a no-op.
144+
"""
145+
129146
async def async_set_preset_mode(self, preset_mode: str) -> None:
130147
"""Set new preset mode."""
131148
try:

homeassistant/components/airobot/quality_scale.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ rules:
5959
exception-translations: done
6060
icon-translations: todo
6161
reconfiguration-flow: todo
62-
repair-issues: todo
62+
repair-issues:
63+
status: exempt
64+
comment: This integration doesn't have any cases where raising an issue is needed.
6365
stale-devices:
6466
status: exempt
6567
comment: Single device integration, no stale device handling needed.

tests/components/airobot/snapshots/test_climate.ambr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
# name: test_climate_entities[climate.test_thermostat-state]
4949
StateSnapshot({
5050
'attributes': ReadOnlyDict({
51+
'current_humidity': 45.0,
5152
'current_temperature': 22.0,
5253
'friendly_name': 'Test Thermostat',
5354
'hvac_action': <HVACAction.IDLE: 'idle'>,

tests/components/airobot/test_climate.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,32 @@ async def test_climate_unavailable_on_update_failure(
219219
state = hass.states.get("climate.test_thermostat")
220220
assert state
221221
assert state.state == "unavailable"
222+
223+
224+
@pytest.mark.parametrize(
225+
("temp_floor", "temp_air", "expected_temp"),
226+
[
227+
(25.0, 22.0, 25.0), # Floor sensor available - should use floor temp
228+
(None, 22.0, 22.0), # Floor sensor not available - should use air temp
229+
],
230+
)
231+
async def test_climate_current_temperature(
232+
hass: HomeAssistant,
233+
mock_airobot_client: AsyncMock,
234+
mock_status: ThermostatStatus,
235+
mock_config_entry: MockConfigEntry,
236+
temp_floor: float | None,
237+
temp_air: float,
238+
expected_temp: float,
239+
) -> None:
240+
"""Test current temperature prioritizes floor sensor when available."""
241+
mock_status.temp_floor = temp_floor
242+
mock_status.temp_air = temp_air
243+
244+
mock_config_entry.add_to_hass(hass)
245+
await hass.config_entries.async_setup(mock_config_entry.entry_id)
246+
await hass.async_block_till_done()
247+
248+
state = hass.states.get("climate.test_thermostat")
249+
assert state
250+
assert state.attributes.get("current_temperature") == expected_temp

0 commit comments

Comments
 (0)