Automation conditions not stoppig execution

I cannot get one of my automatons to work correctly. I’m trying to get an input_boolean to indicate if someone is home or not. I have 2 groups, people (with device trackers) and occupancy (motion sensors). Those groups seem to be working correctly (i believe). The problem is turning on/off the input_boolean.

My conditions in the automation do not appear to have any effect on the automation. If i trigger it manually it always performs the actions (turning on/off the input_boolean). Per the documentation “When a condition does not return true, the automation will stop executing.” To simplify the debugging i just use 1 group shown below

- id: '1600695293635'
  alias: homeOccupancyAway
  description: ''
  trigger:
  - platform: state
    entity_id: group.occupancy
  condition:
  - condition: state
    entity_id: group.occupancy
    state: away
  action:
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.home_occupied
  mode: single

When i manually execute this it always performs the action. Wat am i missing?

Isn’t there something missing in the trigger? You have the entity but you do not say which of its states will set the automation off. This will work if you execute it manually, but otherwise there is nothing to start it running.

I’ll change it. I thought i read somewhere that it would catch all changes.

I’ll rewrite it with conditions in the trigger and see how it goes.

Regardless when i hit execute shouldn’t it check the current condition to ensure it matches the rule before executing the action? It would be nice to be able to test it

When you manually execute an automation, trigger and condition is skipped. You are only running the action part of your automation

That is correct

1 Like

You can do that, but not with the Execute button:

To test an automation there’s three stages you can follow. Testing the action, the condition and action, and the whole automation:

  1. Use Developer toolsStates to find the automation, click and then push Execute. If this fails your problem is in the action: section, and details should be found in your log file

  2. Use Developer toolsServices and call automation.trigger on the automation with skip_condition: false . If the first passes but this fails then the problem is in your condition: block

  3. Use Developer toolsStates to find the trigger entity, click the name, then change the state (at the top) to something that’ll trigger the automation before pushing Set State . If this fails then the problem is with your trigger: section.

3 Likes

Almost true, condition you can put to action part like i did, worked like a charm.

- id: '1601800879799'
  alias: Rolety up
  description: ''
  trigger: []
  condition: []
  action:
  - delay: 00:00:02
  - choose:
    - conditions:
      - condition: template
        value_template: '{{states.input_number.slider1.state!=states.input_number.slider2.state}}'
      sequence:
      - repeat:
          until:
          - condition: template
            value_template: '{{states.input_number.slider1.state==states.input_number.slider2.state}}'
          sequence:
          - delay: 00:00:01
    default: []
  - service: switch.turn_on
    entity_id: switch.rolety_start
  mode: single

why not use that?:

 trigger:
  - platform: state
    entity_id: group.occupancy
    to: away

is there an advantage to have the away state in the condition?

Except, the state isn’t away :wink:

yeah I use not_home personally,
but I didn’t even know HA existed when this post was created so I thought it was that a the time.

but its the first time that I see a condition use that way, is that standard?

No, you’re absolutely correct in what you say that this should be done in the trigger.

1 Like