Automation exit or condition help

Greetings,
is it possible to exit automation from the action part? if some value template is true/fallse?

And why is my condition not working when i trigger the service automation from button, it is starting in both states true/false?

- id: '1601726261665'
  alias: rolety_number_increase_test_2
  description: ''
  trigger: []
  condition:
  - condition: not
    conditions:
    - condition: template
      value_template: '{{states.input_number.slider1.state==states.input_number.slider2.state}}'
  action:
  - repeat:
      until:
      - condition: template
        value_template: '{{states.input_number.slider1.state==states.input_number.slider2.state}}'
      sequence:
      - service: input_number.increment
        data: {}
        entity_id: input_number.slider1
      - delay: 00:00:01
  mode: single

My point is, i want the action of the automation to go only if the conditions of the automation are not true

Okay,
Thereā€™s a few things here, but Iā€™ll start with the first
Trigger: - rubbish trigger that will never fire
Condition - rubbish condition that will never be true
Action - whatever you want

When you fire an automation manually, it doesnā€™t matter what the trigger is or what the condition is, it will just run whatever your action is. i.e. it ONLY tests the action.
If you want to test conditions set an input_boolean.test (I keep a couple knocking around). Add this boolean to your trigger list and that way you can test conditions (you will need to reload automations before doing the test (but I think the gui may do that for you, dunno I donā€™t use the automation editor) ).

This makes no sense - ā€œWorkā€ - ā€œBut only if the conditions donā€™t let you passā€ - Eh ???

I think what you mean is : -

    condition:
      - condition: template
        value_template: "{{ not (states('input_number.slider1') == states('input_number.slider2') }}"  

Confirmed.

I canā€™t remember the last time I had to manually reload automations.

Thx for your time, will try your proposal

As far as I know and what my tests, it does not.
You need to reload automations.

Interestingā€¦
I have never had that experience.

I only use the GUI editor.
Click the save button and itā€™s good to go.

Actually i think i managed it by putting it in choose inside action:

- 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

That is horrendous !

This will cause a trigger on ANY state change on the HA instance.
If you value efficiency and your CPU utilisation, do not do this

Try my suggestion in post 2

@Mutt was referring to the trigger - condition - action sequence of all automations.
If you manually trigger an automation is skips straight to the action: taking in any conditions it may contain, such as in your case.

1 Like

Yep thatā€™s what I said.
Iā€™ve tried to read it again with a different slant but canā€™t see how ukro got anything else from it.

A little bit lost there, if there is

trigger:[]

It will not run ever , only by manual trigger,right?

How about asking the question the correct way around.
Explain what you have and what you are trying to accomplish and someone will help you out with the automation.

Thats actually what i need, i just moved the condition down, and it is doing what i want.

1 Like

If you want to run just an action sequence, that is only called manually, what you want is a script not an automation

Why would i want a scripting (not familiar with that for now) if now its worked like i want, i just dont understand regarding the CPU loading.
Confirmed, restarted, working like a charm.
I hope the CPU is doing what was said

Imagine you got your cars engine running at 3000 rpm day and night.
That is what you are doing.

How can i check if the script is running 3000rpm? if nothing is triggering it?
Only a custom push button that run service automation trigger

A script is just the action part of an automation (same structure, same syntax - everything)

You can use scripts to write code you can use again and again.
Write it once and use it in different places
This way it makes your automations shorter and the code is easier to maintain / debug
It also can be called independantly as you are trying to do.
The actions and conditions are completely irrelevany - so donā€™t use them

Do i understand correctly that
ā€˜ā€™ā€™
trigger:[]
ā€˜ā€™ā€™
Means nothing is triggering it?

I see, okay thank you, will find some time and look into the scripting <3