mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Ontime and delay attribute are allways present in deutsche_bahn sensor (#1875)
This commit is contained in:
parent
448edecdd1
commit
3b0a35f571
@ -69,11 +69,10 @@ class DeutscheBahnSensor(Entity):
|
|||||||
"""Get the latest delay from bahn.de and updates the state."""
|
"""Get the latest delay from bahn.de and updates the state."""
|
||||||
self.data.update()
|
self.data.update()
|
||||||
self._state = self.data.connections[0].get('departure', 'Unknown')
|
self._state = self.data.connections[0].get('departure', 'Unknown')
|
||||||
delay = self.data.connections[0].get('delay',
|
if self.data.connections[0]['delay'] != 0:
|
||||||
{'delay_departure': 0,
|
self._state += " + {}".format(
|
||||||
'delay_arrival': 0})
|
self.data.connections[0]['delay']
|
||||||
if delay['delay_departure'] != 0:
|
)
|
||||||
self._state += " + {}".format(delay['delay_departure'])
|
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
@ -95,6 +94,14 @@ class SchieneData(object):
|
|||||||
self.goal,
|
self.goal,
|
||||||
datetime.now())
|
datetime.now())
|
||||||
for con in self.connections:
|
for con in self.connections:
|
||||||
# Details info are not useful.
|
# Details info is not useful.
|
||||||
|
# Having a more consistent interface simplifies
|
||||||
|
# usage of Template sensors later on
|
||||||
if 'details' in con:
|
if 'details' in con:
|
||||||
con.pop('details')
|
con.pop('details')
|
||||||
|
delay = con.get('delay',
|
||||||
|
{'delay_departure': 0,
|
||||||
|
'delay_arrival': 0})
|
||||||
|
# IMHO only delay_departure is usefull
|
||||||
|
con['delay'] = delay['delay_departure']
|
||||||
|
con['ontime'] = con.get('ontime', False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user