-
Notifications
You must be signed in to change notification settings - Fork 9
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
Distinguish between multiple Gateways #2
Comments
This is actually part of something I've been thinking about having as a feature where certain configuration options would support go templates which could use certain values, such as user-configurable parsing a part of the topic to use in the additional_tags like you described, and some "built-in" ones such as the RuuviBridge version. I was thinking about using regexp with capturing groups for the "parsing configuration". Basically the idea I had in mind was to parse and extract arbitrary portions of the topic with a config something like this (this example having the idea that you'd have multiple "locations" and each "location" would have one or more gateways):
And then the additional_tags can be configured as go templates like this:
where the named capturing groups from the In the future the parsed variables could also be used in other future features, such as supporting similar templating in the I'd like to "get this right" on the first time in order to avoid breaking changes in the future, so this should be carefully planned and thought out before implementing. Thoughts? |
I like your suggestion! While thinking about this idea, I had a similar solution in my mind: Define the topic pattern and let it match parts of it into variables. I didn't suggest this idea because I thought we could also define a pre-defined topic pattern to make it easier in the first place. But your suggestion makes it quite dynamic and opens it up for future ideas not having thought of right now. I'd definitively use this pattern to only run one RuuviBridge for the multiple gateways I have (in various forms). |
Hmm, a "more simple" topic pattern would be much more trivial to configure, especially for users with less regexp knowledge. I like that idea. I wonder if there's any realistic case where a simple pattern match wouldn't be sufficient. Perhaps something like:
which would be internally compiled into a regexp that creates named matching groups for those $variables as well as creating the mqtt subscription, Then in case topic_pattern is not defined, the "existing" |
That would make it even easier to use. While I would be able to write a regexp, I could imagine that just seeing "regexp" could make people think of it to be too complicated. This new proposed pattern is very readable and probably also easily understandable. |
Yeah, exactly, and on top of that using a pattern like this reduces the amount of config compared to the regexp version since the topic pattern would simply replace the topic prefix. Although technically you could create a mqtt subscription based on the regexp, but that'd be much more work than it's worth. And also if the underlying implementation already uses regexp, adding a regexp-config later on would be relatively easy if someone comes up with a weird use-case where a simple pattern match wouldn't be advanced enough. I guess we should wait for a bit now in case someone else happens to be reading around here and has some ideas. Or in case one of us comes up with even better ideas |
I think it would be cool to get that one implemented, doesn't seem that anyone else had a better idea. |
I suppose so. Would you be willing to implement this? |
I must admit that I lack the needed Go know how and time. If I find time to learn more, I'm willing to do it. I'll get back to you with a PR when I have one. |
Currently, there is no way to distinguish between multiple gateways, rather than running multiple instances of RuuviBridge (what I currently do and works). I'd like to suggest teaching RuuviBridge to distinguish between multiple Gateways.
An example could be:
(That's just a partial config to show the idea)
This approach would make it mandatory to configure the Gateways to publish to a predefined format:
We could also find a way to make the topic format configurable, if desired.
What do you think about this idea? I'm open to refine it if needed.
The text was updated successfully, but these errors were encountered: