Home assistant sees trigger; simple automation not firing

So I have a very simple automation that toggles a lamp on or off when I press an Ikea Tradfri Shortcut button. It was created using the visual editor:

Here’s the YAML:

alias: Toggle Lamp (Tradfri Shortcut Button)
description: ""
trigger:
  - platform: device
    domain: mqtt
    device_id: 8a50b6420386656beddf547ad2358f74
    type: action
    subtype: "on"
    discovery_id: 0xf082c0fffe81fc1e action_on
condition: []
action:
  - service: switch.toggle
    target:
      entity_id: switch.lamp
    data: {}
mode: single

Most of the time it works. But sometimes, it just doesn’t fire - even though the logbook shows that Home Assistant is seeing the button being pressed. For example, I pressed it three times here:

image

But the last time it ran was yesterday:

when the logbook looks identical:

image

Since the automation is about as simple as it gets, and since HA is seeing the trigger, I don’t know where to start troubleshooting.

(It usually starts working again after a reboot.)

the place i’d start is at the trace.

in the automation click the upper right where it says traces.

this will give you a step by step review of each call. find the one that failed and see what it says. it may take you a minute to grock all the info there, but once you do, it will be an invaluable tool for you.

go take a look and holler if you need help.

The trace doesn’t show the recent button presses; only the last time it successfully completed yesterday:

huh. that is indeed curious. esp since it’s in the logbook but not triggering the automation.

since you have that automation trigger on “on” . i don’t know the specifics on that tradfri entity, could it’s state have abeen already on such that it didn’t actually trigger because it’s not a new state? in my logbook, i have 2 devices that get “turned off” log entries a couple times a day even tho they were off and stayed off, and my off automation doesn’t trigger.

is curious…

You’re using MQTT, so there could be an issue with your broker.

Also check the HA and broker logs for errors.

Then, steer away from device triggers. Just use a state trigger with the entity ID.

As said, if the state is unchanged (matches what it currently is, HA will do nothing).

The discrepancy between the trace and logbook is strange.