Skip to content

Commit

Permalink
Fix wrong offset #9 - thanks to @noxhirsch
Browse files Browse the repository at this point in the history
  • Loading branch information
FaserF committed May 26, 2023
1 parent cfbe39d commit 2e6d6ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion custom_components/deutschebahn/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"requirements": [
"schiene==0.26"
],
"version": "2.0.2"
"version": "2.0.4"
}
10 changes: 5 additions & 5 deletions custom_components/deutschebahn/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, config, hass: HomeAssistantType):
self.updated = datetime.now()
self.start = config[CONF_START]
self.goal = config[CONF_DESTINATION]
self.offset = timedelta(seconds=config[CONF_OFFSET])
self.offset = timedelta(minutes=config[CONF_OFFSET])
self.only_direct = config[CONF_ONLY_DIRECT]
self.schiene = schiene.Schiene()
self.connections = [{}]
Expand Down Expand Up @@ -104,7 +104,7 @@ def extra_state_attributes(self):
connections["next"] = self.connections[1]["departure"]
if len(self.connections) > 2:
connections["next_on"] = self.connections[2]["departure"]
else:
else:
connections = None
return connections

Expand Down Expand Up @@ -139,12 +139,12 @@ async def async_update(self):

if self.connections[0].get("delay", 0) != 0:
self._state = f"{self.connections[0]['departure']} + {self.connections[0]['delay']}"
else:
else:
self._state = self.connections[0].get("departure", "Unknown")
else:
else:
_LOGGER.exception(f"Data from DB for direction: '{self.start}' '{self.goal}' was empty, retrying at next sync run. Maybe also check if you have spelled your start and destination correct?")
self._available = False

except:
self._available = False
_LOGGER.exception(f"Cannot retrieve data for direction: '{self.start}' '{self.goal}'")
Expand Down

0 comments on commit 2e6d6ef

Please sign in to comment.