-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat!: re-structure state and attributes #7
Conversation
next still fails with not finding property departure?!
@risiko79, @sc-ampersand-p, @kilimnik What do you think? I have this running on my instance for some time. It works well. However, I might miss some use cases, as I am not a heavy user. I am actually converting the data to the old state format for display on my wall-panel. However, I still think it is cleaner to use an actual timestamp as state. |
@akloeckner I think this sounds pretty solid, I can't think of any usecase that requires any additional information. Using a timestamp seems the most logical and robust path forward. |
Allow an observer of this effort to comment on this. I like the datastructure. It covers all the use case I can think of from top of my hat. Also the datetime proposal sounds great. However, I'd advise not to have keys
This would allow for a later extension of the list to a user-defined length. |
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.
Looks good to me, but as external observer I'd abstain from giving a formal review vote here.
Good suggestion! I just factored it in, because it was there before. But: We're leaving the "compatible" path anyways, so why not also change that... To be radical, I would then even not include this list at all, because it is there already in the We might argue to rename it to |
Good point. How about |
Looking at the other integrations again - see #4 (comment) - I think we should use Now, as the connections returned are actually a complex data structure, I think, However: we would not have a list of pure timestamps then. Just the complex data structure. Which I don't consider a problem, because we can generate a list of timestamps easily in a Jinja2 template: {{ state_attr('sensor.koln_hbf_to_frankfurt_main_hbf', 'connections')
| map(attribute='departure')
| list }} Edit: Template for all non-canceled connections:
|
* empty if no journeys returned * populated else * unknown state, if no running connection
seems to require category 🤷
For reference, a change like this was also introduced in the swiss public transport official integration: home-assistant/core#106485 |
BREAKING CHANGE:
This changes the
state
to be the actualtimestamp
of the next non-cancelled departure including delay. This allows to use thestate
programmatically, e.g. to compute atimedelta
from it. Also, the sensor will be shown natively as a relative time, such as "in 5 minutes".This also changes the
attributes
to allow for a list ofconnections
to be returned. The followingattributes
are provided:"next": timestamp of next (i.e. second) departure including delay"next_on": timestamp of over-next (i.e. third) departure including delayWhere a connection provides the following information:
Where each leg contains the following information:
train
RE123
Related: #4