Difference between revisions of "MQTT-flex"
(added atributes table) |
|||
Line 15: | Line 15: | ||
=== Publish section === | === Publish section === | ||
− | + | {| class="wikitable" | |
− | Item Description | + | ! style="font-weight:bold; background-color:#9b9b9b;" | Item |
− | url MQTT broker URL broker.hivemq.com | + | ! style="font-weight:bold; background-color:#9b9b9b;" | Presence |
− | + | ! style="font-weight:bold; background-color:#9b9b9b;" | Possible Values | |
− | + | ! style="font-weight:bold; background-color:#9b9b9b;" | Description | |
− | + | ! style="font-weight:bold; background-color:#9b9b9b;" | JSON Config Usage | |
− | username Credentials for MQTT broker - username freedom | + | |- |
− | password Credentials for MQTT broker - password peace|LOVE|empathy4ALL | + | | style="background-color:#efefef;" | url |
− | clientid | + | | style="background-color:#efefef;" | mandatory |
− | keepalive | + | | style="background-color:#efefef;" | |
+ | | style="background-color:#efefef;" | MQTT broker URL | ||
+ | | style="background-color:#efefef;" | "url":"broker.hivemq.com" | ||
+ | |- | ||
+ | | style="background-color:#efefef;" | port | ||
+ | | style="background-color:#efefef;" | mandatory | ||
+ | | style="background-color:#efefef;" | 1 - 65535 | ||
+ | | style="background-color:#efefef;" | MQTT broker port | ||
+ | | style="background-color:#efefef;" | "port":1883 | ||
+ | |- | ||
+ | | style="background-color:#efefef;" | ssl | ||
+ | | style="background-color:#efefef;" | mandatory | ||
+ | | style="background-color:#efefef;" | true, false | ||
+ | | style="background-color:#efefef;" | Use SSL crypted communication selector | ||
+ | | style="background-color:#efefef;" | "ssl":false | ||
+ | |- | ||
+ | | style="background-color:#efefef;" | type | ||
+ | | style="background-color:#efefef;" | mandatory | ||
+ | | style="background-color:#efefef;" | generic | ||
+ | | style="background-color:#efefef;" | Communication/setup type option | ||
+ | | style="background-color:#efefef;" | "type":"generic" | ||
+ | |- | ||
+ | | style="background-color:#efefef;" | username | ||
+ | | style="background-color:#efefef;" | mandatory | ||
+ | | style="background-color:#efefef;" | regexp+len | ||
+ | | style="background-color:#efefef;" | Credentials for MQTT broker | ||
+ | | style="background-color:#efefef;" | "username":"freedom" | ||
+ | |- | ||
+ | | style="background-color:#efefef;" | password | ||
+ | | style="background-color:#efefef;" | mandatory | ||
+ | | style="background-color:#efefef;" | regexp+len | ||
+ | | style="background-color:#efefef;" | Credentials for MQTT broker | ||
+ | | style="background-color:#efefef;" | "password":"peace|LOVE|empathy4ALL" | ||
+ | |- | ||
+ | | style="background-color:#efefef;" | clientid | ||
+ | | style="background-color:#efefef;" | optional | ||
+ | | style="background-color:#efefef;" | regexp+len | ||
+ | | style="background-color:#efefef;" | MQTT clientid. Max. 32 characters. Variables ${DEVICE_MAC} or ${DEVICE_NAME} can be used | ||
+ | | style="background-color:#efefef;" | "clientid":"myEcoTable01" | ||
+ | |- | ||
+ | | style="background-color:#efefef;" | keepalive | ||
+ | | style="background-color:#efefef;" | optional | ||
+ | | style="background-color:#efefef;" | 1 - XXX? | ||
+ | | style="background-color:#efefef;" | MQTT keep alive period in seconds | ||
+ | | style="background-color:#efefef;" | "keepalive":90 | ||
+ | |} | ||
Revision as of 13:56, 26 July 2019
MQTT is implemented as M2M API protocol, where NETIO device is publisher providing output status and its measurements and subscriber is allowing to control NETIO power outputs via public or internal MQTT brokers.
With MQTT-flex the users can easily define the MQTT topics and payloads by themself via text configuration in JSON object format. Since there is then lot of possibilities with such freestyle flexibility allowed, you can find bellow full set of all implemented attributes and at the end of this article are some examples and links to configurations, which can be used towards public brokers as HiveMQ, IBM Watson, Azure, which you can sometimes directly, sometimes with slight modification (as putting yours Bluemix/Azure credentials) just copy&paste and see data flying between the computers, draw some sexy graphs and have big party with this feature :) ENJOY!
requirements:
PowerCable firmware – 2.1.0 and later
Broker section
here you have to define URL or IP address of machine hosting MQTT broker, level of security used for protocol, auth data and optionally some specific MQTT attributes, which are in the spec, but not mandatory required
Subscriber section
Publish section
Item | Presence | Possible Values | Description | JSON Config Usage |
---|---|---|---|---|
url | mandatory | MQTT broker URL | "url":"broker.hivemq.com" | |
port | mandatory | 1 - 65535 | MQTT broker port | "port":1883 |
ssl | mandatory | true, false | Use SSL crypted communication selector | "ssl":false |
type | mandatory | generic | Communication/setup type option | "type":"generic" |
username | mandatory | regexp+len | Credentials for MQTT broker | "username":"freedom" |
password | mandatory | regexp+len | Credentials for MQTT broker | "password":"peace|LOVE|empathy4ALL" |
clientid | optional | regexp+len | MQTT clientid. Max. 32 characters. Variables ${DEVICE_MAC} or ${DEVICE_NAME} can be used | "clientid":"myEcoTable01" |
keepalive | optional | 1 - XXX? | MQTT keep alive period in seconds | "keepalive":90 |
Config example
{ "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":1111 }, { "type":"delta", "source":"OUTPUTS/1/LOAD", "delta":1 } ] } ] } }
Subscribe topic for control of the output:
• netio/<DEVICE_NAME>/output/1/action with payload for output control : (0 – off, 1 – on, 2 – short off, 3 – short on, 4 – toggle, 5 – no change)
Publish topics for monitoring of the output state and load:
• netio/<DEVICE_NAME>/output/1/state with payload providing output 1 state value - published when the output state change • netio/<DEVICE_NAME>/output/1/load with payload providing actual load of output 1 – published every 1111 seconds or when load change by 1W
possible source:
OUTPUTS/X/VOLTAGE", OUTPUTS/X/CURRENT" OUTPUTS/X/POWER_FACTOR .exp = 100, .div = 1}, OUTPUTS/X/LOAD .exp = 1, .div = 1000}, OUTPUTS/X/STATE OUTPUTS/X/ACTION OUTPUTS/X/DELAY &uintValidator, .exp = 1, .div = 1 OUTPUTS/X/NAME OUTPUTS/X/FREQUENCY .exp = 1, .div = 1000}, OUTPUTS/X/ENERGY .exp = 1, .div = 10}, OUTPUTS/X/ENERGY_START OUTPUTS/X/ENERGY_START_FMT OUTPUTS/TOTAL/ENERGY .exp = 1, .div = 10}, OUTPUTS/TOTAL/LOAD .exp = 1, .div = 1000}, OUTPUTS/TOTAL/CURRENT OUTPUTS/TOTAL/VOLTAGE .exp = 1, .div = 100}, OUTPUTS/TOTAL/POWER_FACTOR", .exp = 100, .div = 1}, OUTPUTS/TOTAL/FREQUENCY" .exp = 1, .div = 1000},
available variables:
DEVICE_NAME DEVICE_MAC BRAND_NAME BRAND_TYPE