State_changed automation creates loop

It seems like this automation creates a loop. If it is triggered then its last_triggered: attribute updates which is a state change which triggers it again. Does anyone know a way to stop the state machine from observing this automation entity?

- alias: Test Event
  initial_state: True
    platform: event
    event_type: state_changed
    - service: system_log.write
        title: test
        level: error
        message: >

Yeah, that’s quite the trigger you have. You are triggering on ALL STATES OF EVERYTHING! Automations have their own states too lol. So when the automation fires, it will change its own state, firing again.

If you ignore the automation domain, it would help.

Put in this condition:

  - "{{ != 'automation' }}"

Or, if you only want to ignore this exact automation only…

  - "{{ != automation.test_event }}"

Hey, @jocnnor

Thanks for the reply! Yeah I thought about adding the condition but it would still continuously trigger. I know a time_changed event would continuously trigger and that makes sense. I just feel that you should be able to deny an entity from being observed or something. Having this thing constantly trigger feels wrong to me(OCD thing maybe). I will probably look into the source code to see what I can do about it although its a little above my Python skill level still. Luckily there is more than one way to skin a cat in HA. Once again I appreciate you chiming in!!

What’s the end goal of this?

Passing all the data available via state_update event about the entity to a separate application.

I can do something similar with this:

- alias: Test State Message
  initial_state: False
    platform: state
      - sensor.test_sensor
      - binary_sensor.token
    - service: persistent_notification.create
        title: Test
        message: >

This doesn’t seem to have the old state info though.

The old state is accessed via from_state, not to_state


Anyway, why not write the data to your db and read it from there? And what do you do with the other application?

@Burningstone Well that makes sense lol!

The other app is a local webserver. Besides HA being a great Home Automation tool, I am using it to learn Python and other programming disciplines. I am just messing around but in the last 4 years I have never used an state_updated event trigger so I thought it was weird how it acted even though it makes sense.