Relay Switch Action not Logged

I have a D1 Mini hooked up to a relay switch with ESPHome installed. The relay is imported into Home Assistant and I have no problems triggering the switch to turn the relay on and off. I want to set up an automation (with nodered) whenever the relay is turned on or off. However, I noticed that any time the switch in Home Assistant is triggered, the action is not logged in Home Assistant and the event is not triggered in NodeRed either.

I suspect that since the relay is only turned on for a second, it is not long enough for HA to trigger the event of it being “on”. Here is the switch entry in ESPHome:

switch:
- platform: gpio
  id: relay
  pin:
    number: GPIO5
    inverted: False
  restore_mode: ALWAYS_OFF
- platform: template
  name: "Garage Door Switch"
  icon: "mdi:garage"
  turn_on_action:
    - switch.turn_on: relay
    - delay: 1s
    - switch.turn_off: relay
    
- platform: restart
  name: 'Garage Door REBOOT'

Anyone have any ideas on how I can get the event to be logged? I feel like HA should be logging every action even if it’s only for a second.

Home Assistant 0.104.3
ESPHome 1.14.3
NodeRed 1.0.3

What do your esphome logs tell you?

ESPHome shows the relay turning on and off:

[22:54:34][D][switch:021]: 'Garage Door Switch' Turning ON.
[22:54:34][D][switch:021]: 'relay' Turning ON.
[22:54:34][D][switch:045]: 'relay': Sending state ON
[22:54:35][D][switch:025]: 'relay' Turning OFF.
[22:54:35][D][switch:045]: 'relay': Sending state OFF

home-assistant.log does not show anything of value and the logbook does not show that anything was changed. I can see the switch in HA switch from “off” to “on” and back to “off” but nothing is logged or triggered

I figured a round-about way to get what I need. I created a Events: All node in nodered with a call_service filter. I pushed that into a switch to check if payload.event.service is turn_on. Next I send that payload to another switch to check if payload.event.service_data.entity_id is the switch that I am targeting. If all that is true, I send a notification. I know that I could have wrapped both of the switches into a single function, but this way I can alert on other “turn_on” actions

Not ideal, but it works!