Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
blocks:app-note:netio [2024-03-20 07:30] mattias [Configure the MQTT driver in Blocks] |
blocks:app-note:netio [2024-04-09 17:08] (current) mattias [Prepare the device] |
| |
====Prepare the device==== | ====Prepare the device==== |
First of all make yourself familiar with MQTT, we hava a [[blocks:server:advanced_server_configuration:mqtt|short article]] explaining the principles and describes how to enable a broker on the Blocks server.. | First of all make yourself familiar with MQTT, we have a [[blocks:server:advanced_server_configuration:mqtt|short article]] explaining the principles and describes how to enable a broker on the Blocks server. |
| |
Please refer to the vendor documentation on how to access the setup of the device. After successfully logged on we must enable and configure the MQTT-flex api. This is done by editing the JSON description as seen here. | Please refer to the vendor documentation on how to access the setup of the device. After successfully logged on we must enable and configure the MQTT-flex api. This is done by editing the JSON description as seen here. |
====Configure the MQTT driver in Blocks==== | ====Configure the MQTT driver in Blocks==== |
| |
Before adding devices we must have a broker configured in the blocks server configuration. | Before adding devices we must have a broker running (somewhere) and configured in the blocks server configuration. Please read [[blocks:server:advanced_server_configuration:mqtt|the MWTT documentation]] to get started. |
We use the generic //configurableMQTT// driver in Blocks, is has a very similar way of configuring as the netio devices. The driver is a bit "nerdy" but is also very flexible and more or less any MQTT device can be configured. | This application note use the generic //configurableMQTT// driver in Blocks, is has a very similar way of configuring as the netio devices. The driver is a bit "nerdy" but is also very flexible and more or less any MQTT device can be configured. It is also possible to write mqtt drivers that is bospoke for a certain device. |
| |
| ===Add the device=== |
Add a new mqtt device from Manage/Network Devices. Give the device a unique and meaningful name and set the //Topic Base//, this is the common part of the mqtt topic. The topic base will be concatenated with the subTopic from the configuration below to form the full topic path. | Add a new mqtt device from Manage/Network Devices. Give the device a unique and meaningful name and set the //Topic Base//, this is the common part of the mqtt topic. The topic base will be concatenated with the subTopic from the configuration below to form the full topic path. |
For the Netio example configurations in this app note the Topic Base is //netios/PowerBOX-B7// where PowerBox-B7 comes from the device name inserted by the device configuration. This comes from //netios/${DEVICE_NAME}/// found in the devices mqtt configuration. | For the Netio example configurations in this app note the Topic Base is //netios/PowerBOX-B7// where PowerBox-B7 comes from the device name inserted by the device configuration. This comes from //netios/${DEVICE_NAME}/// found in the devices mqtt configuration. |
| |
In the drivers custom options we can specify the blocks property names and the MQTT topics we need to subscribe to using JSON. The following example is for 2 socket PowerCABLE configured as in the examples above. | In the drivers custom options we can specify the blocks property names and the MQTT topics we need to subscribe to using JSON. The following example is for 2 socket PowerCABLE configured as in the examples above. |
| |
{{:blocks:app-note:netio:netio.png?800|}} | {{:blocks:app-note:netio:netio.png?800|}} |
| |
| Example driver configuration for a two socket device: |
| |
<code> | <code> |