-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On-demand update of swiss public transport sensor #16723
Conversation
…has crossed). Looking at the documentation on https://transport.opendata.ch/docs.html, delay information is available only on stationboard, so no need to query often if there is no "real"time info.
…catch client errors like throttling rejection (HTTP 429)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 🐦
sensor:
- platform: swiss_public_transport
name: Train
from: Bern
to: Biel
@@ -111,7 +112,7 @@ def device_state_attributes(self): | |||
ATTR_DEPARTURE_TIME2: self._opendata.connections[2]['departure'], | |||
ATTR_START: self._opendata.from_name, | |||
ATTR_TARGET: self._opendata.to_name, | |||
ATTR_REMAINING_TIME: '{}'.format(remaining_time), | |||
ATTR_REMAINING_TIME: '{}'.format(self._remaining_time), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to store relative (to now) times in the state machine as they spam it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, it is an existing attribute. I don't use it / dont see a need for it - don't know what is the adoption.
Agree this does not necessarily be in state machine and can be calculated in a template only by whom who needs it.
Do you recommend deprecating this attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say so yes. @fabaff do you agree?
Description:
Changing Swiss Public Transport sensor to update it's values only when required (only after the train has crossed)
Related issue (if applicable): fixes #9012
(Linking to old issue as the issue has not dissapeared completely and this pull request is extension of previous fix to change it from 90 seconds to on-demand)
Closes home-assistant-ecosystem/python-opendata-transport#3
Checklist:
tox
. Your PR cannot be merged unless tests passIf the code does not interact with devices: