Add `Entity.listen_event`
Is there an existing feature request for this?
- [x] I have searched the existing issues
Your feature request
Analogous to Entity.listen_state consider adding a Entity.listen_event-function.
This would make usage of Entitys more intuitiv and reduce code overhead since you don't need to extract the entity name from an Entity before listening for events of that entity.
Not sure I follow you with this. I don't think Home Assistant generally emits events directly tied to entities that aren't state changes (state_changed events)
Wow this is embarrassing. I've been using appdaemon for at least four years now and your comment made me realize just now that listen_state is just a shorthand for listen_event("state_changed")
Apologies and thanks!
I need to reopen this, unfortunately.
It seems it'd still be good to have an Entity.listen_event, simply because it exposes all of the data of the event.
Example:
def my_cb(self, event_name, data, kwargs):
#now I can get the time and the user_id so that I can filter.
user_id = data["metadata"]["context"].get("user_id", None)
time_fired = self.convert_utc(data["metadata"]["time_fired"])
I can't do that with listen_state
def my_cb(self, entity, attribute, old, new, kwargs):
pass