Sensor update interval question

A little question, Community.
Tell me, does update_interval affect the handling of such a case?
Or maybe it turns out that the relay can wait 30 seconds to turn off in an overloaded state?


    power:
      name: "${device_name} power"
      id: power
      unit_of_measurement: "W"
      filters:
        - calibrate_linear:
          - 0.0 -> 0.0
          - ${power_cal_meas} -> ${power_cal_real}
      on_value_range:
        - above: ${max_power}
          then:
            - switch.turn_off: relay
            - homeassistant.service:
                service: persistent_notification.create
                data:
                  title: Alert ${device_name}
                data_template:
                  message: Overload. ${max_power}W
    update_interval: 30s

I dont understand your question. The update interval doesnt effect the sensor or the automation triggering or not. Its just a manual update of what the state is and just reports to HA whatever the sensor value every 30 seconds. When that relay does or does not trigger, it has nothing to do with the update interval. That relay triggers on_value_range: …

Did I understand you correctly that update_interval concerns only interaction with HA, all automations inside itself esphome is not affected by that?

Yea, thats correct. So with a 30second interval you could have a 30 second delay potentially before HA updates the state you see in HA. This doesnt delay the relay triggering by 30 seconds though.

Now if you wanted to you could force an update to HA in the event that the relay was triggered and then not have to wait 30 seconds.

The automation is attached to your power sensor. The only way it triggers is if the sensor updates. The automation can only trigger once every 30 seconds.

If you are trying to watch an overload situation and waiting 30 seconds to kill the power is too long. You can shorten the interval so it updates every 5 seconds or even less.

crap, you’re right. The problem is update interval doesn’t effect all sensors that way where the automation will only fire on the update. on_value is one of those types where the interval does dictate when the automation can fire.

What about this variant?

interval:
  - interval: 100ms
    then:
      if:
        condition:
          and:
            - sensor.in_range:
                id: "${device_name}_temperature"
                above: ${max_temp}
            - switch.is_on: relay
        then:
          - switch.turn_off: relay
          - homeassistant.service:
              service: persistent_notification.create
              data:
                title: Alert ${friendly_name}
              data_template:
                message: ${friendly_name} Overheat ${max_temp} °C.

The problem with doing this is, there is still a default update_interval on the sensor itself. What did you change that too? You can set the update_interval: 0ms and that will update on every loop through the program which is as fast as you can update it and then that should be all you need. You don’t need the exra Interval automation automation at all, that’s just a redundant automation basically.

How does the circuit get reset? does it need turned on manually or what? I only see half an automation that kills the power. What turns it back on?

What sensor or device is this anyway? Is this like a smart plug w/power monitoring?

0ms may be to fast, i’m not 100% sure if that will cause any issues or if that 100ms delay might be more appropriate. You might try 0ms and see if it throws any complaints in the log output. If it does, increase it and try 100ms.

I agree it needs some value, 500ms should be fine. It will spam your history though.

What you can do is add internal: true to block it from the frontend. Then use a template sensor that updates every 15s or so on your dashboard.

I don’t know, I’m just testing and asking for community advice.
Initially, it seemed to me that this interval affects only on interaction with the frontend (something similar how the accuracy_decimals parameter works)

Alert to HA and further decision in manual mode.
This event is not normal, especially if the nominal consumption of the device is several times less than the specified upper limit

Yep, this is Shelly PM/Shelly Plug devices

Yes, this is a solution if everything works as described above.
Thank you