Example - Tasmota Smart Plug (Martin Jerry MJ-V06) #525
glasscake
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is an example of my flow for martin jerry plugs. There is blocking functionality to stop input loops. It also allows outside inputs (button on device, Tasmota interface, other automation) with feedback to homekit. I am currently using a 2-second repeat input on "get all Tasmota state". When implementing multiple devices just use one
Amazon Link: https://www.amazon.com/dp/B0BMTWNL7R?ref=ppx_yo2ov_dt_b_product_details&th=1
My recommended Tasmota settings:
BackLog MqttHost (YourMQTTIp); MqttUser (your MQTT Login)t; MqttPassword (Your MQTT PW); PowerRetain 1; SetOption53 1; SetOption41 20; Topic (Your mqtt topic); Hostname (your hostname)
Do note if you have a router that handles tasmota devices well drop "SetOption41". If you're noticing a lot of dropped connections renable it.
Example flow:
[ { "id": "8c98380a05075dc7", "type": "homekit-service", "z": "c16b8cbf103f2790", "isParent": true, "hostType": "0", "bridge": "", "accessoryId": "", "parentService": "", "name": "Your HK Plug", "serviceName": "Outlet", "topic": "", "filter": false, "manufacturer": "NRCHKB", "model": "1.5.0", "serialNo": "Default Serial Number", "firmwareRev": "1.5.0", "hardwareRev": "1.5.0", "softwareRev": "1.5.0", "cameraConfigVideoProcessor": "ffmpeg", "cameraConfigSource": "", "cameraConfigStillImageSource": "", "cameraConfigMaxStreams": 2, "cameraConfigMaxWidth": 1280, "cameraConfigMaxHeight": 720, "cameraConfigMaxFPS": 10, "cameraConfigMaxBitrate": 300, "cameraConfigVideoCodec": "libx264", "cameraConfigAudioCodec": "libfdk_aac", "cameraConfigAudio": false, "cameraConfigPacketSize": 1316, "cameraConfigVerticalFlip": false, "cameraConfigHorizontalFlip": false, "cameraConfigMapVideo": "0:0", "cameraConfigMapAudio": "0:1", "cameraConfigVideoFilter": "scale=1280:720", "cameraConfigAdditionalCommandLine": "-tune zerolatency", "cameraConfigDebug": false, "cameraConfigSnapshotOutput": "disabled", "cameraConfigInterfaceName": "", "characteristicProperties": "{}", "waitForSetupMsg": false, "outputs": 2, "x": 1000, "y": 280, "wires": [ [ "5f1423a49f4694f2", "95ded56c5408d25f" ], [] ] }, { "id": "ea0f5d977873ed33", "type": "mqtt in", "z": "c16b8cbf103f2790", "name": "", "topic": "stat/YOUR_TASMOTA/RESULT", "qos": "2", "datatype": "auto-detect", "broker": "", "nl": false, "rap": true, "rh": 0, "inputs": 0, "x": 210, "y": 280, "wires": [ [ "34bf3318582c62fc" ] ] }, { "id": "9870befd9642375c", "type": "function", "z": "c16b8cbf103f2790", "name": "MQTT - Homekit Plug", "func": "//translate the mqtt to homekit\n\nif (msg.payload.POWER != null) {\n msg.mqtt = msg.payload;\n msg.payload = {\n \"On\": false\n }\n if (msg.mqtt.POWER == \"ON\") {\n msg.payload.On = true\n }\n return msg;\n}\n\n\nreturn null;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 780, "y": 280, "wires": [ [ "8c98380a05075dc7" ] ] }, { "id": "5f1423a49f4694f2", "type": "function", "z": "c16b8cbf103f2790", "name": "HomeKit to MQTT", "func": "if(msg.payload.On != null)\n{\n if(msg.payload.On == true)\n {\n return {payload:true};\n }\n return {payload:false};\n}\nreturn null;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1210, "y": 280, "wires": [ [ "576fb5ee348d2a38" ] ] }, { "id": "576fb5ee348d2a38", "type": "mqtt out", "z": "c16b8cbf103f2790", "name": "", "topic": "cmnd/YOUR_TASMOTA/Power1", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "", "x": 1490, "y": 280, "wires": [] }, { "id": "a338cf856207783a", "type": "comment", "z": "c16b8cbf103f2790", "name": "NRB Movable Devices", "info": "", "x": 820, "y": 220, "wires": [] }, { "id": "b051760d42ed81a8", "type": "function", "z": "c16b8cbf103f2790", "name": "Block", "func": "//block all messages until the device has updated itself\n//this also stops loops and other odd issues\n\n//initalize into passing\nif (context.get('blocking') == null) {\n node.status({ fill: \"green\", shape: \"dot\", text: \"passing\" });\n context.set('blocking', false)\n return null\n}\n\n//is this a homekit message\nif (msg.payload.type == 1)\n{\n //that means the homekit service is sending data to the device\n //block all messages untill the device responds on mqtt\n context.set('blocking', true)\n //save what the message was so we confirm it is correct\n context.set('status', msg.payload.On)\n node.status({ fill: \"red\", shape: \"dot\", text: \"blocking\" });\n return null\n}\n\nif (msg.payload.type == 0)\n{\n //this is an mqtt response, lets see if the response matches the set status\n //translate mqtt to bool\n var power = false\n if (msg.payload.POWER == \"ON\")\n {\n power = true\n }\n //check if they match\n if( context.get('status') == power)\n {\n //they match, disable blocking\n context.set('blocking', false)\n node.status({ fill: \"green\", shape: \"dot\", text: \"passing\" });\n }\n}\n\n//get the current blocking state\nvar blocking = context.get('blocking')\n\nif (blocking == true)\n{\n return null\n}\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 590, "y": 280, "wires": [ [ "9870befd9642375c" ] ] }, { "id": "95ded56c5408d25f", "type": "function", "z": "c16b8cbf103f2790", "name": "Set Type", "func": "//let the block know if this is a homekit message\n\nmsg.payload.type = 1\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 780, "y": 340, "wires": [ [ "b051760d42ed81a8" ] ] }, { "id": "34bf3318582c62fc", "type": "function", "z": "c16b8cbf103f2790", "name": "Set Type", "func": "//let the block know this is an mqtt message\n\nmsg.payload.type = 0\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 420, "y": 280, "wires": [ [ "b051760d42ed81a8" ] ] }, { "id": "901159eda9263ff5", "type": "mqtt out", "z": "c16b8cbf103f2790", "name": "Get all tasmotas state", "topic": "cmnd/tasmotas/STATE", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "", "x": 400, "y": 240, "wires": [] }, { "id": "1a70e60011f280a9", "type": "inject", "z": "c16b8cbf103f2790", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 200, "y": 240, "wires": [ [ "901159eda9263ff5" ] ] } ]
Beta Was this translation helpful? Give feedback.
All reactions