|
|
@@ -17,7 +17,10 @@ async def async_setup_entry(
|
|
|
) -> None:
|
|
|
coordinator: RoomCalCoordinator = hass.data[DOMAIN][entry.entry_id]["coordinator"]
|
|
|
device_name = entry.data.get(CONF_ROOM_STATE_NAME, DEFAULT_ROOM_STATE_NAME)
|
|
|
- async_add_entities([ForceRefreshButton(coordinator, entry, device_name)])
|
|
|
+ async_add_entities([
|
|
|
+ ForceRefreshButton(coordinator, entry, device_name),
|
|
|
+ PromoteFromNextButton(coordinator, entry, device_name),
|
|
|
+ ])
|
|
|
|
|
|
|
|
|
class ForceRefreshButton(ButtonEntity):
|
|
|
@@ -38,4 +41,25 @@ class ForceRefreshButton(ButtonEntity):
|
|
|
)
|
|
|
|
|
|
async def async_press(self) -> None:
|
|
|
- await self._coordinator.async_request_refresh()
|
|
|
+ await self._coordinator.async_refresh()
|
|
|
+
|
|
|
+
|
|
|
+class PromoteFromNextButton(ButtonEntity):
|
|
|
+ _attr_has_entity_name = True
|
|
|
+ _attr_name = "Promote from Next"
|
|
|
+
|
|
|
+ def __init__(
|
|
|
+ self,
|
|
|
+ coordinator: RoomCalCoordinator,
|
|
|
+ entry: ConfigEntry,
|
|
|
+ device_name: str,
|
|
|
+ ) -> None:
|
|
|
+ self._coordinator = coordinator
|
|
|
+ self._attr_unique_id = f"{entry.entry_id}_promote_from_next"
|
|
|
+ self._attr_device_info = DeviceInfo(
|
|
|
+ identifiers={(DOMAIN, f"{entry.entry_id}_room_state")},
|
|
|
+ name=device_name,
|
|
|
+ )
|
|
|
+
|
|
|
+ async def async_press(self) -> None:
|
|
|
+ await self._coordinator.async_promote_next_to_current()
|