diff --git a/homeassistant/components/lamarzocco/icons.json b/homeassistant/components/lamarzocco/icons.json index 2964f48ecbd..8ea764b4d18 100644 --- a/homeassistant/components/lamarzocco/icons.json +++ b/homeassistant/components/lamarzocco/icons.json @@ -76,6 +76,9 @@ "coffee_boiler_ready_time": { "default": "mdi:av-timer" }, + "last_cleaning_time": { + "default": "mdi:spray-bottle" + }, "steam_boiler_ready_time": { "default": "mdi:av-timer" } diff --git a/homeassistant/components/lamarzocco/sensor.py b/homeassistant/components/lamarzocco/sensor.py index 17f11534483..9c1214835fa 100644 --- a/homeassistant/components/lamarzocco/sensor.py +++ b/homeassistant/components/lamarzocco/sensor.py @@ -7,6 +7,7 @@ from typing import cast from pylamarzocco.const import ModelName, WidgetType from pylamarzocco.models import ( + BackFlush, BaseWidgetOutput, CoffeeBoiler, SteamBoilerLevel, @@ -84,6 +85,17 @@ ENTITIES: tuple[LaMarzoccoSensorEntityDescription, ...] = ( in (ModelName.GS3_AV, ModelName.GS3_MP, ModelName.LINEA_MINI) ), ), + LaMarzoccoSensorEntityDescription( + key="last_cleaning_time", + translation_key="last_cleaning_time", + device_class=SensorDeviceClass.TIMESTAMP, + value_fn=( + lambda config: cast( + BackFlush, config[WidgetType.CM_BACK_FLUSH] + ).last_cleaning_start_time + ), + entity_category=EntityCategory.DIAGNOSTIC, + ), ) diff --git a/homeassistant/components/lamarzocco/strings.json b/homeassistant/components/lamarzocco/strings.json index 7a77b8ad72c..9b153b5707e 100644 --- a/homeassistant/components/lamarzocco/strings.json +++ b/homeassistant/components/lamarzocco/strings.json @@ -146,6 +146,9 @@ }, "steam_boiler_ready_time": { "name": "Steam boiler ready time" + }, + "last_cleaning_time": { + "name": "Last cleaning time" } }, "switch": { diff --git a/tests/components/lamarzocco/fixtures/config_gs3.json b/tests/components/lamarzocco/fixtures/config_gs3.json index 0c6c6c70b0a..8958bb90fc4 100644 --- a/tests/components/lamarzocco/fixtures/config_gs3.json +++ b/tests/components/lamarzocco/fixtures/config_gs3.json @@ -299,7 +299,7 @@ "code": "CMBackFlush", "index": 1, "output": { - "lastCleaningStartTime": null, + "lastCleaningStartTime": 1743236747166, "status": "Off" }, "tutorialUrl": "http://lamarzocco.com/it/en/app/support/cleaning-and-backflush/#gs3-av" diff --git a/tests/components/lamarzocco/snapshots/test_diagnostics.ambr b/tests/components/lamarzocco/snapshots/test_diagnostics.ambr index 6026ea0d7f4..31292862824 100644 --- a/tests/components/lamarzocco/snapshots/test_diagnostics.ambr +++ b/tests/components/lamarzocco/snapshots/test_diagnostics.ambr @@ -7,7 +7,7 @@ 'coffee_station': None, 'config': dict({ 'CMBackFlush': dict({ - 'last_cleaning_start_time': None, + 'last_cleaning_start_time': '2025-03-29T08:25:47.166000+00:00', 'status': 'Off', }), 'CMCoffeeBoiler': dict({ @@ -571,7 +571,7 @@ 'code': 'CMBackFlush', 'index': 1, 'output': dict({ - 'last_cleaning_start_time': None, + 'last_cleaning_start_time': '2025-03-29T08:25:47.166000+00:00', 'status': 'Off', }), }), diff --git a/tests/components/lamarzocco/snapshots/test_sensor.ambr b/tests/components/lamarzocco/snapshots/test_sensor.ambr index 311e7416b1c..f23771b77b4 100644 --- a/tests/components/lamarzocco/snapshots/test_sensor.ambr +++ b/tests/components/lamarzocco/snapshots/test_sensor.ambr @@ -47,6 +47,54 @@ 'state': 'unknown', }) # --- +# name: test_sensors[sensor.gs012345_last_cleaning_time-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.gs012345_last_cleaning_time', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Last cleaning time', + 'platform': 'lamarzocco', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'last_cleaning_time', + 'unique_id': 'GS012345_last_cleaning_time', + 'unit_of_measurement': None, + }) +# --- +# name: test_sensors[sensor.gs012345_last_cleaning_time-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'timestamp', + 'friendly_name': 'GS012345 Last cleaning time', + }), + 'context': , + 'entity_id': 'sensor.gs012345_last_cleaning_time', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2025-03-29T08:25:47+00:00', + }) +# --- # name: test_sensors[sensor.gs012345_steam_boiler_ready_time-entry] EntityRegistryEntrySnapshot({ 'aliases': set({