-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: MQTT Birth implementation #418
Comments
Hi Eric, The 1.9.0 dev branches support MQTT LWT, which sends a message to a specified topic when the device disconnects. There is not currently a way to send a message when first connecting, but that wouldn't be terribly hard to add. |
Thanks @sidoh. I believe the feature is call MQTT Birth https://www.home-assistant.io/docs/mqtt/birth_will/ I'll rename the title for sake of clarity. |
This is released in 1.9.0-dev10. |
Thanks, I'll give a try this week and provide feedback. |
E.g. tasmota by default uses the LWT to inform about the online and offline status. I personally found this helpfull, but afai can see, there's no option to configure a "opposit to LWT" message. So is there an option to add also a online LWT message when the hub is connecting to the broker to revoke e.g. "offline"? |
Yes, it's in the 1.9.0 branch, as mentioned above. Try the RC release: https://github.com/sidoh/esp8266_milight_hub/releases/tag/1.9.0-rc2 |
My remark already refferenced to version 1.9.0-rc2. Both message types (LWT and birth messages) are great! But one has to "clean up" the LWT message "manually" on the HA controller side (may be different in HASS), as there is only one message to the LWT topic, but not a second, indicating the hub is online again. This one (birth) is to a different topic and in a different structure - single word payload (or whatever is configured) vs. JSON. |
Okay, I understand the suggestion now. But not sure I see the value. Why should it be the same topic? Why should it have the same structure? Is this some standard that I'm not aware of? If it's a broad thing that many MQTT integrations do, happy to consider it. If it's just a particular arbitrary way of doing things, I think I'll probably pass. |
Same topic, same structure: My HA software expects the same type (JSON/non-JSON), otherwise I have to add a more complex message treatment (which is possible).
So imo the tasmota implementation - just sending "Online" and "Offline" seems to be very close to the inventor's description of the intended behaviour. On the other hand, at least imo, there's no need to make the LWT message configurably at all, if, an option to manipulate the time before LWT (when disconneted) is sent used by the broker. |
Ah ok, I see the rationale. It's a single topic that indicates device status. That is nicer. What if I change this to have a single topic used for LWT, birth, disconnects, etc.? It could have all of the same information that the birth message does (with IP address, firmware version, etc.), and also include a "status" field which could be one of How does this sound? |
No need for end-users to configure things twice, plus additional info privided. |
Live in 1.9.0-rc3: https://github.com/sidoh/esp8266_milight_hub/releases/tag/1.9.0-rc3 |
Thank you for the suggestion! |
Thanks a lot for implemeting that fast! |
This looks quiet nice. But sadly, Homeassistant does not support extracting values from json when it comes to availability. To use this with HA flawlessly, a predictable payload to a fixed topic is required (e.g. "ON" or "OFF").
|
Yeah, I noticed this as well. It probably should support templates for this, but I don't have the bandwidth to open a PR for it right now. I'll add a setting to support simple client status messages (will just hardcode "connected" and "disconnected"). |
Great, this worked out quiet well. |
Hi,
Using Home Assistant HASSIO and MQTT pluging, I'm trying to find a way to trigger when Milight_hub connect/reconnect to the MQTT server to assigned an automation task.
Is it possible for the device to announce himself in a specific topic? Unless there is already a feature in MQTT Mosquitto I didn't saw.
Thanks
Eric
The text was updated successfully, but these errors were encountered: