alsm / freeboard-mqtt

MQTT and IBM IoT Foundation plugins for freeboard.io
Eclipse Public License 1.0
60 stars 26 forks source link

Multiple topic from single mqtt client #4

Closed microspace closed 9 years ago

microspace commented 9 years ago

A remote controller publishes three topics to mosquitto broker: /board/temperature, /board/potentiometer, /board/soundlevel. In "the topic to subscribe to" I put "/board/#. In gauge setting I wrote datasources["data"]["msg"]. Now all three topics are diplayed in the same guage and create. I want to display received data in three gauges. How to do this with creating single data source? Thank you for your help.

psorowka commented 9 years ago

There are currently two possibilities to do that.

1. Stay with a single data source and your subscription "/board/#"

Assuming your data source is called "BOARD"

In the particular widget settings, you can then open the JS editor and put:

if(datasources["BOARD"]["topic"].match(/temperature$/)) return datasources["BOARD"]["msg"]

so you will only display msgs from the "temperature" topic in this widget.

2. setup one datasource for each topic

In this scenario you would add three distinct datasources and subscribe directly to /board/temperature

Although this is a bit more userfriendly approach, this variant seemed to be not stable when loading a saved board.

microspace commented 9 years ago

Thank you! First possibility suits me.