Remote switch for Moko Smart Meter Plug using MQTT and Edgeware IoT Edge Gateway
Full disclosure, I work at Edgeware.
This flow allows you to remotely control your Moko BLE Smart Socket Plug MK116B over MQTT.
The Edgeware IoT Edge Gateway comes preconfigured with EMQX and automatically registers devices as publishers and subscribers when they are added to the platform.
For this to work, you must name your Moko plug "moko-1"
You can find more information on how to add sensors and configure the EMQX broker at following post: https://www.edgewaretech.com.au/blogs/getting-started/how-to-configure-node-red-on-your-edgeware-gateway
[{"id":"f6f2187d.f17ca8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"e2198084a7c4341f","type":"mqtt out","z":"f6f2187d.f17ca8","name":"","topic":"moko/requests/name/moko-1","qos":"1","retain":"","respTopic":"moko/responses","contentType":"application/json","userProps":"","correl":"sss","expiry":"","broker":"8e227389c5069897","x":490,"y":140,"wires":[]},{"id":"a34d74ecda7bf8eb","type":"mqtt in","z":"f6f2187d.f17ca8","name":"","topic":"moko/responses","qos":"2","datatype":"auto","broker":"8e227389c5069897","nl":false,"rap":true,"rh":0,"inputs":0,"x":180,"y":320,"wires":[["48e4979bbd5228ef"]]},{"id":"48e4979bbd5228ef","type":"debug","z":"f6f2187d.f17ca8","name":"msg","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":500,"y":320,"wires":[]},{"id":"2b9746f4d0fbf479","type":"inject","z":"f6f2187d.f17ca8","name":"switchOn","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"switchOn\"}","payloadType":"json","x":180,"y":80,"wires":[["e2198084a7c4341f"]]},{"id":"ec7b5c7970e6d290","type":"inject","z":"f6f2187d.f17ca8","name":"switchOff","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"command\":\"switchOff\"}","payloadType":"json","x":180,"y":200,"wires":[["e2198084a7c4341f"]]},{"id":"8e227389c5069897","type":"mqtt-broker","name":"emqx","broker":"emqx","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"5","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]