This repository has been archived by the owner on Jul 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to aiohttp, fix update_interval (#23)
* Migrate aiohttp, fix update_interval * Request data refresh after service calls
- Loading branch information
Showing
10 changed files
with
151 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""Provides the The Fully Kiosk Browser DataUpdateCoordinator.""" | ||
from datetime import timedelta | ||
import logging | ||
|
||
from aiohttp import ClientSession | ||
from aiohttp.client_exceptions import ClientConnectorError | ||
from async_timeout import timeout | ||
from fullykiosk import FullyKiosk | ||
from fullykiosk.exceptions import FullyKioskError | ||
|
||
from homeassistant.helpers.typing import HomeAssistantType | ||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed | ||
|
||
from .const import UPDATE_INTERVAL | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class FullyKioskDataUpdateCoordinator(DataUpdateCoordinator): | ||
"""Define an object to hold Fully Kiosk Browser data.""" | ||
|
||
def __init__( | ||
self, hass: HomeAssistantType, session: ClientSession, host, port, password | ||
): | ||
"""Initialize.""" | ||
self.fully = FullyKiosk(session, host, port, password) | ||
|
||
super().__init__( | ||
hass, _LOGGER, name=f"{host} deviceInfo", update_interval=timedelta(seconds=UPDATE_INTERVAL) | ||
) | ||
|
||
async def _async_update_data(self): | ||
"""Update data via library.""" | ||
try: | ||
with timeout(10): | ||
return await self.fully.getDeviceInfo() | ||
except (FullyKioskError, ClientConnectorError) as error: | ||
raise UpdateFailed(error) from error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.