OK it works but you have to be careful in configuring the switch UI node!
In blynk app:
- a button (V6) in switch mode to output 0 and 255
- an LED (V7)
In node-red
- a “Write event” not set pin V6 to read from button
- a “Write” not set pin V7 to write on led
- a switch UI node, configure with:
check " If msg
arrives on input, pass through to output:"
When clicked, send:
on payload as ‘String’ and 255 value
off payload as ‘String’ and 0 value
IMPORTANT: the switch ui node "accepts as input what it must give in output" so it must be put type "string" because the event node returns a string
So now the button in the app and the switch in the ui will be synchronized
Sample flow below:
[
{
"id": "31d224ca.0dcd7c",
"type": "ui_switch",
"z": "487e4c7.38d5eb4",
"name": "Led switch",
"label": "switch",
"tooltip": "",
"group": "9ed965a1.157dd",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "",
"style": "",
"onvalue": "255",
"onvalueType": "str",
"onicon": "",
"oncolor": "",
"offvalue": "0",
"offvalueType": "str",
"officon": "",
"offcolor": "",
"x": 459,
"y": 238,
"wires": [
[
"52b03515.a8e534"
]
]
},
{
"id": "c113077e.15d4e8",
"type": "blynk-ws-in-write",
"z": "487e4c7.38d5eb4",
"name": "Button",
"pin": "6",
"pin_all": 0,
"client": "8096728c.4c64d8",
"x": 260.5,
"y": 240,
"wires": [
[
"31d224ca.0dcd7c"
]
]
},
{
"id": "52b03515.a8e534",
"type": "blynk-ws-out-write",
"z": "487e4c7.38d5eb4",
"name": "Led",
"pin": "7",
"pinmode": 0,
"client": "8096728c.4c64d8",
"x": 644.5,
"y": 237,
"wires": []
},
{
"id": "9ed965a1.157dd",
"type": "ui_group",
"z": "",
"name": "Default",
"tab": "7dcaad4e.ad6994",
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "8096728c.4c64d8",
"type": "blynk-ws-client",
"z": "",
"name": "Progetto Test",
"path": "wss://blynk-cloud.com/websockets",
"key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"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": true,
"dbg_pins": "",
"multi_cmd": false,
"proxy_type": "no",
"proxy_url": "",
"enabled": true
},
{
"id": "7dcaad4e.ad6994",
"type": "ui_tab",
"z": "",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]