Changing the pass through behaviour of a multistate switch

I'm new to developing nodes and would very much appericate a helping hand. My objective is to change the exisiting multistate switch module so that it would incorporate the same pass through feature as the ui_switch module. The desired result is as follows:

  • no messages are pass through
  • the user interface, i.e. the "icon", shows the state of the input message

To start with, I would need to understand the following. What part of ui_switch.html and/or ui_switch.js "prevents" the state icon from changing from off to on in the following example?

[
    {
        "id": "4e92b883d06ffe99",
        "type": "inject",
        "z": "822bc1ad5f56e898",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 310,
        "y": 280,
        "wires": [
            [
                "15a5658ebe1b3fa9",
                "11fa7d2da42c9ef4"
            ]
        ]
    },
    {
        "id": "11fa7d2da42c9ef4",
        "type": "ui_multistate_switch",
        "z": "822bc1ad5f56e898",
        "name": "Multistate switch",
        "group": "512e9e663b47903c",
        "order": 6,
        "width": 0,
        "height": 1,
        "label": "switch",
        "stateField": "payload",
        "enableField": "enable",
        "passthroughField": "passthrough",
        "inputMsgField": "inputmsg",
        "rounded": true,
        "useThemeColors": true,
        "hideSelectedLabel": false,
        "multilineLabel": false,
        "passThrough": "always",
        "inputMsg": "all",
        "userInput": "enabled_show",
        "options": [
            {
                "label": "FALSE",
                "value": "false",
                "valueType": "bool",
                "color": "#009933"
            },
            {
                "label": "TRUE",
                "value": "true",
                "valueType": "bool",
                "color": "#999999"
            }
        ],
        "topic": "",
        "x": 590,
        "y": 340,
        "wires": [
            [
                "eb87e38c66bae324"
            ]
        ]
    },
    {
        "id": "15a5658ebe1b3fa9",
        "type": "ui_switch",
        "z": "822bc1ad5f56e898",
        "name": "",
        "label": "simple switch (no pass through, icon shows state of input)",
        "tooltip": "",
        "group": "512e9e663b47903c",
        "order": 15,
        "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": 730,
        "y": 280,
        "wires": [
            [
                "f685404e048b5243",
                "ad08d9a3189a5588"
            ]
        ]
    },
    {
        "id": "c0efebd66f52f5c3",
        "type": "inject",
        "z": "822bc1ad5f56e898",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 310,
        "y": 340,
        "wires": [
            [
                "11fa7d2da42c9ef4",
                "15a5658ebe1b3fa9"
            ]
        ]
    },
    {
        "id": "f685404e048b5243",
        "type": "debug",
        "z": "822bc1ad5f56e898",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1090,
        "y": 280,
        "wires": []
    },
    {
        "id": "eb87e38c66bae324",
        "type": "debug",
        "z": "822bc1ad5f56e898",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1090,
        "y": 340,
        "wires": []
    },
    {
        "id": "ad08d9a3189a5588",
        "type": "delay",
        "z": "822bc1ad5f56e898",
        "name": "Simulation of Eltako FSR14x acutuator",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 1190,
        "y": 160,
        "wires": [
            [
                "15a5658ebe1b3fa9"
            ]
        ]
    },
    {
        "id": "512e9e663b47903c",
        "type": "ui_group",
        "name": "Yleisohjaus",
        "tab": "fa7d8b45bcb564c4",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": true,
        "className": ""
    },
    {
        "id": "fa7d8b45bcb564c4",
        "type": "ui_tab",
        "name": "Valot",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

I haven't used that node, but looking at the readme is that not what this selection under User Input does?

Enabled but don't show : The user input will be accepted, but the new state will not be visualized. This could be used if the switch needs to show the real state. As soon as the real state changes, it will be injected into the switch node which will visually switch to the new state

1 Like