Hello All,
n00b Question here: I am working on creating an esp3266 board that will integrate with my Aqualogic Pool Controller. My question is, what is the best way to integrate with Home Assistant? I know that you can do MQTT, Rest API’s, Websockets, etc. etc. But I am not sure which is “the Best”. And By best, I mean, which is the most responsive, easiest to integrate, etc. I have read through a lot of the Home Assistant Developer Documentation, but that talks from the HA side out, and I am looking to see if I should code the board to speak Rest, MQTT, or Websockets, or something else. Any thoughts or opinions would be greatly appreciated!
The short story is, I currently have an RS-485 to Ethernet bridge adapter configured, and then I am using swilson’s aqualogic python library to read the serial output over the wire, and then decode the data from it. The issue that I am running into is that it stops working after a few hours, and sometimes it doesn’t send the commands, and sometimes it doesn’t update the app on my phone, etc. So what I wanted to do was to move the decoding logic onto the board so that it is hard wired into the serial port so there won’t be any latency between the commands being sent over ethernet/wifi. I know that the esp-link library supports serial to wifi bridge, and mqtt, etc. etc. but I think it’s a straight pass through, where as I need to interpret the data first so it’s not as simple as just toggling the I/O ports or reading raw data from a sensor.
I am still looking into other options (like the esp-link which I may fork for the serial bridge code from), and I will take a peak at the esphome to see what options that gives me. But based on my description above, does ESPHome sound like a fit still?
If you are already using python, I’d say go for mqtt. While it does require an external broker, it is extremely easy to set up a mosquitto docker container for that, and using paho to send and receive mqtt messages in python is also basically done with 5 lines of code.
It will give you the flexibility to both send data to HA, and send commands back to the device you are building, with a minimum of work.
Using mqtt you can also have the device auto generate sensors, switches etc in HA for you, so you don’t need to create those manually.
The code that I am writing is actually c++ not Python (I am looking to move the python logic to the board that is direct attached to remove latency, etc.), but there are libraries for mqtt that I can look at. That’s interesting that using mqtt can auto generate sensors. I already added mdns code to make it discover-able through zeroconf, so that would be awesome if it could auto-generate the sensors, etc. too. Do you happen to know of a link to where I could look that info up so I can integrate into my board?