smarthomeNG / smarthome

Device integration platform for your smart home
https://www.smarthomeNG.de
GNU General Public License v3.0
121 stars 92 forks source link

mqtt: birth_topic timing #482

Closed chester4444 closed 1 year ago

chester4444 commented 2 years ago

I have recently upgraded smarthomeNG and now i am using the new MQTT module/plugin. Basically everything works smooth, but there is a small issue with the birth-message.

I use the birth-message (smarthomeNG/start) to broadcast to all my MQTT nodes to tell them they should send in their current status via MQTT (since smarthomeNG just started up).

The birth-message is sent, but it seems the plugin didnt have subscribed to all the MQTT - topics where the nodes reply and so the messages are lost. (retained messages dont makes sense here). When i send the birth-message manually after startup (with mosquitto_pub), everything works as intended.

Maybe someone can point me in a proper direction, how/where to fix this.

My current workaround is a logic (init+2) sending an extra item connected to the birth_topic.

msinn commented 2 years ago

The birth message is sent, when the mqtt module starts working during the initialization of SmartHomeNG.

Subscriptions to topics can only take place afterwards. All subscriptions (from items or from logics) take place after the initialization is finished in the run-phase form SmartHomeNG.

The birth message of the cannot be used for what you are trying to do. For that, you should create your own "I am listening"-message and send it, after all the initialization is done. It is probably the best to implement it in a logic. This way, you have full control, when the message is sent.