Has anyone managed to dynamically set options for the dropdown type of virtual switch? If so, how did you manage to set your options?
The test flow below shows a simplified form what I am trying to do. I have tried following both the example javascript in the help attached to the virtual switch node and the longer configuration definition set out in the Venus OS dbus switch specification. In both cases the error text is “Invalid value types for keys: /SwitchableOutput/output_1/Settings/Labels. Expected: string, number, boolean, null, or array of numbers.
I am using firmware version 3.71 on my Cerbo-S GX.
[
{
"id": "ef5b123c0a22b959",
"type": "tab",
"label": "Test",
"disabled": false,
"info": "",
"env": []
},
{
"id": "4d6815f75342ba53",
"type": "victron-virtual-switch",
"z": "ef5b123c0a22b959",
"name": "",
"outputs": 3,
"switch_1_type": "8",
"switch_1_min": "1",
"switch_1_max": "3",
"switch_1_initial": 0,
"switch_1_label": "",
"switch_1_unit": "",
"switch_1_step": 1,
"switch_1_customname": "No. of options",
"switch_1_group": "Test",
"switch_1_include_measurement": false,
"switch_1_rgb_color_wheel": false,
"switch_1_cct_wheel": false,
"switch_1_rgb_white_dimmer": false,
"x": 200,
"y": 140,
"wires": [
[],
[],
[
"ec56d82501e08c11",
"e124bed4414c85e3"
]
]
},
{
"id": "ec56d82501e08c11",
"type": "switch",
"z": "ef5b123c0a22b959",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "lt",
"v": "2",
"vt": "num"
},
{
"t": "eq",
"v": "2",
"vt": "num"
},
{
"t": "gt",
"v": "2",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 410,
"y": 140,
"wires": [
[
"bff701b4f45982db"
],
[
"da5f3ce5feeb3ba6"
],
[
"24a4a2b4396e0dfa"
]
]
},
{
"id": "bff701b4f45982db",
"type": "change",
"z": "ef5b123c0a22b959",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"/SwitchableOutput/output_1/Settings/DimmingMin\":0,\"/SwitchableOutput/output_1/Settings/DimmingMax\":1,\"/SwitchableOutput/output_1/Settings/Labels\":[\"0\"]}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 100,
"wires": [
[
"f9fea3716cef7032"
]
]
},
{
"id": "da5f3ce5feeb3ba6",
"type": "change",
"z": "ef5b123c0a22b959",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"/SwitchableOutput/output_1/Settings/Labels\":[\"First\",\"Second\"]}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 140,
"wires": [
[
"f9fea3716cef7032"
]
]
},
{
"id": "24a4a2b4396e0dfa",
"type": "change",
"z": "ef5b123c0a22b959",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"/SwitchableOutput/output_1/Settings/Labels\":[\"First\",\"Second\",\"Third\"]}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 180,
"wires": [
[
"f9fea3716cef7032"
]
]
},
{
"id": "f9fea3716cef7032",
"type": "victron-virtual-switch",
"z": "ef5b123c0a22b959",
"name": "",
"outputs": 2,
"switch_1_type": "6",
"switch_1_min": 0,
"switch_1_max": "",
"switch_1_initial": 0,
"switch_1_label": "",
"switch_1_unit": "",
"switch_1_step": 1,
"switch_1_customname": "Test dropdown",
"switch_1_group": "Test",
"switch_1_include_measurement": false,
"switch_1_rgb_color_wheel": false,
"switch_1_cct_wheel": false,
"switch_1_rgb_white_dimmer": false,
"x": 880,
"y": 140,
"wires": [
[],
[]
]
},
{
"id": "e124bed4414c85e3",
"type": "debug",
"z": "ef5b123c0a22b959",
"name": "debug 2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 400,
"y": 260,
"wires": []
},
{
"id": "589635a1b75c709e",
"type": "global-config",
"env": [],
"modules": {
"@victronenergy/node-red-contrib-victron": "1.6.63"
}
}
]