|
@@ -29,6 +29,7 @@ async def async_setup_entry(
|
|
|
OverrideEmptyButton(coordinator, entry, device_name),
|
|
OverrideEmptyButton(coordinator, entry, device_name),
|
|
|
GuestArrivedButton(coordinator, entry, device_name),
|
|
GuestArrivedButton(coordinator, entry, device_name),
|
|
|
GuestDepartedButton(coordinator, entry, device_name),
|
|
GuestDepartedButton(coordinator, entry, device_name),
|
|
|
|
|
+ GuestEnteredButton(coordinator, entry, device_name),
|
|
|
])
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
@@ -160,3 +161,31 @@ class GuestDepartedButton(ButtonEntity):
|
|
|
|
|
|
|
|
async def async_press(self) -> None:
|
|
async def async_press(self) -> None:
|
|
|
await self._coordinator.async_set_departed(True)
|
|
await self._coordinator.async_set_departed(True)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class GuestEnteredButton(ButtonEntity):
|
|
|
|
|
+ """Pressed every time the door is opened, checked in or not. The button's own
|
|
|
|
|
+ state (last-pressed timestamp) is what automations for "on every building
|
|
|
|
|
+ entry" should trigger on. The first press for a stay also flips Arrived, if
|
|
|
|
|
+ it isn't already set — subsequent presses leave Arrived untouched."""
|
|
|
|
|
+
|
|
|
|
|
+ _attr_has_entity_name = True
|
|
|
|
|
+ _attr_translation_key = "guest_entered"
|
|
|
|
|
+ _attr_icon = "mdi:door-open"
|
|
|
|
|
+
|
|
|
|
|
+ def __init__(
|
|
|
|
|
+ self,
|
|
|
|
|
+ coordinator: RoomCalCoordinator,
|
|
|
|
|
+ entry: ConfigEntry,
|
|
|
|
|
+ device_name: str,
|
|
|
|
|
+ ) -> None:
|
|
|
|
|
+ self._coordinator = coordinator
|
|
|
|
|
+ self._attr_unique_id = f"{entry.entry_id}_guest_entered"
|
|
|
|
|
+ self._attr_device_info = DeviceInfo(
|
|
|
|
|
+ identifiers={(DOMAIN, f"{entry.entry_id}_room_state")},
|
|
|
|
|
+ name=device_name,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ async def async_press(self) -> None:
|
|
|
|
|
+ if not self._coordinator.data.active_arrived:
|
|
|
|
|
+ await self._coordinator.async_set_arrived(True)
|