Sensor updates

trigger:
  - platform: numeric_state
    entity_id: sensor.octopus_energy_electricity_xxxxxxxx_xxxxxxx_current_rate
    below: 0.33

This trigger is to activate an automation based on energy price changes. Usually it works as expected, but a significant amount of times it fails to trigger when the unit price drops below this rate. I suspect that this may be due to our occasionally patchy Internet connection - so if the price drops from 0.35 to 0.25 at 07:30 and we’re offline at that point, the trigger won’t activate. But at 08:30, with the price still below 0.33 and the Internet connection being up for at least 45 minutes, the trigger still hasn’t been activated.
How exactly does this trigger work, and what can I do to get it to re-evaluate in case of a bad connection? Does it only trigger when the price crosses a threshold (so if it misses that due to the connection being down, it won’t trigger again until that threshold is crossed again), or can it be set to keep checking what the value of that entity is and then trigger later even if it misses the initial threshold crossing?

Changing from unknown to a value lower than 0.33 should trigger it.

What state does the sensor have when you have no internet?

You could use this catch-all trigger and condition:

trigger:
  - platform: state
    entity_id: sensor.octopus_energy_electricity_xxxxxxxx_xxxxxxx_current_rate
    to: # null to triggers on all state changes, ignores attribute changes
    not_to:
      - unknown 
      - unavailable 
condition:
  - condition: numeric_state
    entity_id: sensor.octopus_energy_electricity_xxxxxxxx_xxxxxxx_current_rate
    below: 0.33

Does there actually need to be a change in state? If the connection was down when it changed from 0.33 to 0.25 and then it stayed at 0.25 for several hours, would the automation trigger? Or if it kept changing but stayed below 0.33 would it trigger?
Trigger was actually set at 0.29 below, whne the automation didn’t work.


Looking at the entity history, it doesn’t show any gaps in data. So a bit stumped now

No. It must transition from above 0.33 to below.

My example above overcomes this.

Thank you. Will give your code a try

returns this error when I try to save the code
“Message malformed: two or more values in the same group of exclusion ‘to’ @ data[]”
?

Change the trigger to this

  - platform: state
    entity_id: sensor.octopus_energy_electricity_xxxxxxxx_xxxxxxx_current_rate
    not_to:
      - unknown 
      - unavailable