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
[feature request] - additional token for the last part of the topic name #4
Comments
I am not sure why you need this. The complete topic is returned (also when using + in the trigger card). And what if you have multiple wildcards in a topic. A generic implementation is not that easy. But if you want to hack yourself, you can check https://github.com/scanno/nl.scanno.mqtt/blob/beta/triggers.js#L88 You will need to add the parsing here |
Hi Scanno,
I know, but for my purposes what I need in the token is just the last part “Humidity”, “Pressure” etc.
I’ll give it another go this evening to see if I can get it work.
Best Peter
…Sent from my iPhone
On 1 Apr 2018, at 13:16, scanno ***@***.***> wrote:
There is no need to split the topic. The topic is already split apart when trying to figure out if the received topic matches one of the triggers.
But i am not sure why you need this. The complete topic is returned (also when using + in the trigger card).
So if you register /ESP_Easy/Sensor_name/+ as topic, the current topic token will return /ESP_Easy/Sensor_name/Humidity,
/ESP_Easy/Sensor_name/Temperature or
/ESP_Easy/Sensor_name/Pressure
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I managed to make it work. If you're interested, I can create a Pull Request Here it is: #5 |
Sure, then I can take a look at it. |
Is this still actual? |
Would it be possible to create an additional token, that contains only the trailing part of the triggering topic?
That would make it possible to run a single wildcard flow for a sensor that spits out multiple measurements into multiple topics. For instance:
/ESP_Easy/Sensor_name/Humidity
/ESP_Easy/Sensor_name/Temperature
/ESP_Easy/Sensor_name/Pressure
If these topics are watched as "/ESP_Easy/Sensor_name/+", the "trailing part" tag would contain the measurement name, while the "message" tag contains the measured value.
I tried hacking this myself, by creating an additional token in the app.json and processing the topic string in messagehandling.js with topic.split, followed by a pop() to get the last element. But my programming skills fall short, I am afraid.
The text was updated successfully, but these errors were encountered: