Automation - Until condition doesn't trigger

it’s momentary. So the moment I release the switch it’s ‘button_1_release’. Both in the action attribute as well as the state. Dev_tools ( see below ) gives me a correct true and false so it should work…

{{ is_state('sensor.wallswitch_attic_action', 'button_1_release' )}}
{{ is_state('sensor.wallswitch_attic_action', 'button_1_hold' )}}

{{ is_state_attr('sensor.wallswitch_attic_action','action','button_1_release') }}```

Try to look here, for me this is working and is stopping on until event:

- id: '1601810050556'
  alias: rolety_number_increase_test_4
  description: ''
  trigger: []
  condition: []
  action:
  - choose:
    - conditions:
      - condition: template
        value_template: '{{states.input_number.slider1.state!=states.input_number.slider2.state}}'
      sequence:
      - service: switch.turn_on
        data: {}
        entity_id: switch.rolety_channel_change
      - delay: 00:00:01
      - service: switch.turn_off
        data: {}
        entity_id: switch.rolety_channel_change
      - delay: 00:00:01
      - repeat:
          until:
          - condition: template
            value_template: '{{states.input_number.slider1.state==states.input_number.slider2.state}}'
          sequence:
          - service: switch.turn_on
            data: {}
            entity_id: switch.rolety_channel_change
          - delay: 00:00:01
          - service: switch.turn_off
            data: {}
            entity_id: switch.rolety_channel_change
          - service: input_number.increment
            data: {}
            entity_id: input_number.slider1
          - delay: 00:00:01
    default: []
  mode: single

Nice code…

I’ll try to adapt it to my situation and give it a go. Not mqtt is it? Keep thinking there is something there that doesn’t work.

1 Like

Put it inside the

choose:

Does the state stay at "button_1_release until you press the next button or does it change to “idle” or sonething similar after a few seconds?

And while you hold the button, is there any attribute thant changes during the time you hold the button? I could imagine that somehow an attribute changes state during the time you hold the button and triggers your automation again even though the state didn’t change. Do you get any warnings in the logs?

1 Like

No mqtt but try to use the

choose

and let me know.

Why do you think this? You say that the entity in HA correctly reflects the current button press, so everything should be fine on MQTT side.

All the states are momentary. So the moment I long press the button it’s button_1_hold, than the state is empty. The moment I release the button it’s button_1_release.

Should trigger on the later one… but it doesn’t.

Because the state change doesn’t seem to register in HA. This is what I see in the logbook :

.

I find that weird. The action doesn’t register in the logbook, but does in the logfiles.

Show us the developer tab when you press

Not familiar with the choose option in automation. I’ll check it out…

1 Like

That’s your problem. Your automation can’t work. The until part will never be true.

At the point it wants to check the until condition, the state is already empty again.

Developer tools. The states briefly switch to ‘true’ on press or release. I actually had to make a video of my screen and play it in slow motion to capture it. It is very very momentary.

So it’s a timing problem? The state switches, briefly. But still it goes to the ‘button_1_release’ state.

Maybe to short of a switch for HA?

Which is funny because it does register the ‘button_1_hold’ state. Which starts the automation…

No, it’s not too short of a switch for HA to notice, the problem is in your action you turn the light on, wait one second and then it checks if the state of the button is “hold_1_release” but at this point it’s already back at an empty state.

Yeah i think you need to change the strategy. Make an input_number for value saving and make 2 automations for that to put to 1 and 0. This what i would do. But im a beginner

Doesn’t work without the delay either.

Just worked that in on a suggestion in one of the HA facebook groups. Tried it without… no go.

As per ukro’s suggestion I’m actually considering using a helper for the toggle of the switch. Might work.

You’d rather use an input_boolean for this if you only want 0 and 1 :wink:

1 Like

I am using for slide min1 max6
But i can suggest only what i know. Bollean is better for him,but after that i cant help him :grinning: