mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Update london-tube-status for TfL API breaking change (#73671)
* Update london-tube-status for TfL API breaking change The TfL API used by the london_underground component (through the london-tube-status module) introduced breaking changes recently, which in turn broke the component, and require updating the london-tube-status dependency to fix. However the newer module versions also introduced other changes, including switching from requests to aiohttp, which require converting the london_underground component to use async APIs. Fixes #73442 * Update sensor.py Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
committed by
GitHub
parent
b6d3e34ebc
commit
670bf0641a
@ -2,7 +2,7 @@
|
||||
"domain": "london_underground",
|
||||
"name": "London Underground",
|
||||
"documentation": "https://www.home-assistant.io/integrations/london_underground",
|
||||
"requirements": ["london-tube-status==0.2"],
|
||||
"requirements": ["london-tube-status==0.5"],
|
||||
"codeowners": [],
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["london_tube_status"]
|
||||
|
@ -9,6 +9,7 @@ import voluptuous as vol
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||
from homeassistant.const import ATTR_ATTRIBUTION
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
@ -43,21 +44,24 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
)
|
||||
|
||||
|
||||
def setup_platform(
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
add_entities: AddEntitiesCallback,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
discovery_info: DiscoveryInfoType | None = None,
|
||||
) -> None:
|
||||
"""Set up the Tube sensor."""
|
||||
|
||||
data = TubeData()
|
||||
data.update()
|
||||
session = async_get_clientsession(hass)
|
||||
|
||||
data = TubeData(session)
|
||||
await data.update()
|
||||
|
||||
sensors = []
|
||||
for line in config[CONF_LINE]:
|
||||
sensors.append(LondonTubeSensor(line, data))
|
||||
|
||||
add_entities(sensors, True)
|
||||
async_add_entities(sensors, True)
|
||||
|
||||
|
||||
class LondonTubeSensor(SensorEntity):
|
||||
@ -92,8 +96,8 @@ class LondonTubeSensor(SensorEntity):
|
||||
self.attrs["Description"] = self._description
|
||||
return self.attrs
|
||||
|
||||
def update(self):
|
||||
async def async_update(self):
|
||||
"""Update the sensor."""
|
||||
self._data.update()
|
||||
await self._data.update()
|
||||
self._state = self._data.data[self.name]["State"]
|
||||
self._description = self._data.data[self.name]["Description"]
|
||||
|
@ -969,7 +969,7 @@ locationsharinglib==4.1.5
|
||||
logi_circle==0.2.3
|
||||
|
||||
# homeassistant.components.london_underground
|
||||
london-tube-status==0.2
|
||||
london-tube-status==0.5
|
||||
|
||||
# homeassistant.components.recorder
|
||||
lru-dict==1.1.7
|
||||
|
Reference in New Issue
Block a user