1. Overwiew
I build ESP32 and ESP8266 devices that talk over MQTT to OpenHAB.
My ESP devices usually have items like measurements, intelligence diagnostics, and settings that get saved in EEPROM.
Readings are combined in cluster messages in a few channels to conserve CPU on ESP while sending.
They do not meet the JSON standard, but REGEX appears to be fine for messages like this from mqtt explorer:
My simple standardized device:
Roleta_Matej // rollsershutters
// readings
Status = Gor: 0; Dol: 0; Stop: 0; Premik: 30; Korak: 20; LPF_Rolete: 0; LPF_Luc1: 0; LPF_Luc2: 0; Rssi:-81; T: nan; V: nan; Cmd_Luc1: 0; Cmd_Luc2: 0;Status_Dol = 0 // runs down
Status_Gor = 0 // runs up
Status_Stop = 0
Ukaz_Korak_Dol = 20 // time command down
Ukaz_Korak_Gor = 20 // time command up
2.Autodiscovery and data parsing
I know of home assistant autodiscovery in OH, others are too complicated.
When I started I did parsing with rules, the way I knew, not a clean way but it still works.
Now I want to move over to REGEX or JSON for new devices as Rich recommended.
I avoided JSON as it encapsulates text in " " that interferes with " " of the string syntax in Arduino, you need additional characters to fix it, and JSON libraries waste lots of ram on Arduinos,on ESP32 is fine.
3. MQTT to OH Builder
My uncle writen OH Builder in visual basic to build things, items, rules and sitemap file to integrate new ESP device based on MQTT messages the device published to MQTT.
It creates basic dacboard on sitemap.
Now it time to upgrade Builder to REGEX and JSON, it could also be brought over to other script like bash.
If anyone else has similar requirements for integrating ESP devices in openhab, i appticiate recommendations and examples on how to build it properly.
4. Arduino MQTT to HA autodiscovery
Esentially there is probably interest for arduino library for OpenHab over MQTT, that also supports HA autodiscovery so we don’t reinvent the wheel.
I even cant find arduino library for HomeAssistant over MQTT, how is that possible? Like other is JSON library, but the autodiscovery part is missing for HA, that OH seems to support, hopefully a custom device.
5. Discovered items into Sitemaps
Then there could be addition of a script that is run besides OH or a new Addon to automatically make new configs from MQTT for items and sitemaps, possibly someday also rules for typical automation.
6.Plans
I will add more bellow, like OH Builder scripts and example Arduino Code to rewiew and give insight, so others can see and we get inspired on what the solution may look like.
For now that’s it, i will continue when time allows.
Cheers
Matej