Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
blocks:app-note:netio [2024-02-26 07:51]
mattias [Control Netio Power Distribution Units using MQTT]
blocks:app-note:netio [2024-04-09 17:08] (current)
mattias [Prepare the device]
Line 1: Line 1:
 =====Control Netio Power Distribution Units using MQTT===== =====Control Netio Power Distribution Units using MQTT=====
  
-This application note explains the steps involved in configuring the device and how to set up the device in Blocks using the Configurable MQTT driver.  There are at time of writing two ways of controlling NETIO pdu from Blocks. The other way is using a Rest API driver that is more straight forward since there is no need to configure a broker and less configuration in Blocks. The use of MQTT is particularly beneficial if you already have a MQTT enabled system and/or if you want to control devices located behind firewalls over the internet.+This application note explains the steps involved in configuring the device and how to set up the device in Blocks using the Configurable MQTT driver.  The use of MQTT is particularly beneficial if you already have a MQTT enabled system and/or if you want to control devices located behind firewalls over the internet
 + 
 +:!: NOTE: If you don't already have an MQTT broker as part of your system, the [[blocks:app-note:netio_modbus|MODBUS-based]] method of controlling this device may be easier to use.
  
 ====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.
Line 93: Line 95:
 ====Configure the MQTT driver in Blocks==== ====Configure the MQTT driver in Blocks====
  
-In blocks there is a similar concept to setup the configurableMQTT driver.+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. 
 +This application note use the generic //configurableMQTT// driver in Blocks, is has 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.  
 +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|}}
 +
 +Example driver configuration for a two socket device:
 +
 + <code>
     {     {
         "property": "Relay1",         "property": "Relay1",
Line 112: Line 126:
     }     }
 ] ]
 +
 +</code>
  
 Where: Where:
Line 126: Line 142:
  
 =====Example configurations for NETIO devices===== =====Example configurations for NETIO devices=====
 +The following examples can be used to configure the device and Blocks for MQTT. Both ends use JSON notation to specify the configuration. Both Netio and Blocks can be configured to match any existing system, hence configurable. In the case of NETIO we do not have to adapt to anything existing but we must setup some topics to use for communication. The examples do in a sense specify create the API. 
 ====NETIO PowerCable 2XX==== ====NETIO PowerCable 2XX====
 ===Netio MQTT flex api config=== ===Netio MQTT flex api config===