Skip to content

Commit 5025af8

Browse files
authored
Add steam temperature number to lamarzocco (home-assistant#157167)
1 parent ec9fb98 commit 5025af8

File tree

5 files changed

+126
-1
lines changed

5 files changed

+126
-1
lines changed

homeassistant/components/lamarzocco/icons.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
},
4646
"smart_standby_time": {
4747
"default": "mdi:timer"
48+
},
49+
"steam_temp": {
50+
"default": "mdi:kettle-steam"
4851
}
4952
},
5053
"select": {

homeassistant/components/lamarzocco/number.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pylamarzocco import LaMarzoccoMachine
88
from pylamarzocco.const import ModelName, PreExtractionMode, WidgetType
99
from pylamarzocco.exceptions import RequestNotSuccessful
10-
from pylamarzocco.models import CoffeeBoiler, PreBrewing
10+
from pylamarzocco.models import CoffeeBoiler, PreBrewing, SteamBoilerTemperature
1111

1212
from homeassistant.components.number import (
1313
NumberDeviceClass,
@@ -59,6 +59,26 @@ class LaMarzoccoNumberEntityDescription(
5959
).target_temperature
6060
),
6161
),
62+
LaMarzoccoNumberEntityDescription(
63+
key="steam_temp",
64+
translation_key="steam_temp",
65+
device_class=NumberDeviceClass.TEMPERATURE,
66+
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
67+
native_step=PRECISION_TENTHS,
68+
native_min_value=20,
69+
native_max_value=134,
70+
set_value_fn=lambda machine, temp: machine.set_steam_target_temperature(temp),
71+
native_value_fn=(
72+
lambda machine: cast(
73+
SteamBoilerTemperature,
74+
machine.dashboard.config[WidgetType.CM_STEAM_BOILER_TEMPERATURE],
75+
).target_temperature
76+
),
77+
supported_fn=(
78+
lambda coordinator: coordinator.device.dashboard.model_name
79+
in (ModelName.GS3_AV, ModelName.GS3_MP)
80+
),
81+
),
6282
LaMarzoccoNumberEntityDescription(
6383
key="smart_standby_time",
6484
translation_key="smart_standby_time",

homeassistant/components/lamarzocco/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@
101101
},
102102
"smart_standby_time": {
103103
"name": "Smart standby time"
104+
},
105+
"steam_temp": {
106+
"name": "Steam target temperature"
104107
}
105108
},
106109
"select": {

tests/components/lamarzocco/snapshots/test_number.ambr

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,62 @@
294294
'unit_of_measurement': <UnitOfTime.SECONDS: 's'>,
295295
})
296296
# ---
297+
# name: test_steam_temperature[GS3 AV]
298+
StateSnapshot({
299+
'attributes': ReadOnlyDict({
300+
'device_class': 'temperature',
301+
'friendly_name': 'GS012345 Steam target temperature',
302+
'max': 134,
303+
'min': 20,
304+
'mode': <NumberMode.AUTO: 'auto'>,
305+
'step': 0.1,
306+
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
307+
}),
308+
'context': <ANY>,
309+
'entity_id': 'number.gs012345_steam_target_temperature',
310+
'last_changed': <ANY>,
311+
'last_reported': <ANY>,
312+
'last_updated': <ANY>,
313+
'state': '123.9',
314+
})
315+
# ---
316+
# name: test_steam_temperature[GS3 AV].1
317+
EntityRegistryEntrySnapshot({
318+
'aliases': set({
319+
}),
320+
'area_id': None,
321+
'capabilities': dict({
322+
'max': 134,
323+
'min': 20,
324+
'mode': <NumberMode.AUTO: 'auto'>,
325+
'step': 0.1,
326+
}),
327+
'config_entry_id': <ANY>,
328+
'config_subentry_id': <ANY>,
329+
'device_class': None,
330+
'device_id': <ANY>,
331+
'disabled_by': None,
332+
'domain': 'number',
333+
'entity_category': None,
334+
'entity_id': 'number.gs012345_steam_target_temperature',
335+
'has_entity_name': True,
336+
'hidden_by': None,
337+
'icon': None,
338+
'id': <ANY>,
339+
'labels': set({
340+
}),
341+
'name': None,
342+
'options': dict({
343+
}),
344+
'original_device_class': <NumberDeviceClass.TEMPERATURE: 'temperature'>,
345+
'original_icon': None,
346+
'original_name': 'Steam target temperature',
347+
'platform': 'lamarzocco',
348+
'previous_unique_id': None,
349+
'suggested_object_id': None,
350+
'supported_features': 0,
351+
'translation_key': 'steam_temp',
352+
'unique_id': 'GS012345_steam_temp',
353+
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
354+
})
355+
# ---

tests/components/lamarzocco/test_number.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,43 @@ async def test_number_error(
251251
blocking=True,
252252
)
253253
assert exc_info.value.translation_key == "number_exception"
254+
255+
256+
@pytest.mark.parametrize("device_fixture", [ModelName.GS3_AV])
257+
async def test_steam_temperature(
258+
hass: HomeAssistant,
259+
mock_lamarzocco: MagicMock,
260+
mock_config_entry: MockConfigEntry,
261+
entity_registry: er.EntityRegistry,
262+
snapshot: SnapshotAssertion,
263+
) -> None:
264+
"""Test steam temperature number."""
265+
266+
await async_init_integration(hass, mock_config_entry)
267+
serial_number = mock_lamarzocco.serial_number
268+
entity_id = f"number.{serial_number}_steam_target_temperature"
269+
270+
state = hass.states.get(entity_id)
271+
272+
assert state
273+
assert state == snapshot
274+
275+
entry = entity_registry.async_get(state.entity_id)
276+
assert entry
277+
assert entry.device_id
278+
assert entry == snapshot
279+
280+
# service call
281+
await hass.services.async_call(
282+
NUMBER_DOMAIN,
283+
SERVICE_SET_VALUE,
284+
{
285+
ATTR_ENTITY_ID: entity_id,
286+
ATTR_VALUE: 128.3,
287+
},
288+
blocking=True,
289+
)
290+
291+
mock_lamarzocco.set_steam_target_temperature.assert_called_once_with(
292+
temperature=128.3,
293+
)

0 commit comments

Comments
 (0)