mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix issue 8894 with uk_transport component if no next_buses or next_trains (#9046)
* Fix bug if no next_buses or trains Fixes https://github.com/home-assistant/home-assistant/issues/8894 * Requested fixes
This commit is contained in:
parent
2355216f61
commit
48909539be
@ -180,9 +180,12 @@ class UkTransportLiveBusTimeSensor(UkTransportSensor):
|
|||||||
'estimated': departure['best_departure_estimate']
|
'estimated': departure['best_departure_estimate']
|
||||||
})
|
})
|
||||||
|
|
||||||
self._state = min(map(
|
if self._next_buses:
|
||||||
_delta_mins, [bus['scheduled'] for bus in self._next_buses]
|
self._state = min(
|
||||||
))
|
_delta_mins(bus['scheduled'])
|
||||||
|
for bus in self._next_buses)
|
||||||
|
else:
|
||||||
|
self._state = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
@ -242,10 +245,12 @@ class UkTransportLiveTrainTimeSensor(UkTransportSensor):
|
|||||||
'operator_name': departure['operator_name']
|
'operator_name': departure['operator_name']
|
||||||
})
|
})
|
||||||
|
|
||||||
self._state = min(map(
|
if self._next_trains:
|
||||||
_delta_mins,
|
self._state = min(
|
||||||
[train['scheduled'] for train in self._next_trains]
|
_delta_mins(train['scheduled'])
|
||||||
))
|
for train in self._next_trains)
|
||||||
|
else:
|
||||||
|
self._state = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user