393 files
This commit is contained in:
@@ -45,6 +45,7 @@ async def async_setup_entry(
|
||||
WashDataResumeCycleButton(manager, entry),
|
||||
WashDataRecordStartButton(manager, entry),
|
||||
WashDataRecordStopButton(manager, entry),
|
||||
WashDataMarkUnloadedButton(manager, entry),
|
||||
])
|
||||
|
||||
|
||||
@@ -246,4 +247,53 @@ class WashDataRecordStopButton(ButtonEntity):
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Handle the button press."""
|
||||
await self._manager.async_stop_recording()
|
||||
await self._manager.async_stop_recording()
|
||||
|
||||
class WashDataMarkUnloadedButton(ButtonEntity):
|
||||
"""Button to confirm the load has been taken out (#451).
|
||||
|
||||
The automation-facing half of unload confirmation: a physical button, an NFC
|
||||
tag or any other automation can press this instead of the door sensor WashData
|
||||
would otherwise need. Available only while the machine is in the Clean state
|
||||
(cycle finished, load still inside) - there is nothing to confirm otherwise,
|
||||
and Home Assistant skips an unavailable entity in a service call, so an
|
||||
automation that presses it unconditionally is a harmless no-op.
|
||||
"""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_translation_key = "mark_unloaded"
|
||||
_attr_icon = "mdi:basket-check-outline"
|
||||
|
||||
def __init__(self, manager: WashDataManager, entry: ConfigEntry) -> None:
|
||||
"""Initialize the button."""
|
||||
self._manager = manager
|
||||
self._entry = entry
|
||||
self._attr_unique_id = f"{entry.entry_id}_mark_unloaded"
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, entry.entry_id)},
|
||||
"name": entry.title,
|
||||
"manufacturer": "WashData",
|
||||
}
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Register callbacks."""
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
self.hass,
|
||||
SIGNAL_WASHER_UPDATE.format(self._entry.entry_id),
|
||||
self._update_callback,
|
||||
)
|
||||
)
|
||||
|
||||
@callback
|
||||
def _update_callback(self) -> None:
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Only available while the finished load is still waiting to be taken out."""
|
||||
return self._manager.is_clean_state
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Handle the button press."""
|
||||
self._manager.mark_unloaded("mark unloaded button")
|
||||
|
||||
Reference in New Issue
Block a user