Skip to content
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

Erroneous "last updated" #35

Open
JPersson77 opened this issue Jan 27, 2024 · 2 comments
Open

Erroneous "last updated" #35

JPersson77 opened this issue Jan 27, 2024 · 2 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed shouldbefixed

Comments

@JPersson77
Copy link

JPersson77 commented Jan 27, 2024

Hi,

I'm a noob with Home Assistant and the state machine so please bare with me. I could not get the departure card to properly show adjusted time remaining to departure, so I decided to take a look.

I have specified a 300s refresh rate for the sensor, but it seems the culprit of the issue is that the value defined in line 62:

var updatedDate = new Date(entity_data.last_updated);

increment every minute and not every 5 minutes (300s) as expected. It seems the departure data fields refresh every 5 min as expected, but the attributes..next_departure_minutes keep ticking down every minute, which cause the last_changed to have an erroneous value. This disturbs the calculated time remaining.

I tried to google, and I suspect (but I am not sure) that this may be changed behaviour for the last_updated field. So to make it work I had to change the above line to:

var updatedDate = new Date(entity_data.attributes.last_refresh);

I also stumbled upon another issue with the integration which seems unable to properly update the config for the sensor (it always revert to the initial settings), but I see that someone has submitted a PR for that already. But this issue meant that I could not change the primary measure (state?) of the sensor from 'min' to 'updated' to see how that would affect the issue described here. But I think regardless the above is the correct value to use for determining when the sensor data was last read from server.

@DSorlov DSorlov self-assigned this Feb 7, 2024
@DSorlov DSorlov added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed shouldbefixed labels Feb 7, 2024
@DSorlov
Copy link
Member

DSorlov commented Feb 7, 2024

Hi @JPersson77!

This is kind of the best issue I have ever received. You are totally right as this have been changed in the history of home assistant and we should look at that value. I will try to find time but there are some big changes to SL-api which breaks the integration so putting my efforts in there.. but a PR can always be merged. =)

@DSorlov
Copy link
Member

DSorlov commented Feb 7, 2024

Duplicate issue: #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed shouldbefixed
Projects
None yet
Development

No branches or pull requests

2 participants