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
availability_topic for Home assistant #105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @phbasler !
Could you take a look at my suggestions and format the changes with black
?
Co-authored-by: Fabian Peter Hammerle <fabian@hammerle.me>
Co-authored-by: Fabian Peter Hammerle <fabian@hammerle.me>
Co-authored-by: Fabian Peter Hammerle <fabian@hammerle.me>
@fphammerle I applied the changes and formatted with black. I also changed the topic to end with "status" like suggested. |
Thank you! What happens if switchbot-mqtt shuts down gracefully? (planned disconnect) |
Shall we set |
@fphammerle Good idea with the retain message. I added the flags. Edit: It doesn't seem that you are calling the disconnect function of the mqtt client anywhere in your code, so it never exits with a clean disconnect |
Thank you! I expected |
released here: https://pypi.org/project/switchbot-mqtt/3.3.0/ |
…will on `homeassistant/switchbot_mqtt/status`) partially reverts commit 9947875 #106 (comment) #105
With this PR a Birth message and a Will message is set.
Upon connection the message "online" is published to switchbot_mqtt/availability and upon loosing connection (KeepAlve Timeout or job was killed) the Will publishes "offline" to the same topic.
For the mqtt sensors in home assistant you can set the availability_topic to this topic and then you can check if the service is running or not.
If you want we could add a CLI Option to set this topic to have different topics for multiple Instances.