jomjol / AI-on-the-edge-device

Easy to use device for connecting "old" measuring units (water, power, gas, ...) to the digital world
https://jomjol.github.io/AI-on-the-edge-device-docs/
5.26k stars 580 forks source link

homeassistant service discovery: derive node_id when using nested topics #3088

Closed henrythasler closed 1 month ago

henrythasler commented 1 month ago

homeassistant needs the MQTT discovery topic according to the following structure: <discovery_prefix>/<component>/[<node_id>/]<object_id>/config If the main topic is embedded in a nested structure, we just use the last part as node_id. This means a maintopic home/test/watermeter is transformed to the discovery topic homeassistant/sensor/watermeter/...

fixes #1792

caco3 commented 1 month ago

Do I see it right that this change only has an impact on devices which have a / in the maintopic? Or will it break existing systems?

caco3 commented 1 month ago

And can you also extend the documentation at https://github.com/jomjol/AI-on-the-edge-device/blob/rolling/param-docs/parameter-pages/MQTT/MainTopic.md please?

henrythasler commented 1 month ago

Do I see it right that this change only has an impact on devices which have a / in the maintopic? Or will it break existing systems?

It does only impact topics with multiple levels. To make this more clear, I have added a unit-test.

henrythasler commented 1 month ago

And can you also extend the documentation at https://github.com/jomjol/AI-on-the-edge-device/blob/rolling/param-docs/parameter-pages/MQTT/MainTopic.md please?

Done

caco3 commented 1 month ago

Thanks!

Seems to work well: grafik


grafik