How to make Template Sensor update immediately and not wait x seconds?

I have a template sensor that relies on other template sensors. They take an awful lot of time to update.

  • Should I just use update_interval: 5s,
  • will force_update: true solve the problem, or
  • can I do a lambda call on the Template Sensor to make it update when the sensor it depends on updates: on_update: then: - lambda: something?
  • Any other option?

I’m assuming that updating sensors too frequently will slow down the device. Is it the case?

With this interval values (if they are changed) should be pushed every 5 seconds to HA.

No as it will just send the values with the same interval but also when they are not changed (typically a bad idea for most cases)

There is a component.update action:

Many

No

1 Like

Thanks, the component_update action is just what I need. The documentation is really good, but sometimes it’s hard to find the thing you don’t know you’re looking for.

A note to anyone using component.update; beware of calling this on a sensor from multiple places simultaneously. For instance something like this might jam the device:

- id: sensor1
  on_value:
    then:
      component.update: sensor2
      component.update: sensor3

- id: sensor2
  lambda: |>
    return id(sensor1).state;
  on_value:
    then:
      component.update: sensor3
1 Like