gablau / node-red-contrib-blynk-ws

Old/Legacy Blynk library implementation for Node-RED using WebSockets
MIT License
31 stars 10 forks source link

Table node not resetting index #25

Closed iskoch01 closed 3 years ago

iskoch01 commented 3 years ago

The documentation for blynk-ws-out-table indicates that when msg.clear = true, the table is cleared. The table is cleared, but... the index is not reset. Turning on logging indicates that the library is sending a cumulative index number. Unfortunately, there is no way to reset the index number, or query for the first index number. Even restarting the flow does not reset the index. This makes it impossible to update a specific item, and requires the entire table to be cleared and re-written for each update.

gablau commented 3 years ago

You are right, this is a bug. I'll fix it for the next release.

Thank you

iskoch01 commented 3 years ago

Mistakenly wrote a long reply for this issue. In case it's helpful...

Node Red: 1.0.3 node-red-contrib-blynk-ws: 1.0.3

Demo flow:



[
    {
        "id": "b459ecf3.dff8b",
        "type": "tab",
        "label": "Blynk Table Idx Test",
        "disabled": false,
        "info": "Demonstrates that table index numbers are not reset by table clear"
    },
    {
        "id": "f2c49730.fecd08",
        "type": "blynk-ws-out-table",
        "z": "b459ecf3.dff8b",
        "name": "",
        "pin": "23",
        "client": "b7d0d638.a6e3",
        "x": 760,
        "y": 240,
        "wires": []
    },
    {
        "id": "4d02faac.0d27bc",
        "type": "function",
        "z": "b459ecf3.dff8b",
        "name": "add to table",
        "func": "delete msg.clear;\n// this works\nmsg.add = [\"_name\",\"_value\"];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 310,
        "y": 240,
        "wires": [
            [
                "c2e15c8e.b6bd48",
                "cf641474.c60cc8"
            ]
        ]
    },
    {
        "id": "c2e15c8e.b6bd48",
        "type": "delay",
        "z": "b459ecf3.dff8b",
        "name": "",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 590,
        "y": 240,
        "wires": [
            [
                "f2c49730.fecd08",
                "90e0d6ff.f4513"
            ]
        ]
    },
    {
        "id": "40fb2ad1.6fd99c",
        "type": "inject",
        "z": "b459ecf3.dff8b",
        "name": "start",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 90,
        "y": 80,
        "wires": [
            [
                "dcb9790b.31b638",
                "8a1e804f.04003",
                "e258acfc.11d2c"
            ]
        ]
    },
    {
        "id": "dcb9790b.31b638",
        "type": "change",
        "z": "b459ecf3.dff8b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "clear",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 200,
        "wires": [
            [
                "c2e15c8e.b6bd48",
                "124bfd01.c42b2b"
            ]
        ]
    },
    {
        "id": "73acd2df.bbee6c",
        "type": "function",
        "z": "b459ecf3.dff8b",
        "name": "update row 1",
        "func": "delete msg.add;\n// following line does not work because row 1 has been cleared\nmsg.update = [\"1\", \"_name_updated\", \"_value_updated\"];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 310,
        "y": 300,
        "wires": [
            [
                "c2e15c8e.b6bd48"
            ]
        ]
    },
    {
        "id": "124bfd01.c42b2b",
        "type": "delay",
        "z": "b459ecf3.dff8b",
        "name": "",
        "pauseType": "delay",
        "timeout": "2",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 160,
        "y": 240,
        "wires": [
            [
                "4d02faac.0d27bc"
            ]
        ]
    },
    {
        "id": "cf641474.c60cc8",
        "type": "delay",
        "z": "b459ecf3.dff8b",
        "name": "",
        "pauseType": "delay",
        "timeout": "2",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 160,
        "y": 300,
        "wires": [
            [
                "73acd2df.bbee6c"
            ]
        ]
    },
    {
        "id": "9c2dbdad.d809f8",
        "type": "comment",
        "z": "b459ecf3.dff8b",
        "name": "Loops continuously to demonstrate that table index numbers are not reset by table clear",
        "info": "",
        "x": 330,
        "y": 40,
        "wires": []
    },
    {
        "id": "8a1e804f.04003",
        "type": "debug",
        "z": "b459ecf3.dff8b",
        "name": "timestamp -> debug/console",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 350,
        "y": 80,
        "wires": []
    },
    {
        "id": "90e0d6ff.f4513",
        "type": "debug",
        "z": "b459ecf3.dff8b",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 730,
        "y": 300,
        "wires": []
    },
    {
        "id": "3d805818.38f018",
        "type": "inject",
        "z": "b459ecf3.dff8b",
        "name": "interrupt",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 100,
        "y": 120,
        "wires": [
            [
                "628e99b.7ddc6e8"
            ]
        ]
    },
    {
        "id": "e258acfc.11d2c",
        "type": "trigger",
        "z": "b459ecf3.dff8b",
        "op1": "",
        "op2": "0",
        "op1type": "pay",
        "op2type": "str",
        "duration": "-10",
        "extend": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "name": "",
        "x": 330,
        "y": 120,
        "wires": [
            [
                "dcb9790b.31b638"
            ]
        ]
    },
    {
        "id": "628e99b.7ddc6e8",
        "type": "change",
        "z": "b459ecf3.dff8b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "reset",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 120,
        "y": 160,
        "wires": [
            [
                "e258acfc.11d2c"
            ]
        ]
    },
    {
        "id": "b7d0d638.a6e3",
        "type": "blynk-ws-client",
        "z": "",
        "name": "Node Red",
        "path": "ws://blynk-cloud.com/websockets",
        "key": "WF6iJUD3C4LzamE9m8LJOVdVr4xmGi29",
        "dbg_all": true,
        "dbg_read": false,
        "dbg_write": false,
        "dbg_notify": false,
        "dbg_mail": false,
        "dbg_prop": false,
        "dbg_sync": false,
        "dbg_bridge": false,
        "dbg_low": false,
        "dbg_pins": "",
        "multi_cmd": false,
        "proxy_type": "no",
        "proxy_url": "",
        "enabled": true
    }
]```

Logs:

14 Sep 06:50:57 - [info] [debug:timestamp -> debug/console] 1600084257403
14 Sep 06:50:57 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","clr"]
14 Sep 06:50:58 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","clr"]
14 Sep 06:50:59 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","add",0,"_name","_value"]
14 Sep 06:51:00 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","add",1,"_name","_value"]
14 Sep 06:51:01 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","update","1","_name_updated","_value_updated"]
14 Sep 06:51:02 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","update","1","_name_updated","_value_updated"]
14 Sep 06:51:07 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","clr"]
14 Sep 06:51:09 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","add",2,"_name","_value"]
14 Sep 06:51:11 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","update","1","_name_updated","_value_updated"]
14 Sep 06:51:17 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","clr"]
14 Sep 06:51:19 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","add",3,"_name","_value"]
14 Sep 06:51:21 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","update","1","_name_updated","_value_updated"]
14 Sep 06:51:27 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","clr"]
14 Sep 06:51:29 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","add",4,"_name","_value"]
14 Sep 06:51:31 - [info] [blynk-ws-client:Node Red] virtualWrite: -> ["vw","23","update","1","_name_updated","_value_updated"]
gablau commented 3 years ago

fixed in 1.0.4 version