Get information from Tuya SMR1- Wi-Fi Smart RCBO

From B-Wiki
Jump to navigation Jump to search

SMR1- Wi-Fi Smart RCBO parameters

  1. Install from Manage pallete
    1. node-red-contrib-tuya-smart-device library in Node-Red
    2. node-red-node-base64
    3. node-red-contrib-simpletime
  2. Follow instructions in the page to get the local keys for the device
  3. Create the flow in Node-Red import code below
  4. Configure the key and id for the device

Reference: TUYA WIFI RCBO LED Adjustable Smart Circuit Breaker Residual Current Circuit Breaker With Over Current and Leakage Protection


Node-Red Import code

[
   {
       "id": "3729abbf064b1c02",
       "type": "tuya-smart-device",
       "z": "3cc77283e2cd6a24",
       "deviceName": "Breaker",
       "disableAutoStart": false,
       "deviceId": "",
       "deviceKey": "",
       "storeAsCreds": true,
       "deviceIp": "",
       "retryTimeout": 1000,
       "findTimeout": 10000,
       "tuyaVersion": "3.1",
       "eventMode": "event-both",
       "logLevel": "log-level-debug",
       "x": 540,
       "y": 120,
       "wires": [
           [
               "fd3ffb32ce742d34",
               "9767c5297ab1545b",
               "90b229b36a30e506"
           ],
           []
       ]
   },
   {
       "id": "823bf224bcd0f826",
       "type": "inject",
       "z": "3cc77283e2cd6a24",
       "name": "Get Status of dps 6",
       "props": [
           {
               "p": "payload"
           },
           {
               "p": "topic",
               "vt": "str"
           }
       ],
       "repeat": "60",
       "crontab": "",
       "once": false,
       "onceDelay": 0.1,
       "topic": "",
       "payload": "{\"operation\":\"GET\",\"dps\":6}",
       "payloadType": "json",
       "x": 320,
       "y": 120,
       "wires": [
           [
               "3729abbf064b1c02"
           ]
       ]
   },
   {
       "id": "3c5576774886270b",
       "type": "inject",
       "z": "3cc77283e2cd6a24",
       "name": "Get Schema",
       "props": [
           {
               "p": "payload"
           },
           {
               "p": "topic",
               "vt": "str"
           }
       ],
       "repeat": "",
       "crontab": "",
       "once": false,
       "onceDelay": 0.1,
       "topic": "",
       "payload": "{\"operation\":\"GET\",\"schema\":true}",
       "payloadType": "json",
       "x": 330,
       "y": 200,
       "wires": [
           [
               "3729abbf064b1c02"
           ]
       ]
   },
   {
       "id": "551a69bf6d6deb6f",
       "type": "function",
       "z": "3cc77283e2cd6a24",
       "name": "decode voltage",
       "func": "var voltage_u = msg.payload[0]\nvar voltage_l = msg.payload[1]\nvar voltage\nvoltage = (voltage_u*256 + voltage_l)/10\nmsg.payload = voltage\nreturn msg;",
       "outputs": 1,
       "timeout": 0,
       "noerr": 0,
       "initialize": "",
       "finalize": "",
       "libs": [],
       "x": 1300,
       "y": 200,
       "wires": [
           [
               "88f65798f9c62812"
           ]
       ]
   },
   {
       "id": "ef318c5a33a453ad",
       "type": "function",
       "z": "3cc77283e2cd6a24",
       "name": "decode current",
       "func": "var current_u = msg.payload[2]\nvar current_m = msg.payload[3]\nvar current_l = msg.payload[4]\nvar current\ncurrent = (current_u*256*256 + current_m*256 + current_l)/1000\nmsg.payload = current\nreturn msg;",
       "outputs": 1,
       "timeout": 0,
       "noerr": 0,
       "initialize": "",
       "finalize": "",
       "libs": [],
       "x": 1300,
       "y": 260,
       "wires": [
           [
               "5a40ea29f1f5f80e"
           ]
       ]
   },
   {
       "id": "437d14af053451f2",
       "type": "function",
       "z": "3cc77283e2cd6a24",
       "name": "decode wattage",
       "func": "var wattage_u = msg.payload[5]\nvar wattage_m = msg.payload[6]\nvar wattage_l = msg.payload[7]\nvar wattage\nwattage = (wattage_u*256*256 + wattage_m*256 + wattage_l)\nmsg.payload = wattage/1000\nreturn msg;",
       "outputs": 1,
       "timeout": 0,
       "noerr": 0,
       "initialize": "",
       "finalize": "",
       "libs": [],
       "x": 1280,
       "y": 320,
       "wires": [
           [
               "6689847a2093c3fb"
           ]
       ]
   },
   {
       "id": "fd3ffb32ce742d34",
       "type": "function",
       "z": "3cc77283e2cd6a24",
       "name": "decode message phase a",
       "func": "var forward_current =  msg.payload.data.dps[6] \nmsg.payload = forward_current\nreturn msg;",
       "outputs": 1,
       "timeout": 0,
       "noerr": 0,
       "initialize": "",
       "finalize": "",
       "libs": [],
       "x": 690,
       "y": 240,
       "wires": [
           [
               "988557b4f55a135e"
           ]
       ]
   },
   {
       "id": "88f65798f9c62812",
       "type": "ui_text",
       "z": "3cc77283e2cd6a24",
       "group": "f8639725f2c6137b",
       "order": 9,
       "width": 0,
       "height": 0,
       "name": "",
       "label": "Voltage (V)",
       "format": "Template:Msg.payload",
       "layout": "row-spread",
       "className": "",
       "style": false,
       "font": "",
       "fontSize": 16,
       "color": "#000000",
       "x": 1530,
       "y": 200,
       "wires": []
   },
   {
       "id": "5a40ea29f1f5f80e",
       "type": "ui_text",
       "z": "3cc77283e2cd6a24",
       "group": "f8639725f2c6137b",
       "order": 9,
       "width": 0,
       "height": 0,
       "name": "",
       "label": "Current (A)",
       "format": "Template:Msg.payload",
       "layout": "row-spread",
       "className": "",
       "style": false,
       "font": "",
       "fontSize": 16,
       "color": "#000000",
       "x": 1530,
       "y": 260,
       "wires": []
   },
   {
       "id": "6689847a2093c3fb",
       "type": "ui_text",
       "z": "3cc77283e2cd6a24",
       "group": "f8639725f2c6137b",
       "order": 9,
       "width": 0,
       "height": 0,
       "name": "",
       "label": "Power (kW)",
       "format": "Template:Msg.payload",
       "layout": "row-spread",
       "className": "",
       "style": false,
       "font": "",
       "fontSize": 16,
       "color": "#000000",
       "x": 1530,
       "y": 320,
       "wires": []
   },
   {
       "id": "9767c5297ab1545b",
       "type": "function",
       "z": "3cc77283e2cd6a24",
       "name": "decode message forward power",
       "func": "var forward_current =  msg.payload.data.dps[1] \nmsg.payload = forward_current/100\nreturn msg;",
       "outputs": 1,
       "timeout": 0,
       "noerr": 0,
       "initialize": "",
       "finalize": "",
       "libs": [],
       "x": 830,
       "y": 440,
       "wires": [
           [
               "60fdfb116a44993c"
           ]
       ]
   },
   {
       "id": "7150535be695e430",
       "type": "ui_text",
       "z": "3cc77283e2cd6a24",
       "group": "f8639725f2c6137b",
       "order": 9,
       "width": 0,
       "height": 0,
       "name": "",
       "label": "Total electricity consumption (kWh)",
       "format": "Template:Msg.payload",
       "layout": "row-spread",
       "className": "",
       "style": false,
       "font": "",
       "fontSize": 16,
       "color": "#000000",
       "x": 1360,
       "y": 440,
       "wires": []
   },
   {
       "id": "90b229b36a30e506",
       "type": "function",
       "z": "3cc77283e2cd6a24",
       "name": "decode message leakage current",
       "func": "var forward_current =  msg.payload.data.dps[15] \nmsg.payload = forward_current\nreturn msg;",
       "outputs": 1,
       "timeout": 0,
       "noerr": 0,
       "initialize": "",
       "finalize": "",
       "libs": [],
       "x": 840,
       "y": 540,
       "wires": [
           [
               "fa54511929e0919c",
               "47e94873b1dfcf28"
           ]
       ]
   },
   {
       "id": "a92108264b6526f5",
       "type": "ui_text",
       "z": "3cc77283e2cd6a24",
       "group": "f8639725f2c6137b",
       "order": 9,
       "width": 0,
       "height": 0,
       "name": "",
       "label": "Leakage current (mA)",
       "format": "Template:Msg.payload",
       "layout": "row-spread",
       "className": "",
       "style": false,
       "font": "",
       "fontSize": 16,
       "color": "#000000",
       "x": 1320,
       "y": 540,
       "wires": []
   },
   {
       "id": "dcae09a2c96c43be",
       "type": "simpletime",
       "z": "3cc77283e2cd6a24",
       "name": "Print time",
       "mydate": true,
       "myymd": true,
       "myyear": true,
       "mymonth": true,
       "mymonthn": true,
       "mydom": true,
       "mydoy": true,
       "myday": true,
       "myhourpm": true,
       "myhour": true,
       "mytime": true,
       "mytimes": true,
       "myminute": true,
       "myminutes": true,
       "mysecond": true,
       "mymillis": true,
       "myepoch": true,
       "myrawdate": true,
       "mypm": true,
       "x": 1080,
       "y": 120,
       "wires": [
           [
               "5c011c187fb2a32b"
           ]
       ]
   },
   {
       "id": "5c011c187fb2a32b",
       "type": "ui_text",
       "z": "3cc77283e2cd6a24",
       "group": "f8639725f2c6137b",
       "order": 9,
       "width": "0",
       "height": "0",
       "name": "",
       "label": "Timestamp unit reporting",
       "format": "Template:Msg.myrawdate",
       "layout": "row-spread",
       "className": "",
       "style": false,
       "font": "",
       "fontSize": 16,
       "color": "#000000",
       "x": 1270,
       "y": 120,
       "wires": []
   },
   {
       "id": "71e0568e46469064",
       "type": "simpletime",
       "z": "3cc77283e2cd6a24",
       "name": "Print time",
       "mydate": true,
       "myymd": true,
       "myyear": true,
       "mymonth": true,
       "mymonthn": true,
       "mydom": true,
       "mydoy": true,
       "myday": true,
       "myhourpm": true,
       "myhour": true,
       "mytime": true,
       "mytimes": true,
       "myminute": true,
       "myminutes": true,
       "mysecond": true,
       "mymillis": true,
       "myepoch": true,
       "myrawdate": true,
       "mypm": true,
       "x": 1180,
       "y": 620,
       "wires": [
           [
               "d62ecd4d902bc330"
           ]
       ]
   },
   {
       "id": "d62ecd4d902bc330",
       "type": "ui_text",
       "z": "3cc77283e2cd6a24",
       "group": "f8639725f2c6137b",
       "order": 9,
       "width": "0",
       "height": "0",
       "name": "",
       "label": "Timestamp node trigger",
       "format": "Template:Msg.myrawdate",
       "layout": "row-spread",
       "className": "",
       "style": false,
       "font": "",
       "fontSize": 16,
       "color": "#000000",
       "x": 1390,
       "y": 620,
       "wires": []
   },
   {
       "id": "988557b4f55a135e",
       "type": "switch",
       "z": "3cc77283e2cd6a24",
       "name": "",
       "property": "payload",
       "propertyType": "msg",
       "rules": [
           {
               "t": "nnull"
           }
       ],
       "checkall": "true",
       "repair": false,
       "outputs": 1,
       "x": 910,
       "y": 200,
       "wires": [
           [
               "dcae09a2c96c43be",
               "bc628644bdf3fe12",
               "bc91447e655f0af0",
               "427545b599c3c72b"
           ]
       ]
   },
   {
       "id": "fa54511929e0919c",
       "type": "switch",
       "z": "3cc77283e2cd6a24",
       "name": "",
       "property": "payload",
       "propertyType": "msg",
       "rules": [
           {
               "t": "nnull"
           }
       ],
       "checkall": "true",
       "repair": false,
       "outputs": 1,
       "x": 1030,
       "y": 620,
       "wires": [
           [
               "71e0568e46469064"
           ]
       ]
   },
   {
       "id": "bc628644bdf3fe12",
       "type": "base64",
       "z": "3cc77283e2cd6a24",
       "name": "",
       "action": "",
       "property": "payload",
       "x": 1080,
       "y": 200,
       "wires": [
           [
               "551a69bf6d6deb6f"
           ]
       ]
   },
   {
       "id": "bc91447e655f0af0",
       "type": "base64",
       "z": "3cc77283e2cd6a24",
       "name": "",
       "action": "",
       "property": "payload",
       "x": 1080,
       "y": 260,
       "wires": [
           [
               "ef318c5a33a453ad"
           ]
       ]
   },
   {
       "id": "427545b599c3c72b",
       "type": "base64",
       "z": "3cc77283e2cd6a24",
       "name": "",
       "action": "",
       "property": "payload",
       "x": 1080,
       "y": 320,
       "wires": [
           [
               "437d14af053451f2"
           ]
       ]
   },
   {
       "id": "60fdfb116a44993c",
       "type": "switch",
       "z": "3cc77283e2cd6a24",
       "name": "",
       "property": "payload",
       "propertyType": "msg",
       "rules": [
           {
               "t": "btwn",
               "v": "0",
               "vt": "num",
               "v2": "10000000",
               "v2t": "num"
           }
       ],
       "checkall": "true",
       "repair": false,
       "outputs": 1,
       "x": 1090,
       "y": 440,
       "wires": [
           [
               "7150535be695e430"
           ]
       ]
   },
   {
       "id": "47e94873b1dfcf28",
       "type": "switch",
       "z": "3cc77283e2cd6a24",
       "name": "",
       "property": "payload",
       "propertyType": "msg",
       "rules": [
           {
               "t": "nnull"
           }
       ],
       "checkall": "true",
       "repair": false,
       "outputs": 1,
       "x": 1110,
       "y": 540,
       "wires": [
           [
               "a92108264b6526f5"
           ]
       ]
   },
   {
       "id": "f8639725f2c6137b",
       "type": "ui_group",
       "name": "Power Meter House",
       "tab": "610d70e3f3b56633",
       "order": 9,
       "disp": true,
       "width": "6",
       "collapse": false,
       "className": ""
   },
   {
       "id": "610d70e3f3b56633",
       "type": "ui_tab",
       "name": "Energy",
       "icon": "dashboard",
       "disabled": false,
       "hidden": false
   }
]

References

https://www.tongou.com/api/tuya-smart-device-api https://platform.tuya.com/cloud/basic?id=p1730042891122rfxxcy&region=EU&toptab=application&authorizeTab=0 https://eu.platform.tuya.com/cloud/explorer?id=p1730042891122rfxxcy&groupId=group-1633641501546254380&interfaceId=1633017088845021199 https://support.tuya.com/en/help/_detail/Kc3n6kr7kllhc https://flows.nodered.org/node/node-red-contrib-tuya-devices

Data proprieties for the device

{

 "result": {
   "properties": [
     {
       "code": "forward_energy_total",
       "custom_name": "",
       "dp_id": 1,
       "time": 1730055431846,
       "type": "value",
       "value": 526
     },
     {
       "code": "phase_a",
       "custom_name": "",
       "dp_id": 6,
       "time": 1730055436303,
       "type": "raw",
       "value": "CJwAEJMAAzU="
     },
     {
       "code": "leakage_current",
       "custom_name": "",
       "dp_id": 15,
       "time": 1730055377266,
       "type": "value",
       "value": 13
     },
     {
       "code": "switch",
       "custom_name": "",
       "dp_id": 16,
       "time": 1730041338833,
       "type": "bool",
       "value": true
     },
     {
       "code": "ov_set",
       "custom_name": "",
       "dp_id": 102,
       "time": 1730040757193,
       "type": "enum",
       "value": "Trip"
     },
     {
       "code": "uv_set",
       "custom_name": "",
       "dp_id": 103,
       "time": 1730040757193,
       "type": "enum",
       "value": "Closed"
     },
     {
       "code": "oc_set",
       "custom_name": "",
       "dp_id": 104,
       "time": 1730040757193,
       "type": "enum",
       "value": "Trip"
     },
     {
       "code": "op_set",
       "custom_name": "",
       "dp_id": 105,
       "time": 1730040757193,
       "type": "enum",
       "value": "Closed"
     },
     {
       "code": "temp_set",
       "custom_name": "",
       "dp_id": 107,
       "time": 1730040757193,
       "type": "enum",
       "value": "Trip"
     },
     {
       "code": "leak_set",
       "custom_name": "",
       "dp_id": 108,
       "time": 1730040757193,
       "type": "enum",
       "value": "Trip"
     },
     {
       "code": "online_state",
       "custom_name": "",
       "dp_id": 109,
       "time": 1730055252643,
       "type": "enum",
       "value": "online"
     },
     {
       "code": "event",
       "custom_name": "",
       "dp_id": 110,
       "time": 1730041339246,
       "type": "enum",
       "value": "Remote_ON"
     },
     {
       "code": "auto_reclosing",
       "custom_name": "",
       "dp_id": 112,
       "time": 1730040857647,
       "type": "bool",
       "value": true
     },
     {
       "code": "rd_set",
       "custom_name": "",
       "dp_id": 113,
       "time": 1730040752050,
       "type": "bool",
       "value": false
     },
     {
       "code": "c_thresh",
       "custom_name": "",
       "dp_id": 114,
       "time": 1730040828233,
       "type": "value",
       "value": 32
     },
     {
       "code": "ov_thresh",
       "custom_name": "",
       "dp_id": 115,
       "time": 1730040966287,
       "type": "value",
       "value": 250
     },
     {
       "code": "uv_thresh",
       "custom_name": "",
       "dp_id": 116,
       "time": 1730040757193,
       "type": "value",
       "value": 165
     },
     {
       "code": "leak_thresh",
       "custom_name": "",
       "dp_id": 117,
       "time": 1730040757193,
       "type": "value",
       "value": 30
     },
     {
       "code": "temp_thresh",
       "custom_name": "",
       "dp_id": 118,
       "time": 1730040757193,
       "type": "value",
       "value": 800
     },
     {
       "code": "op_thresh",
       "custom_name": "",
       "dp_id": 119,
       "time": 1730040934488,
       "type": "value",
       "value": 7625
     },
     {
       "code": "fap_a",
       "custom_name": "",
       "dp_id": 125,
       "time": 1730055431848,
       "type": "value",
       "value": 526
     },
     {
       "code": "temp_a",
       "custom_name": "",
       "dp_id": 131,
       "time": 1730055096069,
       "type": "value",
       "value": 339
     }
   ]
 },
 "success": true,
 "t": 1730055436824,
 "tid": "48fbf7be949511ef894136243096d294"

}