Hardwario Home Assistant integration

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.

The autodiscovery topic

<discovery_prefix>//[<node_id>/]<object_id>/config

In my case I use:

homeassistant/sensor/air-quality-monitor0-co2/monitor1/config

JSON payload

{ “name”: “CO2 Climate monitor 1”, “device_class”: “carbon_dioxide”, “state_topic”: “node/air-quality-monitor:0/co2-meter/-/concentration”, “unique_id”: “air-quality-monitor0-co2”, “unit_of_measurement”: “ppm” }

  • The device class for sensors is listed here.
  • 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.

Hi Marian,

there are few options how to get device type.

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

2022-01-04 10:25:31.06 gateway/usb-dongle/nodes/get null

and you get response including firmware and version.

2022-01-04 10:25:31.07 gateway/usb-dongle/nodes [{"id": "294b9f639a4f", "alias": "lcd-thermostat:0", "firmware": "kit-lcd-thermostat", "version": "v1.4.0"}]

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.

Excellent, thank you Martin.

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.

There is no list of topics in firmwares. You have to check code for every project.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.