HiveMQ

From wiki.netio-products.com
Jump to navigation Jump to search

example integration with Cobra/PowerCable/PowerPDU4PS + HiveMQ public broker + MQTT Dash Android App


cobra MQTT-flex configuration:

{

   "config":{
       "broker":{
           "url":"broker.hivemq.com",
           "protocol":"mqtt",
           "port":1883,
           "ssl":false,
           "type":"generic",
           "username":"freedom",
           "password":"peace|LOVE|empathy4ALL"
       },
       "subscribe":[
           {
               "topic":"netio/${DEVICE_NAME}/output/1/action",
               "qos":0,
               "target":"OUTPUTS/1/ACTION",
               "action":"${payload}"
           }
       ],
       "publish":[
           {
               "topic":"netio/${DEVICE_NAME}/output/1/state",
               "qos":0,
               "retain":true,
               "payload":"${OUTPUTS/1/STATE}",
               "events":[
                   {
                       "type":"change",
                       "source":"OUTPUTS/1/STATE"
                   }
               ]
           },
           {
               "topic":"netio/${DEVICE_NAME}/output/1/load",
               "qos":0,
               "retain":false,
               "payload":"${OUTPUTS/1/LOAD}",
               "events":[
                   {
                       "type":"timer",
                       "period":5
                   },
                   {
                       "type":"delta",
                       "source":"OUTPUTS/1/LOAD",
                       "delta":1
                   }      
               ]
           }
       ]
   }

}


HiveMQ connection settings (just to check, that data are being send towards internet):

http://www.hivemq.com/demos/websocket-client/

- put username, password and click connect

- to check, that data are being send towards broker click 'Add Supscription' and fill in the Topic like: netio/{DEVICE_NAME}/# where replace {DEVICE_NAME} with name of your device (i.e.: if the name of your device is COBRA-8C, then put into this field: netio/COBRA-8C/# ). hash character ('#') stands for wildcard for all other subtopics (like state, voltage, energy etc.)

- to check, that your device can listen to MQTT messages sent through broker fill in the section PUBLISH with Topic netio/{DEVICE_NAME}/output/{OUTPUT_NUM}/action (for example for second output of device named COBRA-8C put 'netio/COBRA-8C/output/2/action') here. for test, put the value number 4, which means toggle (0 - switch output off, 1 - switch output on, 2 - toggle output to the inverse state)

Android App MQTT Dash (you can use any other, of course): https://play.google.com/store/apps/details?id=net.routix.mqttdash&hl=en