diff --git a/homeassistant/components/ecovacs/icons.json b/homeassistant/components/ecovacs/icons.json index 7f2782d8a3391d..8300ce288bdbe8 100644 --- a/homeassistant/components/ecovacs/icons.json +++ b/homeassistant/components/ecovacs/icons.json @@ -89,6 +89,9 @@ } }, "sensor": { + "auto_empty": { + "default": "mdi:delete-empty" + }, "error": { "default": "mdi:alert-circle" }, diff --git a/homeassistant/components/ecovacs/sensor.py b/homeassistant/components/ecovacs/sensor.py index b368b92a579cef..cb2ef51a403513 100644 --- a/homeassistant/components/ecovacs/sensor.py +++ b/homeassistant/components/ecovacs/sensor.py @@ -17,6 +17,7 @@ NetworkInfoEvent, StatsEvent, TotalStatsEvent, + auto_empty, station, ) from sucks import VacBot @@ -158,6 +159,14 @@ def get_area_native_unit_of_measurement(device_type: DeviceType) -> str | None: device_class=SensorDeviceClass.ENUM, options=get_options(station.State), ), + EcovacsSensorEntityDescription[auto_empty.AutoEmptyEvent]( + capability_fn=lambda caps: caps.station.auto_empty if caps.station else None, + value_fn=lambda e: get_name_key(e.frequency) if e.frequency else None, + key="auto_empty", + translation_key="auto_empty", + device_class=SensorDeviceClass.ENUM, + options=get_options(auto_empty.Frequency), + ), ) diff --git a/homeassistant/components/ecovacs/strings.json b/homeassistant/components/ecovacs/strings.json index bb63057cee2335..2227cf36e631e8 100644 --- a/homeassistant/components/ecovacs/strings.json +++ b/homeassistant/components/ecovacs/strings.json @@ -149,6 +149,13 @@ } }, "sensor": { + "auto_empty": { + "name": "Auto-empty frequency", + "state": { + "auto": "Auto", + "smart": "Smart" + } + }, "error": { "name": "Error", "state_attributes": { diff --git a/tests/components/ecovacs/snapshots/test_sensor.ambr b/tests/components/ecovacs/snapshots/test_sensor.ambr index a3a891e6a87beb..c1505f28990267 100644 --- a/tests/components/ecovacs/snapshots/test_sensor.ambr +++ b/tests/components/ecovacs/snapshots/test_sensor.ambr @@ -1652,6 +1652,70 @@ 'state': 'Testnetwork', }) # --- +# name: test_sensors[qhe2o2][sensor.dusty_auto_empty_frequency:state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'enum', + 'friendly_name': 'Dusty Auto-empty frequency', + 'options': list([ + 'min_10', + 'min_15', + 'min_25', + 'auto', + 'smart', + ]), + }), + 'context': , + 'entity_id': 'sensor.dusty_auto_empty_frequency', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'auto', + }) +# --- +# name: test_sensors[qhe2o2][sensor.dusty_auto_empty_frequency:entity-registry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'options': list([ + 'min_10', + 'min_15', + 'min_25', + 'auto', + 'smart', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.dusty_auto_empty_frequency', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Auto-empty frequency', + 'platform': 'ecovacs', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'auto_empty', + 'unique_id': '8516fbb1-17f1-4194-0000001_auto_empty', + 'unit_of_measurement': None, + }) +# --- # name: test_sensors[yna5x1][sensor.ozmo_950_area_cleaned:entity-registry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/ecovacs/test_sensor.py b/tests/components/ecovacs/test_sensor.py index f7e8ccfe32e53c..77a630cc7e19bc 100644 --- a/tests/components/ecovacs/test_sensor.py +++ b/tests/components/ecovacs/test_sensor.py @@ -11,6 +11,7 @@ NetworkInfoEvent, StatsEvent, TotalStatsEvent, + auto_empty, station, ) import pytest @@ -47,6 +48,7 @@ async def notify_events(hass: HomeAssistant, event_bus: EventBus): event_bus.notify(LifeSpanEvent(LifeSpan.SIDE_BRUSH, 40, 20 * 60)) event_bus.notify(ErrorEvent(0, "NoError: Robot is operational")) event_bus.notify(station.StationEvent(station.State.EMPTYING_DUSTBIN)) + event_bus.notify(auto_empty.AutoEmptyEvent(True, auto_empty.Frequency.AUTO)) await block_till_done(hass, event_bus) @@ -102,6 +104,7 @@ async def notify_events(hass: HomeAssistant, event_bus: EventBus): "sensor.dusty_wi_fi_rssi", "sensor.dusty_wi_fi_ssid", "sensor.dusty_station_state", + "sensor.dusty_auto_empty_frequency", "sensor.dusty_main_brush_lifespan", "sensor.dusty_filter_lifespan", "sensor.dusty_round_mop_lifespan",