mqtt-datasource
mqtt-datasource copied to clipboard
Question: When using a wildcard, how can I split the values
Good day,
I am using this plugin to display live data. I can get it to display multiple values when the message is json and contains a name/value pair for each metric. However I also tried to subscribe to this:
Home/+/+/+/power/#
Messages contain electric power consumption per device, of example:
Home/fibaro/fibaro/WashingMachine/power/float 35.53 Home/fibaro/fibaro/Freezer/power/float 0.4
However, in a graph these are all displayed as "value", not as separate values per topic. Ideally, I would want to display the values as "WashingMachine" and "Freezer". But complete topic will do also. Might be possible to split that up with a regex or something.
Is there a way to split the values based on the topic name?
This is also an issue for the Sonoff 4-channel devices I'm using as irrigation controllers. The topic irrigation/bees-knees/relay/+ has 0-3 and I'd like to use transformers to show the status of each (and show a name). I'm not able to use separate queries either, as the datasource doesn't pass the query name. All transformers just show a Time and Value field - no Series, etc. is available.
Currently the plugin sdk does not allow to return series. I already digged into this and could find a solution. The only thing that can be added, would be the topic to the field name. Should not be that hard. If someone implements that, making this an opt in option in the query editor might be nessecary to avoid breaking changes.