Add backflush sensor to lamarzocco (#119888)

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
Josef Zweck 2024-06-21 15:27:22 +02:00 committed by GitHub
parent 6caf614efd
commit e149aa6b2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 65 additions and 0 deletions

View File

@ -45,6 +45,13 @@ ENTITIES: tuple[LaMarzoccoBinarySensorEntityDescription, ...] = (
available_fn=lambda device: device.websocket_connected, available_fn=lambda device: device.websocket_connected,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
LaMarzoccoBinarySensorEntityDescription(
key="backflush_enabled",
translation_key="backflush_enabled",
device_class=BinarySensorDeviceClass.RUNNING,
is_on_fn=lambda config: config.backflush_enabled,
entity_category=EntityCategory.DIAGNOSTIC,
),
) )

View File

@ -56,3 +56,4 @@ class LaMarzoccoButtonEntity(LaMarzoccoEntity, ButtonEntity):
async def async_press(self) -> None: async def async_press(self) -> None:
"""Press button.""" """Press button."""
await self.entity_description.press_fn(self.coordinator.device) await self.entity_description.press_fn(self.coordinator.device)
await self.coordinator.async_request_refresh()

View File

@ -14,6 +14,12 @@
"on": "mdi:cup-water", "on": "mdi:cup-water",
"off": "mdi:cup-off" "off": "mdi:cup-off"
} }
},
"backflush_enabled": {
"default": "mdi:water-off",
"state": {
"on": "mdi:water"
}
} }
}, },
"button": { "button": {

View File

@ -54,6 +54,9 @@
}, },
"entity": { "entity": {
"binary_sensor": { "binary_sensor": {
"backflush_enabled": {
"name": "Backflush active"
},
"brew_active": { "brew_active": {
"name": "Brewing active" "name": "Brewing active"
}, },

View File

@ -1,4 +1,51 @@
# serializer version: 1 # serializer version: 1
# name: test_binary_sensors[GS01234_backflush_active-binary_sensor]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'running',
'friendly_name': 'GS01234 Backflush active',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.gs01234_backflush_active',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_binary_sensors[GS01234_backflush_active-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.gs01234_backflush_active',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.RUNNING: 'running'>,
'original_icon': None,
'original_name': 'Backflush active',
'platform': 'lamarzocco',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'backflush_enabled',
'unique_id': 'GS01234_backflush_enabled',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[GS01234_brewing_active-binary_sensor] # name: test_binary_sensors[GS01234_brewing_active-binary_sensor]
StateSnapshot({ StateSnapshot({
'attributes': ReadOnlyDict({ 'attributes': ReadOnlyDict({

View File

@ -18,6 +18,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
BINARY_SENSORS = ( BINARY_SENSORS = (
"brewing_active", "brewing_active",
"backflush_active",
"water_tank_empty", "water_tank_empty",
) )