Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 092841c

Browse files
aronnebrivioedenhaus
andauthored
Add auto empty sensor to Ecovacs (home-assistant#155489)
Co-authored-by: Robert Resch <robert@resch.dev>
1 parent 70238a6 commit 092841c

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

‎homeassistant/components/ecovacs/icons.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
}
9090
},
9191
"sensor": {
92+
"auto_empty": {
93+
"default": "mdi:delete-empty"
94+
},
9295
"error": {
9396
"default": "mdi:alert-circle"
9497
},

‎homeassistant/components/ecovacs/sensor.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
NetworkInfoEvent,
1818
StatsEvent,
1919
TotalStatsEvent,
20+
auto_empty,
2021
station,
2122
)
2223
from sucks import VacBot
@@ -158,6 +159,14 @@ def get_area_native_unit_of_measurement(device_type: DeviceType) -> str | None:
158159
device_class=SensorDeviceClass.ENUM,
159160
options=get_options(station.State),
160161
),
162+
EcovacsSensorEntityDescription[auto_empty.AutoEmptyEvent](
163+
capability_fn=lambda caps: caps.station.auto_empty if caps.station else None,
164+
value_fn=lambda e: get_name_key(e.frequency) if e.frequency else None,
165+
key="auto_empty",
166+
translation_key="auto_empty",
167+
device_class=SensorDeviceClass.ENUM,
168+
options=get_options(auto_empty.Frequency),
169+
),
161170
)
162171

163172

‎homeassistant/components/ecovacs/strings.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@
149149
}
150150
},
151151
"sensor": {
152+
"auto_empty": {
153+
"name": "Auto-empty frequency",
154+
"state": {
155+
"auto": "Auto",
156+
"smart": "Smart"
157+
}
158+
},
152159
"error": {
153160
"name": "Error",
154161
"state_attributes": {

‎tests/components/ecovacs/snapshots/test_sensor.ambr‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,70 @@
16521652
'state': 'Testnetwork',
16531653
})
16541654
# ---
1655+
# name: test_sensors[qhe2o2][sensor.dusty_auto_empty_frequency:state]
1656+
StateSnapshot({
1657+
'attributes': ReadOnlyDict({
1658+
'device_class': 'enum',
1659+
'friendly_name': 'Dusty Auto-empty frequency',
1660+
'options': list([
1661+
'min_10',
1662+
'min_15',
1663+
'min_25',
1664+
'auto',
1665+
'smart',
1666+
]),
1667+
}),
1668+
'context': <ANY>,
1669+
'entity_id': 'sensor.dusty_auto_empty_frequency',
1670+
'last_changed': <ANY>,
1671+
'last_reported': <ANY>,
1672+
'last_updated': <ANY>,
1673+
'state': 'auto',
1674+
})
1675+
# ---
1676+
# name: test_sensors[qhe2o2][sensor.dusty_auto_empty_frequency:entity-registry]
1677+
EntityRegistryEntrySnapshot({
1678+
'aliases': set({
1679+
}),
1680+
'area_id': None,
1681+
'capabilities': dict({
1682+
'options': list([
1683+
'min_10',
1684+
'min_15',
1685+
'min_25',
1686+
'auto',
1687+
'smart',
1688+
]),
1689+
}),
1690+
'config_entry_id': <ANY>,
1691+
'config_subentry_id': <ANY>,
1692+
'device_class': None,
1693+
'device_id': <ANY>,
1694+
'disabled_by': None,
1695+
'domain': 'sensor',
1696+
'entity_category': None,
1697+
'entity_id': 'sensor.dusty_auto_empty_frequency',
1698+
'has_entity_name': True,
1699+
'hidden_by': None,
1700+
'icon': None,
1701+
'id': <ANY>,
1702+
'labels': set({
1703+
}),
1704+
'name': None,
1705+
'options': dict({
1706+
}),
1707+
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
1708+
'original_icon': None,
1709+
'original_name': 'Auto-empty frequency',
1710+
'platform': 'ecovacs',
1711+
'previous_unique_id': None,
1712+
'suggested_object_id': None,
1713+
'supported_features': 0,
1714+
'translation_key': 'auto_empty',
1715+
'unique_id': '8516fbb1-17f1-4194-0000001_auto_empty',
1716+
'unit_of_measurement': None,
1717+
})
1718+
# ---
16551719
# name: test_sensors[yna5x1][sensor.ozmo_950_area_cleaned:entity-registry]
16561720
EntityRegistryEntrySnapshot({
16571721
'aliases': set({

‎tests/components/ecovacs/test_sensor.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
NetworkInfoEvent,
1212
StatsEvent,
1313
TotalStatsEvent,
14+
auto_empty,
1415
station,
1516
)
1617
import pytest
@@ -47,6 +48,7 @@ async def notify_events(hass: HomeAssistant, event_bus: EventBus):
4748
event_bus.notify(LifeSpanEvent(LifeSpan.SIDE_BRUSH, 40, 20 * 60))
4849
event_bus.notify(ErrorEvent(0, "NoError: Robot is operational"))
4950
event_bus.notify(station.StationEvent(station.State.EMPTYING_DUSTBIN))
51+
event_bus.notify(auto_empty.AutoEmptyEvent(True, auto_empty.Frequency.AUTO))
5052
await block_till_done(hass, event_bus)
5153

5254

@@ -102,6 +104,7 @@ async def notify_events(hass: HomeAssistant, event_bus: EventBus):
102104
"sensor.dusty_wi_fi_rssi",
103105
"sensor.dusty_wi_fi_ssid",
104106
"sensor.dusty_station_state",
107+
"sensor.dusty_auto_empty_frequency",
105108
"sensor.dusty_main_brush_lifespan",
106109
"sensor.dusty_filter_lifespan",
107110
"sensor.dusty_round_mop_lifespan",

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /