Add MQTT homeassistant sensors for air quality#13
Add MQTT homeassistant sensors for air quality#13glenrobertson wants to merge 29 commits intogoat-hill:masterfrom
Conversation
|
Thanks! Did a quick first pass just looking at code. I'll have to do a closer look running on device and testing it out. Specifically memory usage, and backwards compatibility with the web app. |
|
Blocking things to test: (I can help with this too)
Non-blocking things to figure out:
|
|
Keeping some notes here. If you connect the new web UI to an old bitclock FW version, you will see:
If you try to set the MQTT url: Other changes seem to work. So I think this is fine but would be nice to branch instead of error if it detects an old firmware version. But I'd need to reveal that somehow. |
|
If you update to new FW, and connect with new web UI, it initially doesn't work at all https://github.com/goat-hill/bitclock/tree/master/bitclock-fw#bluetooth-gatt-attributes Once you "Forget this device" and re-pair there are no errors. But something to think about communicating if people update. |
|
Annoyingly I think we're running out of memory when parsing the weather API now with cJSON. I bet we were close to the limit and this MQTT stuff pushed us over :( I'll have to poke around for ways to reduce memory usage. |
|
Had to throw a ton of changes in here, mostly because the weather API is extremely expensive to the heap right now. It uses about 30kB via the cJSON library to parse the 17kB giant response from api.weather.gov. I made a bunch of other tweaks in my testing that leaves about 3kB worst case of extra headroom. Not great because a small weather.api.gov change could push things over the limit. Long term fix would be to use a streaming parser of JSON instead of a one-shot one. Those are harder to implement but way less memory intensive. https://components.espressif.com/components/espressif/jsmn instead of cJSON |
|
I merged in master which should hopefully give this PR enough memory headroom since it was improved there. |
…/bitclock into mqtt-homeassistant-sensors
238e76a to
da0c7b6
Compare

Adds support for homeassistant sensor discovery and state reporting via MQTT
mqtt://user:password@mqtt.example.com)Notes:
Relevant home assistant docs for MQTT based sensor discovery:
Testing:
Blocking things to test:
Non-blocking things to figure out: