From 5025af83347eab989904affe5e2263f88e75766c Mon Sep 17 00:00:00 2001 From: Josef Zweck Date: Tue, 25 Nov 2025 13:33:13 +0100 Subject: [PATCH] Add steam temperature number to lamarzocco (#157167) --- .../components/lamarzocco/icons.json | 3 + homeassistant/components/lamarzocco/number.py | 22 ++++++- .../components/lamarzocco/strings.json | 3 + .../lamarzocco/snapshots/test_number.ambr | 59 +++++++++++++++++++ tests/components/lamarzocco/test_number.py | 40 +++++++++++++ 5 files changed, 126 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/lamarzocco/icons.json b/homeassistant/components/lamarzocco/icons.json index a361c2e8caf7..f8270909baeb 100644 --- a/homeassistant/components/lamarzocco/icons.json +++ b/homeassistant/components/lamarzocco/icons.json @@ -45,6 +45,9 @@ }, "smart_standby_time": { "default": "mdi:timer" + }, + "steam_temp": { + "default": "mdi:kettle-steam" } }, "select": { diff --git a/homeassistant/components/lamarzocco/number.py b/homeassistant/components/lamarzocco/number.py index b235cc7c5f9a..831f48bd326a 100644 --- a/homeassistant/components/lamarzocco/number.py +++ b/homeassistant/components/lamarzocco/number.py @@ -7,7 +7,7 @@ from typing import Any, cast from pylamarzocco import LaMarzoccoMachine from pylamarzocco.const import ModelName, PreExtractionMode, WidgetType from pylamarzocco.exceptions import RequestNotSuccessful -from pylamarzocco.models import CoffeeBoiler, PreBrewing +from pylamarzocco.models import CoffeeBoiler, PreBrewing, SteamBoilerTemperature from homeassistant.components.number import ( NumberDeviceClass, @@ -59,6 +59,26 @@ ENTITIES: tuple[LaMarzoccoNumberEntityDescription, ...] = ( ).target_temperature ), ), + LaMarzoccoNumberEntityDescription( + key="steam_temp", + translation_key="steam_temp", + device_class=NumberDeviceClass.TEMPERATURE, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, + native_step=PRECISION_TENTHS, + native_min_value=20, + native_max_value=134, + set_value_fn=lambda machine, temp: machine.set_steam_target_temperature(temp), + native_value_fn=( + lambda machine: cast( + SteamBoilerTemperature, + machine.dashboard.config[WidgetType.CM_STEAM_BOILER_TEMPERATURE], + ).target_temperature + ), + supported_fn=( + lambda coordinator: coordinator.device.dashboard.model_name + in (ModelName.GS3_AV, ModelName.GS3_MP) + ), + ), LaMarzoccoNumberEntityDescription( key="smart_standby_time", translation_key="smart_standby_time", diff --git a/homeassistant/components/lamarzocco/strings.json b/homeassistant/components/lamarzocco/strings.json index 620e440eadd8..3ead6ef6b3e4 100644 --- a/homeassistant/components/lamarzocco/strings.json +++ b/homeassistant/components/lamarzocco/strings.json @@ -101,6 +101,9 @@ }, "smart_standby_time": { "name": "Smart standby time" + }, + "steam_temp": { + "name": "Steam target temperature" } }, "select": { diff --git a/tests/components/lamarzocco/snapshots/test_number.ambr b/tests/components/lamarzocco/snapshots/test_number.ambr index 5f4516954438..72de5e842855 100644 --- a/tests/components/lamarzocco/snapshots/test_number.ambr +++ b/tests/components/lamarzocco/snapshots/test_number.ambr @@ -294,3 +294,62 @@ 'unit_of_measurement': , }) # --- +# name: test_steam_temperature[GS3 AV] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'temperature', + 'friendly_name': 'GS012345 Steam target temperature', + 'max': 134, + 'min': 20, + 'mode': , + 'step': 0.1, + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'number.gs012345_steam_target_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '123.9', + }) +# --- +# name: test_steam_temperature[GS3 AV].1 + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'max': 134, + 'min': 20, + 'mode': , + 'step': 0.1, + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'number', + 'entity_category': None, + 'entity_id': 'number.gs012345_steam_target_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Steam target temperature', + 'platform': 'lamarzocco', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'steam_temp', + 'unique_id': 'GS012345_steam_temp', + 'unit_of_measurement': , + }) +# --- diff --git a/tests/components/lamarzocco/test_number.py b/tests/components/lamarzocco/test_number.py index b36f2944f4a4..111a306abd12 100644 --- a/tests/components/lamarzocco/test_number.py +++ b/tests/components/lamarzocco/test_number.py @@ -251,3 +251,43 @@ async def test_number_error( blocking=True, ) assert exc_info.value.translation_key == "number_exception" + + +@pytest.mark.parametrize("device_fixture", [ModelName.GS3_AV]) +async def test_steam_temperature( + hass: HomeAssistant, + mock_lamarzocco: MagicMock, + mock_config_entry: MockConfigEntry, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: + """Test steam temperature number.""" + + await async_init_integration(hass, mock_config_entry) + serial_number = mock_lamarzocco.serial_number + entity_id = f"number.{serial_number}_steam_target_temperature" + + state = hass.states.get(entity_id) + + assert state + assert state == snapshot + + entry = entity_registry.async_get(state.entity_id) + assert entry + assert entry.device_id + assert entry == snapshot + + # service call + await hass.services.async_call( + NUMBER_DOMAIN, + SERVICE_SET_VALUE, + { + ATTR_ENTITY_ID: entity_id, + ATTR_VALUE: 128.3, + }, + blocking=True, + ) + + mock_lamarzocco.set_steam_target_temperature.assert_called_once_with( + temperature=128.3, + )