ESPHome Home Assistant API Client?

As the title notes: is there a way to use the Home Assistant API directly from an ESPHome device to another ESPHome device - rather then depending on making REST API calls?

Would this be more efficient (since the whole point of the API is that is it is more efficient protobufs as I understand it?)

Do you mean the esphome API?

In short: No :x:
Esphome nodes only host the api server and don’t have a client component :bulb:

A better approach seems to be UDP :point_down:

Efficent in what way? What limitations do you face? :thinking:

I expect both - the REST and UDP approach actually being less resilent and more cumbersome compared to the native api :person_shrugging:

The primary limitation I’ve hit is the big warning message that the Arduino HTTP API is slow - but trying to version restrict that led to crashes.

The UDP component looks almost perfect, but it seems like I can’t fire an action to trigger an update message?

My use case is a presence sensor controlling a light (applies elsewhere too): when presence is active, poll the light status, if not on then send turn on messages till it is then be quiet till presence deactivates.

I want the light on as fast as possible, so periodic broadcasts are no use - but once it’s on we can save some airwaves till it’s off.

Currently I do it with REST, the ESPHome API is meant to be more efficient so maybe that, UDP would be great actually provided I could get some sort of RPC going (though that might not be too hard to hack in).

I have many esp devboards and many Shelly devices with stock firmware. They all communicate between each other through REST and all automations are done in Esphome.
In practice it works well, I only make requests 1/s though. Might fail if I try to request at ms intervals.