mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Fix delijn sensor stuck on last passage (#32710)
* Fix delijn sensor stuck on last passage If the returned passage is an empty list that means there are no next passages, so the sensor should be updated accordingly * Mark the sensor as unavailable instead of emptying data * use available property * add available property
This commit is contained in:
parent
a3dd9979d2
commit
c968e455a9
@ -66,6 +66,7 @@ class DeLijnPublicTransportSensor(Entity):
|
||||
self._attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
self._name = name
|
||||
self._state = None
|
||||
self._available = False
|
||||
|
||||
async def async_update(self):
|
||||
"""Get the latest data from the De Lijn API."""
|
||||
@ -88,8 +89,15 @@ class DeLijnPublicTransportSensor(Entity):
|
||||
self._attributes["due_at_schedule"] = first["due_at_schedule"]
|
||||
self._attributes["due_at_realtime"] = first["due_at_realtime"]
|
||||
self._attributes["next_passages"] = self.line.passages
|
||||
self._available = True
|
||||
except (KeyError, IndexError) as error:
|
||||
_LOGGER.debug("Error getting data from De Lijn: %s", error)
|
||||
self._available = False
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
"""Return True if entity is available."""
|
||||
return self._available
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user