#Change input number only once in automation, how?

7 messages · Page 1 of 1 (latest)

turbid lichen
#

I have a automation action, that on condition flips a input number to a certain number. but the next condition action flips it again if the input number from the last action has already flipped it. How do i make sure this only happens once per automation? With the choose option?
Here is the automation:

      - condition: numeric_state
        entity_id: input_number.yuka_angle_helper
        above: 89
        below: 91
    then:
      - action: input_number.set_value
        metadata: {}
        data:
          value: 0
        target:
          entity_id: input_number.yuka_angle_helper
  - if:
      - condition: numeric_state
        entity_id: input_number.yuka_angle_helper
        below: 1
    then:
      - action: input_number.set_value
        metadata: {}
        data:
          value: 90
        target:
          entity_id: input_number.yuka_angle_helper
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: input_number.yuka_angle_helper
            below: 1
        sequence:
          - action: input_number.set_value
            metadata: {}
            data:
              value: 0
            target:
              entity_id: input_number.yuka_angle_helper
      - conditions:
          - condition: numeric_state
            entity_id: input_number.yuka_angle_helper
            above: 89
            below: 91
        sequence:
          - action: input_number.set_value
            metadata: {}
            data:
              value: 0
            target:
              entity_id: input_number.yuka_angle_helper```

Will the choose do its job? can i remove the If's from actions?
supple onyx
#

Add a stop action to your conditions. Unless you have additional processing that happens further down in the automation. In that case, you might need to move your actions around a bit.

turbid lichen
#

thanks, didnt know that was a option 🙂

green ocean
#

Have a text helper made and set the value of that to 'stay'
Run your choose stuff and instead of changing your input number, flip the helper to 'flip'
On the second to last action check if the helper is flip, and change your number.
For completeness last action set helper to 'stay'.

#

I'm more head-on...

supple onyx
#

Oooohhhh can also template the input_number.set_value action as well. I forgot about that.

tawdry harness
#

@turbid lichen To directly answer your original question: yes, a choose block would work here, so only one of the options would ever be executed. The other suggestions provided will work also… Depends on how you’d like to skin the cat.

Just wanted to make you aware that the original path you were thinking of going down was not misguided.