#Combining async conditions in automation

1 messages · Page 1 of 1 (latest)

gleaming nexus
#

Hello, I have a simple automation to set input boolean expensive_elec on/off depending of the electricity price and current rank.

It has been working fine until today in the morning I noticed that the boolean was off even the price was high.

I think it is caused by asyncronous updating of the sensors rank and price so that rank change was triggered, but price was still acceptable at that point of time.

How is this normally handled? Or do I just need to create a new sensor to follow a status of the rank and price together, and use it as a trigger?

Thanks!

alias: SHF Expensive electricity
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.shf_rank_now
conditions: []
actions:
  - if:
      - condition: state
        entity_id: binary_sensor.shf_price_acceptable
        state: "off"
      - condition: numeric_state
        entity_id: sensor.shf_rank_now
        above: 12
    then:
      - action: input_boolean.turn_on
        target:
          entity_id: input_boolean.expensive_elec
        data: {}
    else:
      - action: input_boolean.turn_off
        target:
          entity_id: input_boolean.expensive_elec
        data: {}
mode: single
#

Or now after posting this, I realized that I can maybe use both sensors as a trigger for the automation?