Timing Question?

hi all..

i have Node Red connected to OBS using websockets.. i have a basic flow to change between three OBS scenes.. the flow mostly works but im seeing some problems..

If i have the transition in OBS to be a fade, say 2 seconds duration.. when I fade from scene A to scene B, if i press scene C during the 2 seconds this interrupts the original fade.. i want the first transition to complete without interruption so i added a context variable to try and stop this..

The variable (in theory) should prevent other inputs while the initial transition is in progress and then allow new inputs at the end of the transition.. It kinda works but ive noticed if you button mash between the 3 scenes during the 2 second fade it will get stuck at times and not reset properly.. it seems like a timing thing around when the variable is being stored and retrieved..

Obviously the easy answer is dont button mash.. i dont plan to do that but i would also like the flow to be robust so no bad inputs trip it up.. would anyone know whats happening and also what would be a good way to fix it ?


[
    {
        "id": "f3843b2dde420604",
        "type": "tab",
        "label": "Flow 5",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "1b74465076378299",
        "type": "change",
        "z": "f3843b2dde420604",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "scene",
                "pt": "flow",
                "to": "0",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 680,
        "y": 500,
        "wires": [
            [
                "35b36ded1a84ebf7"
            ]
        ]
    },
    {
        "id": "bfe2117bc0f72a41",
        "type": "switch",
        "z": "f3843b2dde420604",
        "name": "",
        "property": "scene",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 510,
        "y": 500,
        "wires": [
            [
                "1b74465076378299"
            ]
        ]
    },
    {
        "id": "4c8ecccfc6d1f309",
        "type": "change",
        "z": "f3843b2dde420604",
        "name": "Reset Scene",
        "rules": [
            {
                "t": "set",
                "p": "scene",
                "pt": "flow",
                "to": "1",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 770,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "ebf52d2368c83990",
        "type": "switch",
        "z": "f3843b2dde420604",
        "name": "",
        "property": "scene",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 510,
        "y": 460,
        "wires": [
            [
                "689bcba28fd47f79"
            ]
        ]
    },
    {
        "id": "689bcba28fd47f79",
        "type": "change",
        "z": "f3843b2dde420604",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "scene",
                "pt": "flow",
                "to": "0",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 680,
        "y": 460,
        "wires": [
            [
                "59630c7db7a972d3"
            ]
        ]
    },
    {
        "id": "c7b1c5706eefd018",
        "type": "obs connection status",
        "z": "f3843b2dde420604",
        "name": "",
        "obsInstance": "beb40fb0849fb564",
        "x": 480,
        "y": 220,
        "wires": [
            [
                "27f1284f7c8066de"
            ]
        ]
    },
    {
        "id": "f9820109602da506",
        "type": "inject",
        "z": "f3843b2dde420604",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 320,
        "y": 460,
        "wires": [
            [
                "ebf52d2368c83990"
            ]
        ]
    },
    {
        "id": "fcc20dc9ea8a289b",
        "type": "inject",
        "z": "f3843b2dde420604",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 320,
        "y": 500,
        "wires": [
            [
                "bfe2117bc0f72a41"
            ]
        ]
    },
    {
        "id": "59630c7db7a972d3",
        "type": "SetCurrentProgramScene",
        "z": "f3843b2dde420604",
        "name": "Left Cam",
        "scene": "Left CAM OP",
        "sceneType": "sceneName",
        "obsInstance": "beb40fb0849fb564",
        "x": 960,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "35b36ded1a84ebf7",
        "type": "SetCurrentProgramScene",
        "z": "f3843b2dde420604",
        "name": "Right Cam",
        "scene": "Right CAM OP",
        "sceneType": "sceneName",
        "obsInstance": "beb40fb0849fb564",
        "x": 970,
        "y": 500,
        "wires": [
            []
        ]
    },
    {
        "id": "727954a46cbfb484",
        "type": "obs event",
        "z": "f3843b2dde420604",
        "name": "",
        "event": "SceneTransitionEnded",
        "obsInstance": "beb40fb0849fb564",
        "x": 480,
        "y": 280,
        "wires": [
            [
                "4c8ecccfc6d1f309"
            ]
        ]
    },
    {
        "id": "27f1284f7c8066de",
        "type": "change",
        "z": "f3843b2dde420604",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "scene",
                "pt": "flow",
                "to": "1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 220,
        "wires": [
            []
        ]
    },
    {
        "id": "693bbb945f3bfd2e",
        "type": "switch",
        "z": "f3843b2dde420604",
        "name": "",
        "property": "scene",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 510,
        "y": 420,
        "wires": [
            [
                "bb0c660449eb4177"
            ]
        ]
    },
    {
        "id": "bb0c660449eb4177",
        "type": "change",
        "z": "f3843b2dde420604",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "scene",
                "pt": "flow",
                "to": "0",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 680,
        "y": 420,
        "wires": [
            [
                "130078284492b0ac"
            ]
        ]
    },
    {
        "id": "42b55c21324980a5",
        "type": "inject",
        "z": "f3843b2dde420604",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 320,
        "y": 420,
        "wires": [
            [
                "693bbb945f3bfd2e"
            ]
        ]
    },
    {
        "id": "130078284492b0ac",
        "type": "SetCurrentProgramScene",
        "z": "f3843b2dde420604",
        "name": "Rear Cam",
        "scene": "Drums",
        "sceneType": "sceneName",
        "obsInstance": "beb40fb0849fb564",
        "x": 970,
        "y": 420,
        "wires": [
            []
        ]
    },
    {
        "id": "beb40fb0849fb564",
        "type": "obs-instance",
        "name": "OBS Instance",
        "host": "192.168.178.26",
        "port": "4455"
    }
]

Hi, EaEB11

Im not totaly up on OBS, Can you get feedback from OBS websockets when its completed its transition?

If you cant, the only way I can think to do it is put some gate nodes that inhibit other commands for 2 secs

i have an OBS SceneTransitionEnded node which does what you are saying.. resets the variable at the completion of the transition.. I also have switch nodes after each scene button to prevent inputs until the transition is complete and resets the variable..

i think the design is generally right but if i mash the three scene buttons one gets through occasionally.. i think its because a button press occurs at an exact moment while context is changing.. im not planning to mash buttons but there is always the chance something accidental happens so id like it to be as foolproof as possible..

plan B is make another button to manually reset the context if this situation occurs but it would be good to avoid that if possible..

Why not rate limit the messages for a several seconds using the delay node.

You can feed msg.flush = 1(no other message properties) into the delay node after receiving a transition completed event, this will release the the next message after the transition. and if no event is reported the delay node will release the next message by default after the default rate limit.

1 Like

I did try a rate limit at 1 msg per second and discard other messages.. it didnt seem to work though which i thought was odd..

i think what i had using a variable is the same concept as delay flush. use the OBS node to trigger the change when the transition is done.. i'll send it to delay flush instead, maybe it reacts different than setting the flow variable..

Another possibility is to disable the relevant buttons until the transition is complete.

Here is an example that may work (untested as no OBS).
It may give you some ideas how to structure a flow better.

[{"id":"727954a46cbfb484","type":"obs event","z":"f3843b2dde420604","name":"","event":"SceneTransitionEnded","obsInstance":"beb40fb0849fb564","x":480,"y":280,"wires":[["cceb9b970ab7e572"]]},{"id":"cceb9b970ab7e572","type":"function","z":"f3843b2dde420604","name":"function 1","func":"\nreturn {flush:1}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":280,"wires":[["fd0a170ccc61eb0e"]]},{"id":"fd0a170ccc61eb0e","type":"delay","z":"f3843b2dde420604","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"3","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":740,"y":420,"wires":[["130078284492b0ac"]]},{"id":"42b55c21324980a5","type":"inject","z":"f3843b2dde420604","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Drums","payloadType":"str","x":470,"y":420,"wires":[["fd0a170ccc61eb0e"]]},{"id":"f9820109602da506","type":"inject","z":"f3843b2dde420604","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Left CAM OP","payloadType":"str","x":450,"y":460,"wires":[["fd0a170ccc61eb0e"]]},{"id":"fcc20dc9ea8a289b","type":"inject","z":"f3843b2dde420604","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Right CAM OP","payloadType":"str","x":450,"y":520,"wires":[["fd0a170ccc61eb0e"]]},{"id":"130078284492b0ac","type":"SetCurrentProgramScene","z":"f3843b2dde420604","name":"Cams","scene":"payload","sceneType":"msg","obsInstance":"beb40fb0849fb564","x":960,"y":420,"wires":[[]]},{"id":"beb40fb0849fb564","type":"obs-instance","name":"OBS Instance","host":"192.168.178.26","port":"4455"}]