Before I code this and submit a pull request, I’d like to toss this idea out to the devs and get a nod before I do it.
I would like to add an optional parameter to core.py, async_set, async_remove, set, and remove called context and then pass that context to the async_fire(EVENT_STATE_CHANGED…) line. I would also need to be able to pass it thru the async_call (to the services).
I’m not sure how large the scope of this change would be.
Why?
I am writing my own Alexa smart home controller and I want to implement the real time reporting capabilities. I also want to respond to Alexa synchronously.
If I say “Alexa, turn on the lights”, then I’ll do it and respond synchronously and the state will be updated in Alexa. If I turn on the lights thru HA or the local switch, I need to monitor EVENT_STATE_CHANGED and then call into their reporting API.
I need to be able to know the difference between my component causing the EVENT_STATE_CHANGED being called, vs something else. I could call the service/set and pass along something in the context. Then in my listener for the event, I can evaluate the context and selectively ignore the event.
Thoughts?