ESPHome homeassistant.event

How do I create a homeassistant.event from a lambda expression (script) in Esphome? And how do I send the data with it?

Yes, I know about that method.
But I have a lambda (c++ code) in which I want to start an event. How do I do that?

Found it after a little digging in the source code files:

        auto capi = new esphome::api::CustomAPIDevice();
        capi->fire_homeassistant_event("esphome.touch1_event", 
                                       {{"channel", ch},{"data", onoff}});

I don’t know if this is the official way, but it works.

1 Like