ESPHome <-> HA update interval

I’ve flashed smart outlet with ESPHome using HLW8012 component. I was doing calibration (power and voltage measurement) and I setup update_interval to 5s to see changes more often.
So I start to wonder if this option affects on interval of sending data to HA? If not, what is the option / default value of sending data from esphome devoce to HA?

It doesn’t.

Esphome uses local push for communication with HA. So every change is instantly reported.

So it affects indirectly - when update_interval is very frequent (like 5 sec) then sensor state - for example power - changes very often (5 sec) and is being reported to HA evry 5 sec, right?

I did test it - sensor values (like power in my case) is being pushed to HA every time state change. So yes, update_interval is in charge of it.

Have you tried setting update_interval to say, 60? Does it change anything?

Yes. As I already wrote update_interval affects how often data is being fetched for sensor. And if there is value change then it’s pushed to HA.

that’s strange. I had an impression that it’s either poll or push but not both.

As @orange-assistant wrote previously, every state/value change is being pushed to HA immediately. So when you setup update_interval to 60 sec for example, then you’re gonna have HA updated every at most every 60 sec. If you setup to 5 sec then every 5 sec at most (except value/state does not change).

I still don’t get why you think it works that way.
I believe it’s either 1) HA polls an entity or b) entity sends its new state to HA.
Reading the link above

LOCAL DEVICE PUSHING NEW STATE: If it does not also support polling, home automation will not be made aware of the state after booting up until it changes.

so it looks like the answer depends on “Does your ESPHome device support pushing and polling”?

My understanding is that it uses local push to send data to ha. update_interval in esphome sets how often that push occurs, however I don’t think this setting is available for everything in esphome.

EDIT: meant to add that my devices always seem to have the right state upon boot of either device. I would suspect that esphome pushes when it connect to ha.

Ok, I just opened the code to see how it works as I don’t like to guess.

  1. I took a binary_sensor as an example - any esphome entity will do. So it inherits everything from EsphomeEntity.
  2. EsphomeEntity is a child of Entity, which uses SCAN_INTERVAL.
  3. EsphomeEntity has polling disabled by default (and binary_sensor does not change it) so it’s any sort of push but not polling (so no scan_interval is used).
  4. I can see no signs of SCAN_INTERVAL in esphome integration code.

So from what I can see there should be no impact of scan_interval on esphome entities.

@AhmadK yes, I’ve just took a look into as well :slight_smile:
I get the feeling that you mean scan_interval in HA. I was asking about scan_interval option in esphome code (for my ESP8266 based outlet).


looking at the original question, it was


Haha :smiley: , at very beggining I wrote:

I’ve flashed smart outlet with ESPHome […]

But thank you for all the comments, I’m little bit smarter now :stuck_out_tongue:

Also check out the sensor filters for additional control

I saw that. It’s just that update_interval in esphome and scan_interval in HA confusion… :slight_smile:

force_update sounds like the way to go, if anyone else stumbles upon this. More info here.

No, sorry, but it’s just bullshit :cow2::poop: what you posted on a 2 year old thread :man_facepalming:

force_update will update (push) values to ha even when they are the same (and at the same time not increasing the update interval :bulb:). This is something you typically don’t want at all because it creates traffic for no reason and it will also flood you ha db

It’s disabled by default for a good reason @sarrchini