StephanJoubert / home_assistant_solarman

Home Assistant component for Solarman collectors used with a variety of inverters.
Apache License 2.0
507 stars 191 forks source link

Added support for individual update intervals for each range #611

Closed StackOverflowEx closed 3 days ago

StackOverflowEx commented 3 days ago

This pull request adds the option to specify an update interval per request.

For instance, consider the following request definition. This definition will update the register range 0x0584 - 0x0589 no earlier than every 60 seconds, even if MIN_TIME_BETWEEN_UPDATES is set to 15 seconds.

requests:
  - start: 0x0584
    end: 0x0589
    mb_functioncode: 0x03
    interval: 60

This allows for finer control. For example, we could query the current home power consumption every 15 seconds while we query the daily generated solar power only once every 120 seconds.

However, the MIN_TIME_BETWEEN_UPDATES setting specifies the absolute minimum. If MIN_TIME_BETWEEN_UPDATES is set to 15 seconds, the interval setting will have no effect if it is less or equal to 15 seconds. Furthermore, if the interval for a range is set to 20 and MIN_TIME_BETWEEN_UPDATES to 15 seconds, the range might only be updated after 30 seconds (or a multiple of MIN_TIME_BETWEEN_UPDATES)