add mqtt module #2
Loading…
Reference in a new issue
No description provided.
Delete branch "accumulator/btclock_v3:mqtt_dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add support for publishing device stats to MQTT. See also
webui
pull request.Using this data in HomeAssistant requires some configuration (Note: there is an option to autoconfigure the settings below in HomeAssistant by publishing to a certain
/config
topic, but that is not done in this PR as I don't want to make the implementation specific for a consumer)This is the snippet I use
a2217bf52b
toadf6b38bfb
Thanks for your PR! Very happy to see that you implemented it in the right locations and that you also updated the WebUI for it, good job!
I looked at it and I was wondering whether you also considered elims/PsychicMqttClient, since the library you now use hasn't been updated for 4 years and doesn't have SSL support which I think is desirable.
There are multiple supported targets, the Rev.A board doesn't have frontlight and no light sensor. When I tried to compile for the Rev.A target there were some errors because hasLightLevel() is not defined. You can add a guard to handle this:
I think it's also good to just add a MQTT_HOST default to the defaults file, just for consistency.
I took the MQTT client that is also used in the meshtastic project.
Not sure how SSL is handled in the ESP32 world, but I got the impression that there's a generic 'socket like wrapper' for secure connections in the form of
WifiClientSecure
(vsWifiClient
for non-ssl)?Ah yes.. I disabled building the other targets to speed up my testing :) will add.
Will add.
Instead of adding a SSL switch and user, password, port number fields in the config, I'd like to use a URL field (e.g.
mqtt://user:pass@host:port
ormqtts://user:pass@host:port
). Do you know of a lib that can parse the URL and return its components?You could use
mqttString.startsWith("mqtts://")
to check for SSL, and if so you could set the SSL certificate bundle similar like I do here:client.setCACertBundle(rootca_crt_bundle_start);
No, the point is to allow user, password, hostname, port number, ssl in a single config parameter, so I need to extract all these fields. simply testing with
.startsWith
is insufficient for anything beyond whether to use ssl.In the meantime I hacked together a simple generic url parser that does just this, so stay tuned.
ee81edbcd2
tofa705e45e8
updated using
elims/PsychicMqttClient
, but this has compile problems, due toESP_IDF_VERSION_MAJOR
not being supported correctly.Leaving this PR for now, as this is taking way too much time.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.