-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 topics problems in latest mega branch #2866
Comments
I never noticed it, probably because my broker trims the spaces, but it's indeed happenning. |
@crnjan good catch by the way |
this will fix it:
|
see #2867 |
Hey! Thx for the prompt response. My only comment about the fix is that topic can actually contain spaces ... not sure if someone uses that in practice, but standard allows them ...
Taken from here. |
It shouldn't be fixed there, but in the place where it is called. I will make a patch for it, as topics obviously don't need to have trailing spaces, so it makes sense to sanitize the topics in the MQTT related code. |
When trimming the topic, it removes only the leading and trailing spaces. |
The extra padding to a minimal line length does only make sense for use on displays and some special formatting. So the majority of the uses of parseTemplate now uses 0 as minimum line length. Fixes: letscontrolit#2866 Closes: letscontrolit#2867 (superseeds PR)
I too think that topics with trailing/leading spaces are not really used in practice. Thx for the fix, will give it a spin over the weekend! |
Hi!
I'm working on a new plugin and noticed strange behaviour in latest develop (while being fine in last pre-release).
Long story short - when using CPLUGIN_005 (Home Assistant (openHAB) MQTT) to publish messages to broker, in latest develop the topic is not correct.
I.e. in my setup the topic should be
"ESP_Easy/xxx/MitsubishiHeatPump"
but its send as
"ESP_Easy/xxx/MitsubishiHeatPump "
(notice the space at the end). I checked what could be the issue and my guess is that change here is the problem.
So
parseTemplate
pads spaces at the end to match length:but when we call the
parseTemplate
fromparseControllerVariables
, it still contains the placeholder%sysname%
:"%sysname%/xxx/%valname%"
which is replaced with "ESP_Easy" within the
parseTemplate
function and since "ESP_Easy" has 8 chars (compared to "%sysname%" with 9 chars),parseTemplate
will append a space to the end:"ESP_Easy/xxx/%valname% "
(notice the space at the end). Publisher will use this topic (with extra space) to publish the message ...
Hopefully my explanation makes sense :)
The text was updated successfully, but these errors were encountered: