Draw a google visualization of mqtt data. Shortcode content should include an mqttcogs_data shortcode . See example


charttypeoptional, default ‘LineChart’. The google visualization chart type as shown here. Simple charts are supported, for example ‘LineChart’, ‘ColumnChart’.

optionsoptional javascript object literal, default ”. This is passed directly to google visualization draw method as defined here. Can be used to customize the chart. For example, for setting the legend and axes labels.

refresh_secs –  optional, default ”. The refresh interval for the chart in seconds. If not set, the chart will not be refreshed.

script –  optional, default ”. New version 2.2. This is a reference to a custom field that contains a javascript function. The function is used to manipulate the data client side before the chart is drawn. See here for a walk through of this attribute.


This Shortcode must contain a mqttcogs_data shortcode . This defines the data to be used in the visualization.


Show the last 100 data points for a single topic and set graph legends and titles.

[ mqttcogs_drawgoogle 
     options="{series: {0:{labelInLegend: 'Soil'}},
               title:'My graph',
               hAxis: { title: 'DateTime(UTC)',format:'d MMM HH:mm' },
               vAxis: { title: 'Temp (C)' }}" 
  [ mqttcogs_data limit="100" topics="mysensors_out/100/1/1/0/0"] 
[/mqttcogs_drawgoogle ]


Specifies the mqtt data used for drawing the visualization. Shortcode should be wrapped by a mqttcogs_drawgoogle shortcode. See example below


topics – required. A comma delimited list of topics to graph. Each topic ends up as a separate series on the final graph. For example, topics=”mysensors_out/100/1/1/0/0,mysensors_out/100/2/1/0/0″

limit optional, default ‘100’. The maxium number of data points to be returned for each topic

fromoptional, default ”. Either a negative number of days from now or a date & time in the format yyyy-mm-dd hh:mm:ss

to optional, default ”. Either a negative number of days from now or a date & time in the format yyyy-mm-dd hh:mm:ss

orderoptional, default ‘ASC’. Either ‘ASC’ or ‘DESC’

group – optional, default ”. New version 2.2. Applies grouping based on the MySQL EXTRACT() function.

aggregations – optional, default ”. New version 2.2. If a group is set, apply the aggregation to each grouped topic.


If from and to are omitted. The last N data points will be returned for each topic.  For example

[ mqttcogs_data limit="100" from="2016-12-01 00:00:00" topics="mysensors_out/100/1/1/0/0" ]

A negative number N in the from or to field represents (current date and time) – N days. This example shows data from no more than 2 days ago restricted to a maximum of 40 data points.

[ mqttcogs_data limit="40" from="-2" topics="mysensors_out/100/1/1/0/0" ]


Show data for the last 24 hours using the default LineChart

[ mqttcogs_drawgoogle] 
  [ mqttcogs_data limit="999" from="-1" topics="mysensors_out/100/1/1/0/0"] 
[/mqttcogs_drawgoogle ]


Returns a single piece of Mqtt data. Attributes determine if payload or datetime are returned. See example below


topic – required. A single topic. For example, topic=”mysensors_out/100/1/1/0/0″

field – optional, one of ‘datetime’ or ‘payload’, default ‘payload’.

order – optional, either ‘desc’ or ‘asc’, default ‘desc’. Order of returned data. By default the data is ordered by descending datetime

fromoptional, default ”. Either a negative number of days from now or a date & time in the format yyyy-mm-dd hh:mm:ss

to optional, default ”. Either a negative number of days from now or a date & time in the format yyyy-mm-dd hh:mm:ss.

dateformat – optional, default blog datetime. By default will use the datetime settings of the blog. Otherwise use standard PHP date formatting strings. Eg ‘Y-m-d H:i:s’

local – optional, default ‘false’. If set to true will return blog’s localised datetime. This will depend on settings.


The value does not auto refresh.

If from and to and order are omitted the most recent piece of Mqtt data will be returned. For example

[ mqttcogs_get topic='mysensors_out/99/2/1/0/0' field='payload' ]

If from and to are included then order will determine whether the first/last value within the given date range is returned. For example, the following will return the last value on the 25th December 2016

[ mqttcogs_get 
from='2016-12-25 00:00:00' 
to='2016-12-26 00:00:00' 
order='desc' ]


Last known temperature reading is [ mqttcogs_get topic='mysensors_out/99/2/1/0/0' field='payload' ]C   taken at [ mqttcogs_get topic='mysensors_out/99/2/1/0/0' field='datetime' dateformat='Y-m-d H:i:s' local='false' ]


Allows a user to publish data to an Mqtt Broker. The Shortcode can display most supported html input types. This includes ‘text’, ‘checkbox’, ‘range’. Shortcode will display a label and an html input element. Data is published on the onchange event of the input element.

On initialization the input is populated with the last known value for the chosen topic. If there is no last value then the value in the input_value attribute. This is coerced into an appropriate type. For example, input_value=’0′ will be set as 0. On submit the data entered into the input field is published to specified Mqtt topic. When type is set to ‘checkbox’ the values 0,1 or ‘false’, ‘true’ will be toggled. This will depend on the initial value.

See example below, in addition there is a more detailed blog here with some more examples.


topic – required. A single topic to which data will be published. For example, topic=”mysensors_out/100/1/1/0/0″

minrole – optional, default ‘Administrator’. WordPress User role required for the Shortcode. If the user does not have the minimum role the text specified in the ‘restrictedtext’ field will be displayed.

qos – optional, one of ‘0’, ‘1’ or ‘2’, default ‘1’. Mqtt QOS (quality of service) level. A setting of 1 means ‘acknowledged’.

retained – optional, one of ‘0’ or ‘1’, default ‘0’. Mqtt retained flag. A setting of 0 means not retained. 0 is normal.

id – optional, html id attribute. A unique id will be auto generated if not provided

class – optional.

label_text optional. Label text next after input

input_value optional. Will be used as a default value if the topic does not have a last value

input_type optional, default ‘text’. Written to type attribute of input element.

input_title optional. Written to title attribute of input element.

input_pattern optional. Written to pattern attribute of input element. Use a regex for text validation

input_min optional. Written to min attribute of input element.

input_max optional. Written to max attribute of input element.

input_step optional. Written to step attribute of input element.

class – optional.  Class for styling purposes

restrictedtext – optional, default ”. Text to display if user does not have sufficient privileges for this Shortcode


Html similar to the following will be inserted into the dom by the shortcode. The code below omits any input attributes, it shows the basic structure only. The span class is added so that a checkbox can easily be styled into a toggle button if required.

<div id="5df9f0141f226" class="yourclass">
	<input id="mqttcogs_set_5df9f0141f226" type="text" onchange="setMQTTData5df9f0141f226()">
	<label for="mqttcogs_set_5df9f0141f226">Enter a new value here<span class="sw"></span></label>	
	<script type="text/javascript">		
	      	function setMQTTData5df9f0141f226() {
.....the function  

If the user does not meet the minrole requirements (i.e if minrole was Author and current role is Subscriber) then the text displayed in the ‘restrictedtext’ attribute will be displayed. Use the yourclassfromattribute tag to style the html. See here for an example.

Currently no validation is performed on the payload!


[ mqttcogs_set topic='tests/blog/publishingdata' label_text='Enter a new value here:' input_value='23' input_type='number' input_min='0' input_max='50' input_step='1']

About | Examples | Shortcodes | Hooks | Download