Example - Tasmota wall Dimmer (Martin Jerry US-SD-KN01) #526
glasscake
started this conversation in
Show and tell
Replies: 1 comment
-
Seems that in blocking function |
Beta Was this translation helpful? Give feedback.
0 replies
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 wall dimmers should work on either the rotary or button type. 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 "get all Tasmota state" for all Tasmota devices.
Amazon Link: https://www.amazon.com/dp/B0C3L3HXLF?psc=1&ref=ppx_yo2ov_dt_b_product_details
https://www.martinjerry.com/us-sd-kn01-support
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": "b6b9d00d03eca1fc", "type": "comment", "z": "c16b8cbf103f2790", "name": "NRB Single CH Dimmers", "info": "", "x": 770, "y": 480, "wires": [] }, { "id": "928473d58bc72ff6", "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": 230, "y": 540, "wires": [ [ "c2b7ad62a9e09c64" ] ] }, { "id": "c71d08bfe8cc1890", "type": "homekit-service", "z": "c16b8cbf103f2790", "isParent": true, "hostType": "0", "bridge": "", "accessoryId": "", "parentService": "", "name": "Your HK Dimmer", "serviceName": "Lightbulb", "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": "{\"Brightness\":true}", "waitForSetupMsg": false, "outputs": 2, "x": 1050, "y": 540, "wires": [ [ "1e4da63e183bd46c", "e767d87dd576116f" ], [] ] }, { "id": "1e4da63e183bd46c", "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},null];\n}\n\nif(msg.payload.Brightness != null)\n{\n return [null,{payload:msg.payload.Brightness}];\n}\n\nreturn null,null;", "outputs": 2, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1270, "y": 540, "wires": [ [ "1ff9481d85b056d5" ], [ "b8fd1e0c09069805" ] ] }, { "id": "1ff9481d85b056d5", "type": "mqtt out", "z": "c16b8cbf103f2790", "name": "", "topic": "cmnd/YOUR_TASMOTA/Power1", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "", "x": 1530, "y": 500, "wires": [] }, { "id": "b8fd1e0c09069805", "type": "mqtt out", "z": "c16b8cbf103f2790", "name": "", "topic": "cmnd/YOUR_TASMOTA/Dimmer", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "", "x": 1540, "y": 540, "wires": [] }, { "id": "bc90979c090a0c7a", "type": "function", "z": "c16b8cbf103f2790", "name": "MQTT To HomeKit ", "func": "\n//translate the mqtt to homekit\n\nif(msg.payload.POWER != null && msg.payload.Dimmer == null)\n{\n msg.mqtt = msg.payload;\n msg.payload={\n \"On\":false\n }\n if(msg.mqtt.POWER == \"ON\")\n {\n msg.payload.On = true\n }\n return msg;\n}\n\nif(msg.payload.Dimmer != null && msg.payload.POWER != null)\n{\n msg.mqtt = msg.payload;\n msg.payload={\n \"On\":false,\n \"Brightness\":msg.mqtt.Dimmer\n }\n if(msg.mqtt.POWER == \"ON\")\n {\n msg.payload.On = true\n }\n return msg;\n}\n\nreturn null;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 830, "y": 540, "wires": [ [ "c71d08bfe8cc1890" ] ] }, { "id": "917e528b9ca0fc85", "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 //also need to save what the last change was since homekit only reports either brightness or power\n if (msg.payload.Brightness != null)\n {\n context.set('lastchange', 0)\n context.set('brightness', msg.payload.Brightness)\n }\n if (msg.payload.On != null)\n {\n context.set('lastchange', 1)\n context.set('status', msg.payload.On)\n }\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 var dimmer = 0\n\n //check what the last homekit message was and comapare\n if (\n //was the last change a brightness change and do they match?\n (context.get('lastchange') == 0 && context.get('brightness') == msg.payload.Dimmer)\n || //or\n //was the last change a power change and do they match\n (context.get('lastchange') == 1 && context.get('status') == power)\n )\n {\n //one of the above were true\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": 650, "y": 540, "wires": [ [ "bc90979c090a0c7a" ] ] }, { "id": "c2b7ad62a9e09c64", "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": 480, "y": 540, "wires": [ [ "917e528b9ca0fc85" ] ] }, { "id": "e767d87dd576116f", "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": 820, "y": 600, "wires": [ [ "917e528b9ca0fc85" ] ] }, { "id": "1ea41f9f2c2e58f6", "type": "mqtt out", "z": "c16b8cbf103f2790", "name": "Get all tasmotas state", "topic": "cmnd/tasmotas/STATE", "qos": "", "retain": "", "respTopic": "", "contentType": "", "userProps": "", "correl": "", "expiry": "", "broker": "", "x": 360, "y": 500, "wires": [] }, { "id": "73ee99e7e388eb00", "type": "inject", "z": "c16b8cbf103f2790", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 160, "y": 500, "wires": [ [ "1ea41f9f2c2e58f6" ] ] } ]
Beta Was this translation helpful? Give feedback.
All reactions