MQTT Tiles variables

Configure variables in MQTT Tiles to select from the lists of like entities and populate the widgets with their values.

Defining variables in MQTT Tiles allows forming the drop-down lists to select from the items of the same type (e.g. channels, devices, streams, custom entities) and populate the widgets on the boards with the values associated with the selected entity.

For instance, you have several devices connected to flespi. If you define a variable <%device_id%>, you will be able to select the needed device from a drop-down list and have the widgets subscribed to topics with the ID of this particular device - messages/telemetry/etc.

Variables are added in the board settings either upon creation or later on. If you decide to add variables to the existing board, go to the three dots on the board card and select Settings:

mqtt tiles board settings

Then find the Variables section in the opened dialog and configure the desired variables:

mqtt tiles board variable presets

The Presets field allows selecting from the most used variable sources — channels, devices, or calcs taken from your flespi account.

If you want to take variable values from a custom topic, pick Custom from the Presets drop-down, then pick Source from the Type drop-down, and specify the topic to take the values from.

mqtt tiles board variable custom source

If you need custom values for variables, pick Custom from the Presets drop-down, then pick Custom in the Type drop-down, and populate the custom values manually in the Items section:

mqtt tiles board custom variable values

Now you can open the board in the Full board view and add widgets that incorporate the values from the added variables.

When you open the dialog to add the new widget, you will see the (x) icon next to the drop-downs. Click on this icon to select the variable that will be used to form the source topic for the widget.

mqtt tiles widget topic source variable

Select the proper variable and parameter(s). Note that the parameters can also be selected from variable values if the suitable variable exists.

mqtt tiles topic source variable dropdown

For example our task is to subscribe the widget to the telemetry topic of selected device. You define devices variable from template and in your topic you specify <%device_id%> placeholder which will be replaced to the actual id of the currently selected device in variables. 

If your topic was 'flespi/state/gw/devices/<%device_id%>/telemetry/position.latitude' when you select a specific device with id 123 the widget will subscribe to real topic with device id substituted: 'flespi/state/gw/devices/123/telemetry/position.latitude'

Here’s the resulting widget showing the speed for the selected device:

mqtt tiles widget result

***

Remember, variables in MQTT Tiles can be used only for forming subscriptions with the changing value on a certain level (or levels). 


See also
MQTT bridge is a very useful tool when you need to separate and partially isolate parts of your system, as well as not be fully dependent on a third-party MQTT broker.
How to achieve MQTT bridging functionality in flespi