Dashing job to subscribe to MQTT messages.
MQTT is a lightweight publish/subscribe messaging transport. This job allows Dashing to subscribe to these messages and send them as events. There is no associated widget as the data can take any form - commonly numbers, but not necessarily. The script as laid out below sends events with value, current (the same contents) and last values so can be plugged directly into the Numbers or Meter widgets using the data-id in the dashboard file. The send_event could easily be modified if required.
Add to Gemfile:
gem 'mqtt', '>= 0.3.1'
Run
bundle
Then set your MQTT_SERVER and MQTT_TOPICS with associated tags.
I use MQTT to publish electricity usage and temperature from a CurrentCost device connected to a linux machine within my home network, hence the topics in the example job file. For the example topics, you could add the Numbers and/or Meter widgets:
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="watts" data-view="Number" data-title="Current Electricity Use" data-moreinfo="In watts" ></div>
</li>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="cctemp" data-view="Meter" data-title="Temperature" data-min="0" data-max="100"></div>
</li>
Looks and works great :)
But i have a question, it is possible to make two way communication? For example, clicking on widget publish something to mqtt?