-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Periodically refresh overkiz states #99499
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed | ||
from homeassistant.util.decorator import Registry | ||
|
||
from .const import DOMAIN, LOGGER, UPDATE_INTERVAL | ||
from .const import DOMAIN, LOGGER, REFRESH_DEVICE_STATES_INTERVAL, UPDATE_INTERVAL | ||
|
||
EVENT_HANDLERS: Registry[ | ||
str, Callable[[OverkizDataUpdateCoordinator, Event], Coroutine[Any, Any, None]] | ||
|
@@ -209,3 +209,32 @@ async def on_execution_state_changed( | |
ExecutionState.FAILED, | ||
]: | ||
del coordinator.executions[event.exec_id] | ||
|
||
|
||
class OverkizDeviceRefreshCoordinator(DataUpdateCoordinator[None]): | ||
"""Class to trigger device state refresh for devices on Overkiz platform.""" | ||
|
||
def __init__( | ||
self, | ||
hass: HomeAssistant, | ||
logger: logging.Logger, | ||
*, | ||
client: OverkizClient, | ||
device_url: str, | ||
) -> None: | ||
"""Initialize data update coordinator.""" | ||
self.client = client | ||
self.device_url = device_url | ||
super().__init__( | ||
hass, | ||
logger, | ||
name=f"device refresh for {device_url}", | ||
update_interval=REFRESH_DEVICE_STATES_INTERVAL, | ||
) | ||
|
||
# Ensure this coordinator runs periodically even though there is no listener needed. | ||
self.async_add_listener(lambda: None) | ||
|
||
async def _async_update_data(self) -> None: | ||
"""Trigger device state refresh on Overkiz platform.""" | ||
await self.client.refresh_device_states(self.device_url) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not really a use-case where the data update coordinator is required imo, since you don't receive any data here. See iMicknl/ha-tahoma#271 for my initial try 3 years ago. Code is very outdated, but shows you another approach. You could use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Allright, I'll migrate it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, let me know if you need help! This issue (#103183) looks related. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this more specific? I am not sure if an UIClass (or widget) is specific enough. There are many many Overkiz devices and perhaps we should scope this on the
controllable_name
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, makes sense.