-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
MQTT Switch: add availability_topic for online/offline status #8593
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
Conversation
@pvizeli It is not really a protocol quirk since it can be implemented using the Last Will and Birth messages which are part of the MQTT protocol. Any device which implements Birth and Last Will messages will work with this. What do you mean by "add this into core for 1 device"? I'm not sure I understand, sorry. There are other devices which show as "unavailable" when they go offline. |
Any MQTT devices built on top of "Homie" framework support online status reporting out of the box... I have a few DIY switches built with it, I think this is a worthwhile addition, it's not only about Espurna devices. |
Tests added. Hope all is good now. |
@abmantis, that was not a personal attack. We need to be care, that the code stay clean to all other user of home-assistant. So we ask questions and discuss over functions... |
Yes I understand that. I didn't thought it was an attack. You guys do a great work keeping the platform moving forward and I understand that not every contribution should be accepted. No worries! :-) |
i like this very much and it works quite well. my tasmota sonoff sends "Offline" and "Online" as last will and birth message. to test this feature i hardcoded these values into mqtt.py. it would be nice to be able to configure the
and i think this feature would be nice on a broader range, adding it to mqtt light would probably be the easiest, but also other light components suffer from unavailable lights, such as the hue or tradfri components. the ikea app manages to mark lights as unavailable, if they are cut from current, as does the hue app. if the components could be expanded to query the availability of lights, this would be a nice addition. |
@abmantis I was trying to replicate your availability setup for mqtt binary sensor and I'm struggling to find the location in the code where you added the CONF_AVAILABILITY_TOPIC as an option for voluptuous, so chances are that this part could have been missed eventually. Btw. are you planning to implement the "availability_topic" for other mqtt components as well ? |
@pezinek I didn't knew that I should add it as an option for voluptuous! 😟 It is needed for validation, right? I'll make a PR with it. I only have mqtt switches ATM, so I would not be able to test other mqtt components. |
…ssistant#8593) * mqtt switch: add availability_topic for online/offline status * fix method doc strings * MQTT Switch: add test
Description:
Some MQTT devices (for example, those with Espurna firmware) publish a message to a topic when the device is online, and have specified a last will message to the same topic for when going offline. This PR allows using those to set the switch to "unavailable" on the front end when it is offline.
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#3034
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests pass