Add steam temperature number to lamarzocco (#157167)

This commit is contained in:
Josef Zweck
2025-11-25 13:33:13 +01:00
committed by GitHub
parent ec9fb9837a
commit 5025af8334
5 changed files with 126 additions and 1 deletions
@@ -45,6 +45,9 @@
},
"smart_standby_time": {
"default": "mdi:timer"
},
"steam_temp": {
"default": "mdi:kettle-steam"
}
},
"select": {
+21 -1
View File
@@ -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",
@@ -101,6 +101,9 @@
},
"smart_standby_time": {
"name": "Smart standby time"
},
"steam_temp": {
"name": "Steam target temperature"
}
},
"select": {
@@ -294,3 +294,62 @@
'unit_of_measurement': <UnitOfTime.SECONDS: 's'>,
})
# ---
# name: test_steam_temperature[GS3 AV]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'GS012345 Steam target temperature',
'max': 134,
'min': 20,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 0.1,
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'number.gs012345_steam_target_temperature',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '123.9',
})
# ---
# name: test_steam_temperature[GS3 AV].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 134,
'min': 20,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 0.1,
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'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': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <NumberDeviceClass.TEMPERATURE: 'temperature'>,
'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': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
@@ -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,
)