Automation trigger doesn't fire

Hi,

I have the following code as part of my automations.yaml:

- alias: "IR commands"
  trigger:
    platform: state
    entity_id: switch.my_power
    to: "on"
  action:
      service: mqtt.publish
      data:
        topic: "cmnd"
        payload: '{"gyumolcs":"alma"}'

While all the other automation in the same file work properly, this one doesn’t get triggered. The entity id is correct, the state does become on when switched, the service works in the Developer tools/Services page.

I have just started using automation, so it is probably something very trivial, like a missing/extra space/etc.

Any help would be greatly appreciated!

v

that topic looks lacking. Everything else looks fine.

I shortened the topic here a bit, true, but it’s besides the point as it works properly when tried from the Developer tools/Services page. Also, the topic here should work as well, it’s a valid mqtt topic (i admit it is unusual :slight_smile: )

Then if this is all good, any idea how I can investigate it? Any specific log, etc?

Indentation looks off after action,but config check should complain.

What exactly is wrong with the identation? Config check didn’t complain… But again, it doesn’t always report problems and I’m new to this…

here

  action:
      service: mqtt.publish
      data:
        topic: "cmnd"
        payload: '{"gyumolcs":"alma"}'

has 4 spaces, should be

  action:
    service: mqtt.publish
    data:
      topic: "cmnd"
      payload: '{"gyumolcs":"alma"}'

But yes the checker doesn’t complain i just test it also, you can change it see if it makes a difference

the other thing to check if is the automation entity (automation.ir_commands) is actually on or enabled.

I’m afraid, no difference…

It turns out that I was using the wrong switch entity… Doh…

Thank you anyway for trying to help!!!