-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
MQTT Discovery improvement proposals #70
Comments
CC @fabaff as you have been working on discovery. |
I personally think 1-2 are fine. I think that a reconfigure / removal could be accomplished by either having the resulting MQTT entity listen to MQTT directly, or have it listen to updates from discovery via the dispatcher.
If you plan on opening PRs to support this, please limit each PR to one of the issues. |
@balloob Thanks for comments! And yeah, I was planning to open PRs.
Can you explain this in some more detail please? |
Reconfiguration of a device means in a lot of cases that the topics will change too because it's no longer a switch but a light (if I understand you right in 1.). Now, comes the tricky part: If the domain is changed (e.g. from It will more be "remove an old device and add a new one" with one hiccup: The new device doesn't know the original As long as the device is in the same domain would it be nice to be able to update the attributes and alike.
Devices with the same $ mosquitto_pub -h 127.0.0.1 -p 1883 -u homeassistant -P test123 -t "home/binary_sensor/garden/config" -m '{"name": "garden", "device_class": "motion"}' -V mqttv311
$ mosquitto_pub -h 127.0.0.1 -p 1883 -u homeassistant -P test123 -t "home/binary_sensor/garden1/config" -m '{"name": "garden", "device_class": "motion"}' -V mqttv311 With this will give you two sensor with the name "garden".
This sounds like an issue that should be solved by Tasmota and not Home Assistant. It's a common problem that PubSubClient and other MQTT libs are limiting the payload size (see But if there is an easy way with only a little maintenance we can try to use some sort of mapping to make it easier to integrate implementation which are limited or upstream refused to make the needed changes. |
If you're limiting to 128 chars, writing |
Yes, I hope to push a proposal during the weekend unless someone else wants to do it? |
@fabaff Thanks for comments!
Aha, you're right! I have seen an issue with not all devices being discovered and I though it was related to the name being the same, but it must be something different. I removed 3. from the description. |
@emontnemery, can you please post the payload of the discovery message that is send by Sonoff-Tasmota to the config topic? While looking at home-assistant/core#16635 it seems that I didn't get the point. |
@fabaff Sure, here's an example of configuration data for an RGBWW light:
Example of shortened payload (717 bytes) as per current proposal in home-assistant/core#16635:
|
@emontnemery It sounds like adding a topic prefix, which would be set to Code would do something like check if the topic prefix exists, prepend it to all of the topics received in the discovery payload. If it doesn't exist, no change. |
In my experience, the limited payload size can easily be fixed on most platforms by using more sophisticated MQTT libraries/solutions. For example, esphomelib streams all its MQTT packets to work around the limited TX buffer size on some MPUs. So for bigger frameworks like tasmota that should be the solution. Of course, most DIY developers use libraries like pubsubclient that have hard limits on the maximum packet size (for example 128 bytes). But I think most of those people will: a) not use discovery as implementing discovery is way harder to do than just adding a few lines to your YAML config and Another thing is that this 128 byte max packet size is only really a problem for one platform:
Btw, tasmota could easily get to {
"platform": "mqtt_json",
"brightness": true,
"rgb": true,
"color_temp": true,
"name": "Sonoff B1",
"availability_topic": "tasmota/sonoff_9D3B0B/tele/LWT",
"state_topic": "tasmota/sonoff_9D3B0B/stat/json",
"command_topic": "tasmota/sonoff_9D3B0B/tele/json"
} Please correct me if I'm wrong but in my view topic prefixes/abbreviated keys would definitely reduce the payload length, but:
And whole frameworks which tend to have bigger discovery payloads can easily work around the problem by choosing the MQTT library more wisely :) But 1&2 I would be very excited about :) |
Would it be an idea to introduce |
@balloob That's not a bad idea! Would something like this be acceptable for more flexibility:
|
No, that seems a bit too wild. If anything, maybe just Can't we have tasmota publish to the topic minus |
@balloob The main issue is that Tasmota doesn't have the platform type (sensor, light, switch) as a mandatory part of both in- and outgoing topics. Maybe something like this then:
|
@emontnemery that is pretty much what I was envisioning in terms of topic prefixes. I assume we would want to implement them in a backwards compatible way? I agree with @balloob, we should keep it to one ~. |
OK, updated home-assistant/core#16635 with topic prefix |
Closing this since all the proposals are now implemented. |
A few proposals for changes to MQTT discovery:
Support removal of previously discovered device when a (retained) discovery payload is cleared. This would be highly useful for devices such as "Sonoff Tasmota" which have some default configuration when flashing with official firmware (configured as a single switch) and which might have a completely different functionality after setup (e.g. an RGBWW LED dimmer light ). If acceptable, I'll finish what was started in PR Mqtt discovery remove core#11489.
PR: Remove discovered MQTT Switch device when discovery topic is cleared core#16605 + follow ups for other platforms
Support reconfiguration of a previously discovered device when the discovery payload is modified. The purpose is very similar to 1).
PR: Reconfigure MQTT binary_sensor component if discovery info is changed core#18169 + follow ups for other platforms
Do not reject multiple devices with same 'name' in the discovery message, again the purpose is better support for generic device binary without requiring a homeassistant restart after (re)configuration.Not an issue with MQTT discovery, this issue was caused by Reconfigure MQTT climate component if discovery info is changed core#18174.
The mqtt discovery protocol is very verbose, which is causing out-of-memory issues for memory constrained devices when sending the discovery message. An example is the "Sonoff-Tasmota" project, where it's not possible to add information about supported effects because it would not be possible to send the resulting very long discovery message.
A simple solution would be to support some common and documented abbreviations, such as '_topic' -> '_t', '_template'->'_tmp' etc in the discovery message.
PR: Support abbreviations in discovery topic core#16635
The text was updated successfully, but these errors were encountered: