Hi all,
I started developing a simple add-on module for Home Assistant, able to use a USB radio gateway for Hardwario products.
The kick-off version is available on my GitHub.
What I would like to discuss here, where is the best place for HA MQTT “autodiscovery” feature.
Here is how it works:
HA is expecting MQTT special topic with JSON as configuration.
Unique_id has to he unique identification of the element
state_topic is the MQTT topic as it is being sent to the MQTT broker
This MQTT message must be sent with the “retain” option set.
For me, it would make sense to build a custom script to send all auto-discover MQTT messages to the broker after startup, however, “state_topic” needs to be known from the USB radio dongle for all paired devices. How we can get information from USB dongle about all paired devices and it’s topics including device type? Each device type can have hardcoded device classes and units of measurement, that could be used for auto-discover JSON build.
In the USB dongle’s EEPROM there is a list of paired nodes, and also aliases are saved there.
Alias looks like lcd-thermostat:0, lcd-thermostat:1,… so it gives you some info what type of device you have. However if user renames this alias, you have no idea what this device is.
But bcg also displays firmware. This information is handled by bcg and it is cached in bcg config/cache. This firmware information is send after power-up of the node together with pairing command. So to have this information in bcg you have to at least once pair or reboot the node while the bcg is running so it will catch firmware type and save it.
You can get nodes by sending this mqtt command with null (or any) topic
Unfortunately the node or dongle does not report or remembers what topics device responds. So this will have to be handled by your script. Most probably the script will have to look for firmware and based on that it will have table of topics that firmware reports and units.
Is there any list of available “firmware” and its corresponding values? This would make sense to implement an external script and send auto-discovery based on a static library.