dawidchyrzynski / arduino-home-assistant

ArduinoHA allows to integrate an Arduino/ESP based device with Home Assistant using MQTT.
https://dawidchyrzynski.github.io/arduino-home-assistant/
GNU Affero General Public License v3.0
463 stars 112 forks source link

Availability topic doesn't change with data topic #234

Closed f-hnt closed 2 months ago

f-hnt commented 5 months ago

Availability topic doesn't change with data topic and stays at the default "aha".

By setting the data topic in the setup section with: mqtt.setDataPrefix("DataTopic"); the availability of the device is being reported in "aha" topic. States, data, etc. are correctly reported in "DataTopic"

Is this a normal behavior? I expected after changing the data data topic, the MQTT structure to be like that:

Data: DataTopic/UniqueID/switch1/....

Availability: DataTopic/UniqueID/avty_t

dawidchyrzynski commented 2 months ago

Hi @f-hnt,

The setDataPrefix method must be called before enableSharedAvailability. Please let me know if it solves your problem.

f-hnt commented 2 months ago

It worked. Thank you a lot :)