Hello!
So I have a working doorbell that has a button and once pressed I want an automation to run. I have this running just fine with the classic button way, however for reasons I'm not entirely sure about, I figured: "hey there's a doorbell event class in home assistant – it sure is a good idea to fire an event when the button is pressed and have the automation run from the event instead of the button press!"
#how to trigger for esphome event?
1 messages · Page 1 of 1 (latest)
Said and done, my button press now triggers an event, but I'm having trouble to figure out how to get the event to trigger an automation. Because the event is simply: "doorbell", but listening to a doorbell event doesn't yield a trigger, unless I trigger it from the developer tools. So I started listening to * and sure got the event data from esphome:
event_type: state_changed
data:
entity_id: event.klingel_doorbell
old_state:
entity_id: event.klingel_doorbell
state: "2024-11-08T11:21:58.246+00:00"
attributes:
event_types:
- doorbell
event_type: doorbell
device_class: doorbell
icon: mdi:bell
friendly_name: Klingel doorbell
last_changed: "2024-11-08T11:21:58.246716+00:00"
last_reported: "2024-11-08T11:21:58.246716+00:00"
last_updated: "2024-11-08T11:21:58.246716+00:00"
context:
id: 01JC5R4W76A1CNN2VDP12G6Y54
parent_id: null
user_id: null
new_state:
entity_id: event.klingel_doorbell
state: "2024-11-08T11:22:02.229+00:00"
attributes:
event_types:
- doorbell
event_type: doorbell
device_class: doorbell
icon: mdi:bell
friendly_name: Klingel doorbell
last_changed: "2024-11-08T11:22:02.229720+00:00"
last_reported: "2024-11-08T11:22:02.229720+00:00"
last_updated: "2024-11-08T11:22:02.229720+00:00"
context:
id: 01JC5R503N1Q3SMNHNC1SPAKQC
parent_id: null
user_id: null
origin: LOCAL
time_fired: "2024-11-08T11:22:02.229720+00:00"
context:
id: 01JC5R503N1Q3SMNHNC1SPAKQC
parent_id: null
user_id: null
But how do I listen to that in an automation trigger?
this is the event in my esphome device:
event:
- platform: template
name: doorbell
id: doorbell
icon: "mdi:bell"
device_class: "doorbell"
event_types:
- "doorbell"
triggered by:
- event.trigger:
id: doorbell
event_type: "doorbell"
Looks like you can use the state of event.klingel_doorbell
triggers:
- trigger: state
entity_id: event.klingel_doorbell
to: ~
ohhh a state trigger, ofc. my brain was absolutely locked into using an event trigger ...
event_type: state_changed
data:
entity_id: event.klingel_doorbell
old_state:
``` 
now that my brain is unlocked it makes complete sense, but why does esphome not trigger an event in the way that I see when I use the event trigger in the dev tools? just because I'd like to understand ...
Because it moved to event entities
You can still use the state changed event, but that'd be daft
yeah looking at the event data I figured I must be doing something wrong, hence came here to ask 😅
HA is trying to move off of events and to event entities, since those are simpler to work with