From cceee05c1558828fa8bd6dd100f7e2d23a91b074 Mon Sep 17 00:00:00 2001 From: Josef Zweck Date: Sun, 5 Oct 2025 13:04:28 +0200 Subject: [PATCH] Fix lamarzocco brewing start time sensor availability (#153732) --- homeassistant/components/lamarzocco/sensor.py | 11 +++++++++-- .../components/lamarzocco/snapshots/test_sensor.ambr | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/lamarzocco/sensor.py b/homeassistant/components/lamarzocco/sensor.py index 1f4983a03a8..2e36db85fc4 100644 --- a/homeassistant/components/lamarzocco/sensor.py +++ b/homeassistant/components/lamarzocco/sensor.py @@ -5,7 +5,7 @@ from dataclasses import dataclass from datetime import datetime from typing import cast -from pylamarzocco.const import BackFlushStatus, ModelName, WidgetType +from pylamarzocco.const import BackFlushStatus, MachineState, ModelName, WidgetType from pylamarzocco.models import ( BackFlush, BaseWidgetOutput, @@ -97,7 +97,14 @@ ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = ( ).brewing_start_time ), entity_category=EntityCategory.DIAGNOSTIC, - available_fn=(lambda coordinator: not coordinator.websocket_terminated), + available_fn=( + lambda coordinator: not coordinator.websocket_terminated + and cast( + MachineStatus, + coordinator.device.dashboard.config[WidgetType.CM_MACHINE_STATUS], + ).status + is MachineState.BREWING + ), ), LaMarzoccoSensorEntityDescription( key="steam_boiler_ready_time", diff --git a/tests/components/lamarzocco/snapshots/test_sensor.ambr b/tests/components/lamarzocco/snapshots/test_sensor.ambr index 3dd1ff9b665..1ded7231287 100644 --- a/tests/components/lamarzocco/snapshots/test_sensor.ambr +++ b/tests/components/lamarzocco/snapshots/test_sensor.ambr @@ -45,7 +45,7 @@ 'last_changed': , 'last_reported': , 'last_updated': , - 'state': '2025-05-07T18:04:20+00:00', + 'state': 'unavailable', }) # --- # name: test_sensors[sensor.gs012345_coffee_boiler_ready_time-entry]