Dynamic update interval

So I’m trying to develop an automated gardening system. I’m using ESPHome and so far so good until now. I’ve got a moisture sensor and a solenoid valve controlled by a relay on two separate ESP’s, I’ve got the automation through Hassio working correctly. Basically when the value of the moisture level falls below a certain level, the solenoid valve opens which then rewaters the whole system, and then when the moisture level gets above a certain level it shuts.

This is automated via the ‘update_interval:’ Hassio receives for the automation to work. However, I don’t need to update/publish/receive the reading every 10s when it’s freshly watered, however I cannot afford to check it every 30 minutes when it’s dry.

How could I create a dynamic update interval differs dependent on the value the sensor receives.

I’m pretty darn new at this, so I may using the ‘update_interval:’ line in an improper fashion.



What does it matter if the update is too frequent?

1 Like

Came across this thread while looking for a similar solution, where the sensor only needs updated at a long interval (ex: 30s) except during a certain condition, where having it update at a shorter interval (ex: 1s) would be helpful for more accurate readings.

I can’t speak for the OP, but I’m thinking the underlying reasoning for this may be the same: It would seem that if a sensor is updating every 1s, more resources (network communication, HA reading and recording, DB entries) are required than at 30s. Would this be correct?

I can’t speak for the OP either, but I am looking for this because I want to run the sensor on battery.
My personal setup is to monitor the water level in tank with rain water - It’s more than enough to scan it once before the pump starts and once after it stops - to see how much I used.
When the rain is predicted - scan once per hour to see how much and how fast it is refiled.

… I wonder why there are people who feel the urge to post a comment, without answering the question.

I do it this way…

  - id: interval
    mode: restart
      - component.update: bme280_sensor
      - delay: !lambda "return id(update_interval).state * 1000;"
      - script.execute: interval

  - platform: homeassistant
    id: update_interval
    entity_id: input_number.bme280_update_interval
        - script.execute: interval

  - platform: bme280
    id: bme280_sensor
    address: 0x76
    update_interval: never
      name: $device_name Temperature
      id: temperature
      icon: mdi:temperature-fahrenheit
      accuracy_decimals: 1
      name: $device_name Humidity
      id: humidity
      icon: mdi:water-percent
      accuracy_decimals: 1
      name: $device_name Pressure
      id: pressure
      accuracy_decimals: 5