Condition - state change is NOT from -other Automation-

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.

In the third picture you can see that the lamp was switched by automation (KĂźche Bewegung). So the condition is met.

Sorry, but I can’t confirm anything without seeing it in english. Remember, if another automation triggers the entity in your trigger, it will not continue. That’s the only use case here.

OK, I understand. But I’m still too new to understand the system :frowning:

The aim was / is for automation (A) to check whether the lights have been switched by another specific automation (B) and if so, then nothing else does. If not, then keep running and turn on the helper.

Now the answer is always no… because even if the specific automation (B) switches the lights, the automation (A) is continued and the helper is switched on.

Yes, and I gave you that condition above and you said it wasn’t good enough. Also, your automation turns OFF the helper.

And that won’t happen, but I need to see the trace in english to see what’s actually happening. Sorry, I cant read your language. And I can’t copy/paste it to translate it because you took screenshots. My hands are tied, the ball is in your court.

I hope that’s better…



can you post the automation that you’re using as well

sure. that’s the Automation for the Lights triggered by motion-sensor

alias: KĂźche Bewegung
description: ""
trigger:
  - type: motion
    platform: device
    device_id: c0c19ca9b449a076cab5731ef34bb874
    entity_id: binary_sensor.kuche_bewegungssensor
    domain: binary_sensor
    id: Bewegung
  - type: no_motion
    platform: device
    device_id: c0c19ca9b449a076cab5731ef34bb874
    entity_id: binary_sensor.kuche_bewegungssensor
    domain: binary_sensor
    id: keine Bewegung
condition: []
action:
  - if:
      - condition: or
        conditions:
          - condition: trigger
            id: Bewegung
            alias: Bewegung
          - condition: and
            conditions:
              - condition: trigger
                id: Bewegungsmelder (Helfer) An
                alias: Bewegungsmelder (Helfer) An
              - type: is_motion
                condition: device
                device_id: c0c19ca9b449a076cab5731ef34bb874
                entity_id: binary_sensor.kuche_bewegungssensor
                domain: binary_sensor
            alias: Bewegungsmelder (Helfer) An und Bewegung erkannt
          - condition: trigger
            id: Test
        alias: Bewegung, oder Bewegungsmelder (Helfer An) und Bewegung erkannt
      - condition: state
        entity_id: input_boolean.kuche_bewegungsmelder
        state: "on"
      - condition: numeric_state
        entity_id: sensor.kuche_helligkeitssensor
        attribute: dark
        above: 0
        below: 2
        alias: Helligkeitssensor - Dark
        enabled: true
      - condition: trigger
        id: Bewegung
    then:
      - if:
          - condition: time
            after: "06:30:00"
            before: "22:00:00"
            alias: 06:30 Uhr - 22:00 Uhr
        then:
          - type: turn_on
            device_id: 208132dfc591f203bbb37fbd13fd0e31
            entity_id: light.kuche_decke
            domain: light
            brightness_pct: 60
            alias: KĂźche Decke Ein - 60%
          - type: turn_on
            device_id: 9d0754b4a502c636ab2f200fa1e16e03
            entity_id: light.kuche_herd_links
            domain: light
            brightness_pct: 40
            enabled: false
          - type: turn_on
            device_id: 69c3ef03bc456cf3abbcd881ad07bc7d
            entity_id: light.kuche_herd_rechts
            domain: light
            brightness_pct: 40
            enabled: false
        alias: Tag
      - if:
          - condition: time
            after: "22:00:00"
            before: "00:00:00"
            alias: 22:00 Uhr - 00:00 Uhr
        then:
          - type: turn_on
            device_id: 208132dfc591f203bbb37fbd13fd0e31
            entity_id: light.kuche_decke
            domain: light
            brightness_pct: 30
            alias: KĂźche Decke Ein - 30%
            enabled: true
          - type: turn_on
            device_id: 9d0754b4a502c636ab2f200fa1e16e03
            entity_id: light.kuche_herd_links
            domain: light
            brightness_pct: 20
            enabled: false
          - type: turn_on
            device_id: 69c3ef03bc456cf3abbcd881ad07bc7d
            entity_id: light.kuche_herd_rechts
            domain: light
            brightness_pct: 20
            enabled: false
        alias: Spät
      - if:
          - condition: time
            after: "00:00:00"
            before: "06:30:00"
            alias: 00:00 Uhr - 06:30 Uhr
        then:
          - type: turn_on
            device_id: 208132dfc591f203bbb37fbd13fd0e31
            entity_id: light.kuche_decke
            domain: light
            brightness_pct: 10
            alias: KĂźche Decke Ein - 10%
          - type: turn_on
            device_id: 9d0754b4a502c636ab2f200fa1e16e03
            entity_id: light.kuche_herd_links
            domain: light
            brightness_pct: 5
            enabled: false
          - type: turn_on
            device_id: 69c3ef03bc456cf3abbcd881ad07bc7d
            entity_id: light.kuche_herd_rechts
            domain: light
            brightness_pct: 5
            enabled: false
        alias: Nacht
    alias: Bewegung
  - if:
      - condition: trigger
        id: keine Bewegung
        alias: keine Bewegung
      - condition: state
        entity_id: input_boolean.kuche_bewegungsmelder
        state: "on"
        alias: KĂźche Bewegungsmelder ist An
    then:
      - device_id: 208132dfc591f203bbb37fbd13fd0e31
        domain: light
        entity_id: light.kuche_decke
        type: brightness_decrease
      - device_id: 3cb16ca57fe116ee027a586b44dddc5f
        domain: light
        entity_id: light.kuche_herd
        type: brightness_decrease
      - delay:
          hours: 0
          minutes: 0
          seconds: 6
          milliseconds: 0
      - type: turn_off
        device_id: 1bf7fa27672e425f03cd0771702ef3d1
        entity_id: light.kuche_licht_schalter_gruppe
        domain: light
    alias: keine Bewegung
mode: restart

and that’s the atomation, for checking the triggered automation.

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

And the trace is for Küche Bewegungsmelder, correct? Because that’s the automation that will not fire if Küche Bewegung is the triggering automation.

You can try changing the automation to this and then post the results of the Changed Variables tab. Please do not post a screenshot, post the text on the tab.

alias: KĂźche Bewegungsmelder
description: ""
trigger:
  - platform: state
    entity_id:
      - light.kuche_decke
      - light.kuche_herd_links
      - light.kuche_herd_rechts
variables:
  parent: "{{ trigger.to_state.context.parent_id }}"
  other: "{{ states.automation.kuche_bewegung.context.id }}"
condition:
  - condition: template
    value_template: "{{ parent != other }}"
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.kuche_bewegungsmelder
mode: single

step config:
platform: state
entity_id:

  • light.kuche_decke
  • light.kuche_herd_links
  • light.kuche_herd_rechtsthis:

changed variables:

entity_id: automation.kuche_bewegungsmelder
state: ‘on’
attributes:
last_triggered: ‘2022-09-28T20:31:10.208230+00:00’
mode: single
current: 0
id: ‘1664203448089’
friendly_name: KĂźche Bewegungsmelder
last_changed: ‘2022-09-28T18:52:17.125785+00:00’
last_updated: ‘2022-09-28T20:31:10.239324+00:00’
context:
id: 01GE2WQKWQVBH1RQPZ1E21824T
parent_id: 01GE2WQKW28JCXM1ZBA1KJ97R9
user_id: null
trigger:
id: ‘0’
idx: ‘0’
alias: null
platform: state
entity_id: light.kuche_decke
from_state:
entity_id: light.kuche_decke
state: ‘off’
attributes:
min_mireds: 153
max_mireds: 454
supported_color_modes:
- color_temp
is_deconz_group: false
friendly_name: KĂźche Decke
supported_features: 40
last_changed: ‘2022-09-28T20:31:10.209087+00:00’
last_updated: ‘2022-09-28T20:31:10.209087+00:00’
context:
id: 01GE2WQKW1BX6Y1YZ15KVBT541
parent_id: null
user_id: null
to_state:
entity_id: light.kuche_decke
state: ‘on’
attributes:
min_mireds: 153
max_mireds: 454
supported_color_modes:
- color_temp
color_mode: color_temp
brightness: 76
color_temp: 454
hs_color:
- 29.79
- 84.553
rgb_color:
- 255
- 146
- 39
xy_color:
- 0.579
- 0.388
is_deconz_group: false
friendly_name: KĂźche Decke
supported_features: 40
last_changed: ‘2022-09-28T20:31:14.868049+00:00’
last_updated: ‘2022-09-28T20:31:14.868049+00:00’
context:
id: 01GE2WQRAHFRP2VAWKMYJHCF59
parent_id: 01GE2WQRADSF1QJ8MX0Y6YJ5M3
user_id: null
for: null
attribute: null
description: state of light.kuche_decke
parent: 01GE2WQRADSF1QJ8MX0Y6YJ5M3
other: 01GE2WQRAHFRP2VAWKMYJHCF59

Step Config

condition: template
value_template: ‘{{ parent != other }}’

Changed Variables

Executed: September 28, 2022 at 10:31:14 PM
Result:

result: true entities: []

Changed Variables

No variables changed

Ok, put this in the Developer Tools → Template tab (Template editor) and tell me what you get:

{% set tar = '01GE2WQRADSF1QJ8MX0Y6YJ5M3' %}
Automation: {{ states.automation | selectattr('context.id', 'eq', tar) | map(attribute='name') | list | first | default }}
Script: {{ states.script | selectattr('context.id', 'eq', tar) | map(attribute='name') | list | first | default }}
Something Else: {{ states| selectattr('context.id', 'eq', tar) | map(attribute='name') | list | first | default }}

Copy/paste the results here.

Automation:
Script:
Something Else:

Ok, I see the problem

The solution reply has been updated.

1 Like

That’s it, yeah!

But I was wondering why it still triggered 2-3 seconds later. Then I noticed that I use adaptive lighting. Then I turned it off and it didn’t trigger anymore.

Great, thanks for that.

Can the system also be used for this adaptive lighting? So if the lamps are changed by them, it should not trigger either.

I tested with second condition

{{ trigger.to_state.context.id != states.service.adaptive_lighting_kuche.context.id }}

But it doesn’t work…

do u have an idea/tip for?

I was able to solve it.

Adaptive Lighting only controls the color temperature for me. Therefore, I have set the triggers to Turn On and Change Brightness.

Thanks again for the help, that really helps a lot!

Greetings

1 Like