You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while trying to realize a small project I noticed some pretty strange behavior with the on_topic decorator. I need to receive non-hermes mqtt messages and after I tried to figure out what the best way is to do that, I thought I might try it that way first.
Since it did work after I changed the temperature topic for the light one, I am pretty sure that it is the * in my topic that is the issue. According to the mqtt standard, only using + or # in a topic is not allowed, all other UTF-8 characters are fair game. Would it be possible to fix this?
I did some testing with escaping the * symbol when the regex is built and that got it to work, but I doubt my simple solution of replacing token + "$"with token.replace("*", "\*") + "$" in line 566 is a good solution. If this character causes problems when not escaped, others might too, so a more general approach of escaping characters might be the better solution for that.
Daenara
The text was updated successfully, but these errors were encountered:
Daenara
changed the title
app.on_topic decorator not working with special characters (* is the one I came across)
@app.on_topic decorator not working with special characters (* is the one I came across)
Jul 28, 2022
If we're not sure which other characters might cause problems, your solution is fine for me for now. We can deal with other problems later. Can you create a pull request and document the reason for escaping in the code?
Good Evening,
while trying to realize a small project I noticed some pretty strange behavior with the on_topic decorator. I need to receive non-hermes mqtt messages and after I tried to figure out what the best way is to do that, I thought I might try it that way first.
Here is what I tried:
Does not work (HermesApp: Unexpected topic: weather/inside/wohnzimmer/temperature_*C)
Works
Works
Since it did work after I changed the temperature topic for the light one, I am pretty sure that it is the * in my topic that is the issue. According to the mqtt standard, only using + or # in a topic is not allowed, all other UTF-8 characters are fair game. Would it be possible to fix this?
I did some testing with escaping the * symbol when the regex is built and that got it to work, but I doubt my simple solution of replacing
token + "$"
withtoken.replace("*", "\*") + "$"
in line 566 is a good solution. If this character causes problems when not escaped, others might too, so a more general approach of escaping characters might be the better solution for that.Daenara
The text was updated successfully, but these errors were encountered: