Display boolean read values on UI switch

Hi,

I would like to display boolean values (got by reading values on a PLC) on a dashboard, using UI switches. Each time, it is possible to click on the switch in order to change the value, but I want the opposite. I just would like to trigger the value targeted, so that the switch becomes ON when the value is true and OFF when it's false.

I've found some topics who barely spoke about this issue, but it didn't help me to solve my problem.
I understood that I have to register the value before the switch thanks to a change node. I did that and transform each value into msg.payload, with the purpose to display the result on the switch.
Unfortunately, it didn't work. What do I have to put into "On Payload" and "Off payload" of the switch ?

I also have a lot of alarms on my PC, so it would be great if you have a solution which avoid me to have many and many nodes (thanks to an unique function for instance).

My flow :

[
    {
        "id": "94c53e1fb7cccfbc",
        "type": "tab",
        "label": "Flux 4",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8aaa48f84818486f",
        "type": "s7 in",
        "z": "94c53e1fb7cccfbc",
        "endpoint": "fed32a73d5582e79",
        "mode": "all",
        "variable": "",
        "diff": true,
        "name": "Reading measures",
        "x": 210,
        "y": 580,
        "wires": [
            [
                "beb5b40f0623fa30",
                "dbbd21fd05d8dda5",
                "b1d5947a6488af35",
                "0795cfe801cec740",
                "c8e77ee01ebb8eca",
                "584ab7fcb536f569"
            ]
        ]
    },
    {
        "id": "19d97c37bab53fa0",
        "type": "ui_switch",
        "z": "94c53e1fb7cccfbc",
        "name": "",
        "label": "Safety temperature switch",
        "tooltip": "",
        "group": "cd79e9901663568e",
        "order": 23,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 890,
        "y": 500,
        "wires": [
            []
        ]
    },
    {
        "id": "dbbd21fd05d8dda5",
        "type": "ui_switch",
        "z": "94c53e1fb7cccfbc",
        "name": "",
        "label": "Overload_cutout",
        "tooltip": "",
        "group": "cd79e9901663568e",
        "order": 23,
        "width": 0,
        "height": 0,
        "passthru": false,
        "decouple": "false",
        "topic": "payload.Overload_cutout",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 860,
        "y": 540,
        "wires": [
            []
        ]
    },
    {
        "id": "b1d5947a6488af35",
        "type": "ui_switch",
        "z": "94c53e1fb7cccfbc",
        "name": "",
        "label": "Thermal_cutout",
        "tooltip": "",
        "group": "cd79e9901663568e",
        "order": 23,
        "width": 0,
        "height": 0,
        "passthru": false,
        "decouple": "false",
        "topic": "payload.Thermal_cutout",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 860,
        "y": 580,
        "wires": [
            []
        ]
    },
    {
        "id": "0795cfe801cec740",
        "type": "ui_switch",
        "z": "94c53e1fb7cccfbc",
        "name": "",
        "label": "Power_fail",
        "tooltip": "",
        "group": "cd79e9901663568e",
        "order": 23,
        "width": 0,
        "height": 0,
        "passthru": false,
        "decouple": "false",
        "topic": "payload.Power_fail",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 850,
        "y": 620,
        "wires": [
            []
        ]
    },
    {
        "id": "beb5b40f0623fa30",
        "type": "change",
        "z": "94c53e1fb7cccfbc",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload.Safety_temperature_switch",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 560,
        "y": 500,
        "wires": [
            [
                "19d97c37bab53fa0"
            ]
        ]
    },
    {
        "id": "c8e77ee01ebb8eca",
        "type": "change",
        "z": "94c53e1fb7cccfbc",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload.Door_open",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 660,
        "wires": [
            [
                "91ee2be7177eb5ba"
            ]
        ]
    },
    {
        "id": "91ee2be7177eb5ba",
        "type": "ui_switch",
        "z": "94c53e1fb7cccfbc",
        "name": "",
        "label": "Door open",
        "tooltip": "",
        "group": "cd79e9901663568e",
        "order": 23,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 850,
        "y": 660,
        "wires": [
            []
        ]
    },
    {
        "id": "584ab7fcb536f569",
        "type": "debug",
        "z": "94c53e1fb7cccfbc",
        "name": "debug 212",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 450,
        "y": 420,
        "wires": []
    },
    {
        "id": "fed32a73d5582e79",
        "type": "s7 endpoint",
        "transport": "iso-on-tcp",
        "address": "192.168.0.1",
        "port": "102",
        "rack": "0",
        "slot": "1",
        "localtsaphi": "01",
        "localtsaplo": "00",
        "remotetsaphi": "01",
        "remotetsaplo": "00",
        "connmode": "rack-slot",
        "adapter": "",
        "busaddr": "2",
        "cycletime": "10000",
        "timeout": "2000",
        "name": "Discovery",
        "vartable": [
            {
                "addr": "DB62,BYTE0",
                "name": "Dry_Bulb_0"
            },
            {
                "addr": "DB62,BYTE1",
                "name": "Dry_Bulb_1"
            },
            {
                "addr": "DB62,BYTE2",
                "name": "Dry_Bulb_2"
            },
            {
                "addr": "DB62,BYTE3",
                "name": "Dry_Bulb_3"
            },
            {
                "addr": "DB62,BYTE4",
                "name": "Wet_Bulb_0"
            },
            {
                "addr": "DB62,BYTE5",
                "name": "Wet_Bulb_1"
            },
            {
                "addr": "DB62,BYTE6",
                "name": "Wet_Bulb_2"
            },
            {
                "addr": "DB62,BYTE7",
                "name": "Wet_Bulb_3"
            },
            {
                "addr": "DB62,BYTE8",
                "name": "PT100_USER0_0"
            },
            {
                "addr": "DB62,BYTE9",
                "name": "PT100_USER0_1"
            },
            {
                "addr": "DB62,BYTE10",
                "name": "PT100_USER0_2"
            },
            {
                "addr": "DB62,BYTE11",
                "name": "PT100_USER0_3"
            },
            {
                "addr": "DB62,BYTE12",
                "name": "PT100_USER1_0"
            },
            {
                "addr": "DB62,BYTE13",
                "name": "PT100_USER1_1"
            },
            {
                "addr": "DB62,BYTE14",
                "name": "PT100_USER1_2"
            },
            {
                "addr": "DB62,BYTE15",
                "name": "PT100_USER1_3"
            },
            {
                "addr": "DB62,BYTE16",
                "name": "PT100_USER2_0"
            },
            {
                "addr": "DB62,BYTE17",
                "name": "PT100_USER2_1"
            },
            {
                "addr": "DB62,BYTE18",
                "name": "PT100_USER2_2"
            },
            {
                "addr": "DB62,BYTE19",
                "name": "PT100_USER2_3"
            },
            {
                "addr": "DB62,BYTE20",
                "name": "PT100_USER3_0"
            },
            {
                "addr": "DB62,BYTE21",
                "name": "PT100_USER3_1"
            },
            {
                "addr": "DB62,BYTE22",
                "name": "PT100_USER3_2"
            },
            {
                "addr": "DB62,BYTE23",
                "name": "PT100_USER3_3"
            },
            {
                "addr": "DB62,BYTE24",
                "name": "Low_stage_suction_pressure_0"
            },
            {
                "addr": "DB62,BYTE25",
                "name": "Low_stage_suction_pressure_1"
            },
            {
                "addr": "DB62,BYTE26",
                "name": "Low_stage_suction_pressure_2"
            },
            {
                "addr": "DB62,BYTE27",
                "name": "Low_stage_suction_pressure_3"
            },
            {
                "addr": "DB62,BYTE28",
                "name": "Low_stage_discharge_pressure_0"
            },
            {
                "addr": "DB62,BYTE29",
                "name": "Low_stage_discharge_pressure_1"
            },
            {
                "addr": "DB62,BYTE30",
                "name": "Low_stage_discharge_pressure_2"
            },
            {
                "addr": "DB62,BYTE31",
                "name": "Low_stage_discharge_pressure_3"
            },
            {
                "addr": "DB62,BYTE32",
                "name": "High_stage_suction_pressure_0"
            },
            {
                "addr": "DB62,BYTE33",
                "name": "High_stage_suction_pressure_1"
            },
            {
                "addr": "DB62,BYTE34",
                "name": "High_stage_suction_pressure_2"
            },
            {
                "addr": "DB62,BYTE35",
                "name": "High_stage_suction_pressure_3"
            },
            {
                "addr": "DB62,BYTE36",
                "name": "High_stage_discharge_pressure_0"
            },
            {
                "addr": "DB62,BYTE37",
                "name": "High_stage_discharge_pressure_1"
            },
            {
                "addr": "DB62,BYTE38",
                "name": "High_stage_discharge_pressure_2"
            },
            {
                "addr": "DB62,BYTE39",
                "name": "High_stage_discharge_pressure_3"
            },
            {
                "addr": "DB62,BYTE40",
                "name": "User_analog_input0_0"
            },
            {
                "addr": "DB62,BYTE41",
                "name": "User_analog_input0_1"
            },
            {
                "addr": "DB62,BYTE42",
                "name": "User_analog_input0_2"
            },
            {
                "addr": "DB62,BYTE43",
                "name": "User_analog_input0_3"
            },
            {
                "addr": "DB62,BYTE44",
                "name": "User_analog_input1_0"
            },
            {
                "addr": "DB62,BYTE45",
                "name": "User_analog_input1_1"
            },
            {
                "addr": "DB62,BYTE46",
                "name": "User_analog_input1_2"
            },
            {
                "addr": "DB62,BYTE47",
                "name": "User_analog_input1_3"
            },
            {
                "addr": "DB62,BYTE48",
                "name": "User_analog_input2_0"
            },
            {
                "addr": "DB62,BYTE49",
                "name": "User_analog_input2_1"
            },
            {
                "addr": "DB62,BYTE50",
                "name": "User_analog_input2_2"
            },
            {
                "addr": "DB62,BYTE51",
                "name": "User_analog_input2_3"
            },
            {
                "addr": "DB62,BYTE52",
                "name": "User_analog_input3_0"
            },
            {
                "addr": "DB62,BYTE53",
                "name": "User_analog_input3_1"
            },
            {
                "addr": "DB62,BYTE54",
                "name": "User_analog_input3_2"
            },
            {
                "addr": "DB62,BYTE55",
                "name": "User_analog_input3_3"
            },
            {
                "addr": "DB62,BYTE56",
                "name": "User_analog_input4_0"
            },
            {
                "addr": "DB62,BYTE57",
                "name": "User_analog_input4_1"
            },
            {
                "addr": "DB62,BYTE58",
                "name": "User_analog_input4_2"
            },
            {
                "addr": "DB62,BYTE59",
                "name": "User_analog_input4_3"
            },
            {
                "addr": "DB62,BYTE60",
                "name": "Capacity_probe_0"
            },
            {
                "addr": "DB62,BYTE61",
                "name": "Capacity_probe_1"
            },
            {
                "addr": "DB62,BYTE62",
                "name": "Capacity_probe_2"
            },
            {
                "addr": "DB62,BYTE63",
                "name": "Capacity_probe_3"
            },
            {
                "addr": "DB62,BYTE64",
                "name": "Chamber_temperature_0"
            },
            {
                "addr": "DB62,BYTE65",
                "name": "Chamber_temperature_1"
            },
            {
                "addr": "DB62,BYTE66",
                "name": "Chamber_temperature_2"
            },
            {
                "addr": "DB62,BYTE67",
                "name": "Chamber_temperature_3"
            },
            {
                "addr": "DB62,BYTE68",
                "name": "Relative_humidity_0"
            },
            {
                "addr": "DB62,BYTE69",
                "name": "Relative_humidity_1"
            },
            {
                "addr": "DB62,BYTE70",
                "name": "Relative_humidity_2"
            },
            {
                "addr": "DB62,BYTE71",
                "name": "Relative_humidity_3"
            },
            {
                "addr": "DB62,BYTE72",
                "name": "Absolute_humidity_0"
            },
            {
                "addr": "DB62,BYTE73",
                "name": "Absolute_humidity_1"
            },
            {
                "addr": "DB62,BYTE74",
                "name": "Absolute_humidity_2"
            },
            {
                "addr": "DB62,BYTE75",
                "name": "Absolute_humidity_3"
            },
            {
                "addr": "DB62,BYTE104",
                "name": "Channel0_measure_0"
            },
            {
                "addr": "DB62,BYTE105",
                "name": "Channel0_measure_1"
            },
            {
                "addr": "DB62,BYTE106",
                "name": "Channel0_measure_2"
            },
            {
                "addr": "DB62,BYTE107",
                "name": "Channel0_measure_3"
            },
            {
                "addr": "DB62,BYTE108",
                "name": "Channel1_measure_0"
            },
            {
                "addr": "DB62,BYTE109",
                "name": "Channel1_measure_1"
            },
            {
                "addr": "DB62,BYTE110",
                "name": "Channel1_measure_2"
            },
            {
                "addr": "DB62,BYTE111",
                "name": "Channel1_measure_3"
            },
            {
                "addr": "DB62,X128.0",
                "name": "Safety_temperature_switch"
            },
            {
                "addr": "DB62,X128.1",
                "name": "Overload_cutout"
            },
            {
                "addr": "DB62,X128.2",
                "name": "Thermal_cutout"
            },
            {
                "addr": "DB62,X128.3",
                "name": "Power_fail"
            },
            {
                "addr": "DB62,X128.4",
                "name": "Emergency_switch"
            },
            {
                "addr": "DB62,X128.5",
                "name": "Door_open"
            },
            {
                "addr": "DB62,X128.6",
                "name": "Max_temperature"
            },
            {
                "addr": "DB62,X128.7",
                "name": "Adjustable_max_temperature"
            },
            {
                "addr": "DB62,X129.0",
                "name": "Adjustable_min_temperature"
            },
            {
                "addr": "DB62,X129.1",
                "name": "Pt100_dry_bulb_sensor_fail"
            },
            {
                "addr": "DB62,X129.2",
                "name": "TC_dut_sensor_fail"
            },
            {
                "addr": "DB62,X129.3",
                "name": "Pt100_wet_bulb_sensor_fail"
            },
            {
                "addr": "DB62,X129.4",
                "name": "Salt_solution_min_level"
            },
            {
                "addr": "DB62,X129.5",
                "name": "Water_lack"
            },
            {
                "addr": "DB62,X129.6",
                "name": "Steam_generator_max_temperature"
            },
            {
                "addr": "DB62,X129.7",
                "name": "Low_stage_compressor_min_oil_pressure"
            },
            {
                "addr": "DB62,X130.0",
                "name": "Low_stage_compressor_overload_cutout"
            },
            {
                "addr": "DB62,X130.1",
                "name": "Low_stage_compressor_thermal_cutout"
            },
            {
                "addr": "DB62,X130.2",
                "name": "Low_stage_fan_compressor_overload_cutout"
            },
            {
                "addr": "DB62,X130.3",
                "name": "Max_low_stage_pressure"
            },
            {
                "addr": "DB62,X130.4",
                "name": "Min_low_stage_pressure"
            },
            {
                "addr": "DB62,X130.5",
                "name": "Max_low_stage_discharge_temperature"
            },
            {
                "addr": "DB62,X130.6",
                "name": "High_stage_compressor_min_oil_pressure"
            },
            {
                "addr": "DB62,X130.7",
                "name": "High_stage_compressor_overload_cutout"
            },
            {
                "addr": "DB62,X131.0",
                "name": "High_stage_compressor_thermal_cutout"
            },
            {
                "addr": "DB62,X131.1",
                "name": "High_stage_fan_compressor_overload_cutout"
            },
            {
                "addr": "DB62,X131.2",
                "name": "High_stage_max_pressure"
            },
            {
                "addr": "DB62,X131.3",
                "name": "High_stage_min_pressure"
            },
            {
                "addr": "DB62,X131.4",
                "name": "Max_high_stage_discharge_temperature"
            },
            {
                "addr": "DB62,X131.5",
                "name": "Intermediate_fluid_overtemperature"
            },
            {
                "addr": "DB62,X131.6",
                "name": "Intermediate_fluid_undertemperature"
            },
            {
                "addr": "DB62,X131.7",
                "name": "Max_intermediate_fluid_level"
            },
            {
                "addr": "DB62,X132.0",
                "name": "Min_intermediate_fluid_level"
            },
            {
                "addr": "DB62,X132.1",
                "name": "Intermediate_fluid_overpressure"
            },
            {
                "addr": "DB62,X132.2",
                "name": "Intermediate_fluid_underpressure"
            },
            {
                "addr": "DB62,X132.3",
                "name": "Intermediate_fluid_pump_overload_cutout"
            },
            {
                "addr": "DB62,X132.4",
                "name": "Intermediate_fluid_pump_thermal_cutout"
            },
            {
                "addr": "DB62,X132.5",
                "name": "Condenser_fan_overload_cutout"
            },
            {
                "addr": "DB62,X132.6",
                "name": "Water_lack_pre-alarm"
            },
            {
                "addr": "DB62,X132.7",
                "name": "Min_condenser_water_flow"
            },
            {
                "addr": "DB62,X133.0",
                "name": "Min_compressed_air_pressure"
            },
            {
                "addr": "DB62,X133.1",
                "name": "Min_differential_pressure"
            },
            {
                "addr": "DB62,X133.2",
                "name": "Min_liquid_nytrogen_pressure"
            },
            {
                "addr": "DB62,X133.3",
                "name": "Smoke_detector"
            },
            {
                "addr": "DB62,X133.4",
                "name": "Max_CO_concentration"
            },
            {
                "addr": "DB62,X133.5",
                "name": "Min_oxygen_concentration"
            },
            {
                "addr": "DB62,X133.6",
                "name": "Inverter_fail"
            },
            {
                "addr": "DB62,X133.7",
                "name": "Vacuum_pump_overload_cutout"
            },
            {
                "addr": "DB62,X134.0",
                "name": "Vacuum_pump_thermal_cutout"
            },
            {
                "addr": "DB62,X134.1",
                "name": "Vacuum_pump_warmup"
            },
            {
                "addr": "DB62,X134.2",
                "name": "Ventilation_lack"
            },
            {
                "addr": "DB62,X134.3",
                "name": "Air_filter"
            },
            {
                "addr": "DB62,X134.4",
                "name": "Low_stage_compressor_start-up_failure"
            },
            {
                "addr": "DB62,X134.5",
                "name": "High_stage_compressor_start-up_failure"
            },
            {
                "addr": "DB62,X134.6",
                "name": "Movement_timeout"
            },
            {
                "addr": "DB62,X134.7",
                "name": "Defrosting_in_progress"
            },
            {
                "addr": "DB62,X135.0",
                "name": "Defrosting_timeout"
            },
            {
                "addr": "DB62,X135.1",
                "name": "Capacitive_probe_temperature_out_of_range"
            },
            {
                "addr": "DB62,X135.2",
                "name": "Acceleration_critical_deviation"
            },
            {
                "addr": "DB62,X135.3",
                "name": "Oxygen_min._concentration_(Non_critical)"
            },
            {
                "addr": "DB62,X135.4",
                "name": "Hardware_alarm_(WinSmartkit)"
            },
            {
                "addr": "DB62,X137.4",
                "name": "Remote_mode_control"
            },
            {
                "addr": "DB62,X137.5",
                "name": "Abort_test_in_program_mode"
            },
            {
                "addr": "DB62,X137.6",
                "name": "End_test"
            },
            {
                "addr": "DB62,X137.7",
                "name": "Critical_alarm"
            }
        ]
    },
    {
        "id": "cd79e9901663568e",
        "type": "ui_group",
        "name": "Group 1",
        "tab": "70cc5f9e2792ba6a",
        "order": 1,
        "disp": true,
        "width": 6
    },
    {
        "id": "70cc5f9e2792ba6a",
        "type": "ui_tab",
        "name": "Alarms",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

The dashboard :

Thank you for your help :slight_smile:

Set th ui-switch to not pass through payload, and set to react to state of input.

e.g.

[{"id":"91ee2be7177eb5ba","type":"ui_switch","z":"94c53e1fb7cccfbc","name":"","label":"Door open","tooltip":"","group":"cd79e9901663568e","order":23,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":850,"y":660,"wires":[[]]},{"id":"cd79e9901663568e","type":"ui_group","name":"Group 1","tab":"70cc5f9e2792ba6a","order":1,"disp":true,"width":6},{"id":"70cc5f9e2792ba6a","type":"ui_tab","name":"Alarms","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Sorry, I do not understand. Please try and explain again in more detail.

Also there is no point in exporting a large flow containing nodes that we are unlikely to have installed. Try and build a simple flow with just a few nodes, using Inject nodes to feed in values and debug nodes to see the result. If you can do that and tell us what you want to happen then it will be easier for us to help.

Sorry, I will try to explain it better.

For instance, I'd like to know if the door is opened or not thanks to a captor "Door open".
If the door is opened, the value returned will be TRUE, otherwise FALSE.

I created a flow (with inject nodes) for illustrating this :

[
    {
        "id": "385e0e4a056f1e80",
        "type": "inject",
        "z": "94c53e1fb7cccfbc",
        "name": "Door opened",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 270,
        "y": 1000,
        "wires": [
            [
                "265aa74b814f4264"
            ]
        ]
    },
    {
        "id": "ecf05621ef86f89a",
        "type": "inject",
        "z": "94c53e1fb7cccfbc",
        "name": "Door closed",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 270,
        "y": 1060,
        "wires": [
            [
                "265aa74b814f4264"
            ]
        ]
    },
    {
        "id": "265aa74b814f4264",
        "type": "ui_switch",
        "z": "94c53e1fb7cccfbc",
        "name": "",
        "label": "Door opened or closed",
        "tooltip": "",
        "group": "20d793545cef9dd3",
        "order": 28,
        "width": 0,
        "height": 0,
        "passthru": false,
        "decouple": "true",
        "topic": "topic",
        "topicType": "msg",
        "style": "",
        "onvalue": "true",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "false",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "animate": false,
        "className": "",
        "x": 520,
        "y": 1020,
        "wires": [
            []
        ]
    },
    {
        "id": "20d793545cef9dd3",
        "type": "ui_group",
        "name": "Default",
        "tab": "754bf002dd819293",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "754bf002dd819293",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

By the way, the solution that suggested E1cid works with inject nodes (so in this example too).
However, it doesn't work with the boolean values that I read from my PLC.

For instance, this is the path to get the value of "Door_open" : payload.Door_open
I used a change node to put this value into just "payload", in order to link it to the switch UI.
Otherwise, I don't know how to do to differentiate each value.

Does it more meaningful now ?

It would help to show us the boolean values from PLC.

I can not see the source of the object in that image.

Why post an image, when you can copy the payload value and post it here as text. We can then copy it for testing, no guessing no typo's.

I suspect the path to the boolean is not correct.

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

{"Door_open":true,}

The value returned is true whereas on the switch UI it's off. I thought it was more convenient for you to see a picture rather than just a value.

Moreover, I've already saw all these pages many times... If I create a topic, it is because I didn't find the answer through them and my researches... I know how to get the value from an object and print it with a debug node for example, but it doesn't work with the UI switch.

And what property is that value in?
It would be easier and less guessing to set the debug to complete message object, then copy the msg value. We would then have a complete insight in to where and what was in the msg.

Try copy path to get the path to the boolean, then use that path to move to payload.

In the change node I had to move the value rather than set the value, it was the mistake. It perfectly works now.

Thanks E1cid !

If you pass msg.payload true or false to a correctly set up dashboard switch node it will show the input value.

image

image

[{"id":"dc61841217f183b2","type":"ui_switch","z":"b7c21fe4372f10e8","name":"","label":"true=on false=off","tooltip":"","group":"a33b70ec7afeecf9","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":770,"y":60,"wires":[[]]},{"id":"67a2e36025fe154c","type":"ui_switch","z":"b7c21fe4372f10e8","name":"","label":"true=off false=on","tooltip":"","group":"a33b70ec7afeecf9","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic","topicType":"msg","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":770,"y":120,"wires":[[]]},{"id":"6a02a166932e6f67","type":"ui_button","z":"b7c21fe4372f10e8","name":"","group":"a33b70ec7afeecf9","order":2,"width":"2","height":"1","passthru":false,"label":"true","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"true","payloadType":"bool","topic":"topic","topicType":"msg","x":550,"y":60,"wires":[["dc61841217f183b2","67a2e36025fe154c"]]},{"id":"9a49b904f4173fce","type":"ui_button","z":"b7c21fe4372f10e8","name":"","group":"a33b70ec7afeecf9","order":2,"width":"2","height":"1","passthru":false,"label":"false","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"false","payloadType":"bool","topic":"topic","topicType":"msg","x":550,"y":120,"wires":[["67a2e36025fe154c","dc61841217f183b2"]]},{"id":"a33b70ec7afeecf9","type":"ui_group","name":"Demo","tab":"682e93cdaaeac1ae","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"682e93cdaaeac1ae","type":"ui_tab","name":"Demo","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.