Hi,
I’ve already asked this on the ESPHome Discord and had no reply, I realised it’s quite a technical question and may be more related to Home Assistant development practices.
It’s about the use of serial proxy from within Home Assistant and using the ESPHome Client API. The ESPHome integration does not currently expose a “serial proxy” as an entity, although from what I’ve read recently that may change with serialx.
In my custom integration do I:
A) Create my own APIClient that is standalone from the ESPHome Integration, with all the reconnection ReconnectLogic baggage, keys, reauth etc that goes with it, or
B) Get the ESPHOME domain config entries hass.config_entries.async_entries("esphome") , search through them for a match to the IP address I’d like to use and then grab the client from the RuntimeEntryData, also using the available bool state in there and hooking in to the async_subscribe_device_updated callback. Is it OK to look through the runtime of another integration and hijack the API client?
I’ve already prototyped both and have them working but the standalone A) APIClient has lots of baggage with reconnections and I think it might be conflicting with the ESPHome integration doing the same. I am using ReconnectLogic class but I don’t get on_connect and on_disconnect calls to match.
The indirect method B) - well it just works, the callback I have looks at the RuntimeEntryData available flag. I can post code snippets if that helps. Any help or advice would be much appreciated, thanks