From 8466dd4c2b012204147af03dd4f20128d03c5604 Mon Sep 17 00:00:00 2001 From: Blaine Cook Date: Tue, 3 Feb 2026 03:38:39 -0800 Subject: [PATCH] Add temperature sensor to Huum integration (#161405) Co-authored-by: Claude Opus 4.5 Co-authored-by: Joostlek --- homeassistant/components/huum/const.py | 8 ++- homeassistant/components/huum/sensor.py | 42 ++++++++++++++ .../huum/snapshots/test_sensor.ambr | 58 +++++++++++++++++++ tests/components/huum/test_sensor.py | 25 ++++++++ 4 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 homeassistant/components/huum/sensor.py create mode 100644 tests/components/huum/snapshots/test_sensor.ambr create mode 100644 tests/components/huum/test_sensor.py diff --git a/homeassistant/components/huum/const.py b/homeassistant/components/huum/const.py index 28609a7e920..610a6c220d1 100644 --- a/homeassistant/components/huum/const.py +++ b/homeassistant/components/huum/const.py @@ -4,7 +4,13 @@ from homeassistant.const import Platform DOMAIN = "huum" -PLATFORMS = [Platform.BINARY_SENSOR, Platform.CLIMATE, Platform.LIGHT, Platform.NUMBER] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.CLIMATE, + Platform.LIGHT, + Platform.NUMBER, + Platform.SENSOR, +] CONFIG_STEAMER = 1 CONFIG_LIGHT = 2 diff --git a/homeassistant/components/huum/sensor.py b/homeassistant/components/huum/sensor.py new file mode 100644 index 00000000000..9629fcfdf88 --- /dev/null +++ b/homeassistant/components/huum/sensor.py @@ -0,0 +1,42 @@ +"""Sensor platform for Huum sauna integration.""" + +from __future__ import annotations + +from homeassistant.components.sensor import ( + SensorDeviceClass, + SensorEntity, + SensorStateClass, +) +from homeassistant.const import UnitOfTemperature +from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback + +from .coordinator import HuumConfigEntry, HuumDataUpdateCoordinator +from .entity import HuumBaseEntity + + +async def async_setup_entry( + hass: HomeAssistant, + config_entry: HuumConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, +) -> None: + """Set up Huum sensors from a config entry.""" + async_add_entities([HuumTemperatureSensor(config_entry.runtime_data)]) + + +class HuumTemperatureSensor(HuumBaseEntity, SensorEntity): + """Representation of a Huum temperature sensor.""" + + _attr_device_class = SensorDeviceClass.TEMPERATURE + _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS + _attr_state_class = SensorStateClass.MEASUREMENT + + def __init__(self, coordinator: HuumDataUpdateCoordinator) -> None: + """Initialize the temperature sensor.""" + super().__init__(coordinator) + self._attr_unique_id = f"{coordinator.config_entry.entry_id}_temperature" + + @property + def native_value(self) -> int | None: + """Return the current temperature.""" + return self.coordinator.data.temperature diff --git a/tests/components/huum/snapshots/test_sensor.ambr b/tests/components/huum/snapshots/test_sensor.ambr new file mode 100644 index 00000000000..7545c2b0b0c --- /dev/null +++ b/tests/components/huum/snapshots/test_sensor.ambr @@ -0,0 +1,58 @@ +# serializer version: 1 +# name: test_sensor[sensor.huum_sauna_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.huum_sauna_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Temperature', + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Temperature', + 'platform': 'huum', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': 'AABBCC112233_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_sensor[sensor.huum_sauna_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'Huum sauna Temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.huum_sauna_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '30', + }) +# --- diff --git a/tests/components/huum/test_sensor.py b/tests/components/huum/test_sensor.py new file mode 100644 index 00000000000..1bf83dc0803 --- /dev/null +++ b/tests/components/huum/test_sensor.py @@ -0,0 +1,25 @@ +"""Tests for the Huum sensor entity.""" + +from unittest.mock import AsyncMock + +from syrupy.assertion import SnapshotAssertion + +from homeassistant.const import Platform +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er + +from . import setup_with_selected_platforms + +from tests.common import MockConfigEntry, snapshot_platform + + +async def test_sensor( + hass: HomeAssistant, + mock_huum: AsyncMock, + mock_config_entry: MockConfigEntry, + snapshot: SnapshotAssertion, + entity_registry: er.EntityRegistry, +) -> None: + """Test the temperature sensor.""" + await setup_with_selected_platforms(hass, mock_config_entry, [Platform.SENSOR]) + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)