-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move london underground coordinator to its own file (#99550)
- Loading branch information
Showing
5 changed files
with
62 additions
and
50 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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,26 @@ | ||
"""Constants for the London underground integration.""" | ||
from datetime import timedelta | ||
|
||
DOMAIN = "london_underground" | ||
|
||
CONF_LINE = "line" | ||
|
||
|
||
SCAN_INTERVAL = timedelta(seconds=30) | ||
|
||
TUBE_LINES = [ | ||
"Bakerloo", | ||
"Central", | ||
"Circle", | ||
"District", | ||
"DLR", | ||
"Elizabeth line", | ||
"Hammersmith & City", | ||
"Jubilee", | ||
"London Overground", | ||
"Metropolitan", | ||
"Northern", | ||
"Piccadilly", | ||
"Victoria", | ||
"Waterloo & City", | ||
] |
30 changes: 30 additions & 0 deletions
30
homeassistant/components/london_underground/coordinator.py
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,30 @@ | ||
"""DataUpdateCoordinator for London underground integration.""" | ||
from __future__ import annotations | ||
|
||
import asyncio | ||
import logging | ||
|
||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator | ||
|
||
from .const import DOMAIN, SCAN_INTERVAL | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class LondonTubeCoordinator(DataUpdateCoordinator): | ||
"""London Underground sensor coordinator.""" | ||
|
||
def __init__(self, hass, data): | ||
"""Initialize coordinator.""" | ||
super().__init__( | ||
hass, | ||
_LOGGER, | ||
name=DOMAIN, | ||
update_interval=SCAN_INTERVAL, | ||
) | ||
self._data = data | ||
|
||
async def _async_update_data(self): | ||
async with asyncio.timeout(10): | ||
await self._data.update() | ||
return self._data.data |
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