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

Feature Request: Changeable Refresh Time #22

Open
TheChosentwo opened this issue Jan 8, 2025 · 6 comments
Open

Feature Request: Changeable Refresh Time #22

TheChosentwo opened this issue Jan 8, 2025 · 6 comments
Labels
enhancement New feature or request

Comments

@TheChosentwo
Copy link

Hi, I used the add-on now for some weeks and I really love it, great work!

I saw in your Code that the Sensor is refreshing every 30 Seconds, I found that is a bit often.

It would be great if everyone can change it for their own preferences.

I never tried to create an add-on but I found some tutorial where they wrote, you can add an options.json file that can handle this feature request.

If you need more Information, please write back.

Kind regards

@akloeckner
Copy link
Owner

Yes, this sounds reasonable. I put this fast update rate, because I don't want the next train to be shown "five minutes ago". (Also, KVB delays tend to magically appear out of nowhere in the last minute before departure. 😉)

Can you point me to this options.json documentation? If it is that simple, we should definitely do it. If it's more difficult, we could still add an option to the sensor configuration.

@akloeckner
Copy link
Owner

akloeckner commented Jan 8, 2025

I did some searching and it appears to me, the scan interval of polling sensors is intentionally not configurable in HA anymore. See documentation. Instead, the recommended way to customise the polling interval is to write an automation for it. See here for an example:

https://community.home-assistant.io/t/recommended-way-to-define-scan-intervals-for-sensors/596265

@TheChosentwo
Copy link
Author

Thank you for the fast reply!

I found the information on this website:

https://developers.home-assistant.io/docs/add-ons/tutorial/#bonus-working-with-add-on-options

I will try your idea too in the next days, but it is not so easy when the add-on don't work atm.

@akloeckner
Copy link
Owner

akloeckner commented Jan 9, 2025

I found the information on this website:

This is about add-ons, which is basically a software separate from home assistant, such as MQTT brokers. It doesn't seem to provide for setting scan intervals for custom components.

I will try your idea too in the next days, but it is not so easy when the add-on don't work atm.

Yes, that's a disappointing development... I'm not sure yet how to handle this.

@TheChosentwo
Copy link
Author

TheChosentwo commented Jan 9, 2025

My idea was, that you can dynamically adjust the value in the sensor.py file where you set the scan_interval.

SCAN_INTERVAL = timedelta(seconds=30)

With the help of the options file.
That you can edit this value over the ui and it will be updated becouse it is a reference from the sensor.py to the option.py file.

@LordMike
Copy link

[..], the recommended way to customise the polling interval is to write an automation for it. See here for an example:

Amazing. Just what I wanted. I want dynamic pollings (night, rush hour, ..) which would be too much to ask - but now I can fix it myself.

Thanks for the integration. It works beautifully. :)

@akloeckner akloeckner added the enhancement New feature or request label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants