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 displays a label, text input and submit button. On initialization the input is populated with the last known value for the chosen topic.

On submit the data entered into the input field is published to specified Mqtt topic.

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.

textoptional, default ”. When displaying a basic input, text to display on the submit button.

label optional, default ”. Prompt text displayed on label

class – optional, default ”.  Optional class for styling purposes

options – optional, default ”.  ??

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


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.

If the user does meet the minrole requirements then html similar to the following will be inserted:

<div id="586bad0914ecf" class="yourclassfromattribute">
    <label for="mqttcogs_set_586bad0914ecf">Enter a new value here:</label>
	<input id="mqttcogs_set_586bad0914ecf" name="field1" value="23" type="text">
	<input id="mqttcogs_set_btn_586bad0914ecf" value="Add" onclick="setMQTTData586bad0914ecf()" type="submit">

Use the yourclassfromattribute tag to style the html. See here for an example.

The submission to the Mqtt broker is synchronous. During the submission process the button will disable.

Currently no validation is performed on the payload!


[ mqttcogs_set topic='tests/blog/publishingdata' text='Add' label='Enter a new value here:' ]

About | Examples | Shortcodes | Hooks | Download