Condition - state change is NOT from -other Automation-

Okay, thank you, I understand so far.

This means that I would not control the automation but a Bool helper, which in turn is queried in automation.

However, this does not yet solve the question of how I control this helper. So that when the light changes, the second automation checks and recognizes that the change is not triggered by the 1st automation and then switches the helper.

This stops an automation from running the actions when automation.xyz is what triggered it.

- condition: template
  value_template: "{{ trigger.to_state.context.parent_id != states.automation.xyz.context.id }}"

EDIT: Assuming this is a state trigger.

I’m sorry, I’m still new with home assistant.

But I don’t understand that.

If I enter … = states.automation.test.context.id }}" as a condition, it does not work.

You asked for a condition for when the state change is not from another automation, which is what’s provided. That condition will stop the automation from running when automation.xyz is what caused the state change.

That’s the Automation…

alias: Küche Bewegungsmelder
description: ""
trigger:
  - platform: state
    entity_id:
      - light.kuche_decke
      - light.kuche_herd
condition:
  - condition: template
    value_template: |-
      - condition: template
        value_template: "{{ trigger.to_state.context.parent_id != states.automation.kuche_bewegung.context.id }}"
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.kuche_bewegungsmelder
mode: restart

it should be

alias: Küche Bewegungsmelder
description: ""
trigger:
  - platform: state
    entity_id:
      - light.kuche_decke
      - light.kuche_herd
condition:
  - condition: template
    value_template: "{{ trigger.to_state.context.id != states.automation.kuche_bewegung.context.id }}"
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.kuche_bewegungsmelder
mode: restart
1 Like

I See, the UI- Editor…

And now, It works fine!

Thank u very much!

EDIT: It doesn’t works :frowning:

I think the problem is that the changes for lights are more then 1 Automation.

Now I want to build the automation in such a way that only when HomeKit or the ui the changes come, the helper is switched on.

condition:
  - condition: template
    value_template: "{{ trigger.to_state.context.parent_id not in states.automation | map(attribute='context.id') | list }}"

what’s that?

what you just asked for?

I mean I don’t understand what the code

makes sure the automation only runs when it comes from a source outside automations.

states.automation → makes a list of all automations
| map(attribute=‘context.id’) → maps the automations context.id as the item in the list
| list → makes it a list
trigger.to_state.context.parent_id not in → checks to see if the parent_id is in the automation list

Thanks for the information :slight_smile:

But it still doesn’t work.

If I control via HomeKit, it does not trigger.

alias: Küche Bewegungsmelder
description: ""
trigger:
  - platform: state
    entity_id:
      - light.kuche_decke
      - light.kuche_herd
condition:
  - condition: template
    value_template: >-
      "{{ trigger.to_state.context.parent_id not in states.automation |
      map(attribute='context.id') | list }}"
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.kuche_bewegungsmelder
mode: restart

check the trace and see why it didn’t trigger.

Triggered by the state of light.kuche_herd at 27. September 2022, 01:20:00

template condition

Stopped because a condition failed at 27. September 2022, 01:20:00 (runtime: 0.00 seconds)

remove teh quotes around your template.

1 Like

Now the template is captured, but always seems to say yes.

id: '1664203448089'
alias: Küche Bewegungsmelder
description: ''
trigger:
  - platform: state
    entity_id:
      - light.kuche_decke
      - light.kuche_herd_links
      - light.kuche_herd_rechts
condition:
  - condition: template
    value_template: >-
      {{ trigger.to_state.context.parent_id !=
      states.automation.kuche_bewegung.context.id }}
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.kuche_bewegungsmelder
mode: single



It’s going to always say yes when the context isn’t coming from an automation.

Context can only distinguish it’s origin if it came from: Automations, A user action in the frontend, and scripts. Everything else (Physical press or from the integration) are seen with no context as they both look the same.

So, this automations condition will only stop when it comes from an automation.

Sorry, I can’t read non-english.