-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add option to use MQTT abbreviations #2641
Add option to use MQTT abbreviations #2641
Conversation
Happy with the changes, just cannot decide on default behaviour as both decisions make a change to existing behaviour |
The MQTT discovery stuff is fairly HA-specific anyway, so I don't think we need to worry too much about other software using it, so I would just default to enabling usage of abbreviations. |
One thing though, maybe it's better to use constexpr variables instead. That gives us namespacing and type checking, and from a quick look it compiles to the same. So e.g. constexpr const char* const ACTION_TOPIC = "action_topic"; |
Awesome, thanks! I've changed the defines to |
Only added breaking-change label so I know to mention it in next release just in case people are using the topics directly |
What does this implement/fix?
Adds the option to enable/disable abbreviations for MQTT Discovery. Using abbreviations frees up a small amount of flash, memory usage during discovery, and reduces network traffic ever so slightly.
MQTT abbreviations are enabled by default; this should work just fine with Home Assistant since the abbreviations in this PR have been adapted directly from HA source, however this will be a breaking change if used with other software that uses MQTT discovery but doesn't recognize these abbreviations.
Making this a non-breaking change is not as simple as disabling abbreviations by default, because the MQTT Climate component was already using abbreviations while other components were not.
If this PR is approved, I'll go ahead and update docs/tests.
Types of changes
Related issue or feature (if applicable): fixes
Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#
Test Environment
Example entry for
config.yaml
:# Example config.yaml
Checklist:
tests/
folder).If user exposed functionality or configuration variables are added/changed: