Delay node, help wanted

[
    {
        "id": "a11fe5d5f925d625",
        "type": "switch",
        "z": "7b83b20cb732bf2a",
        "name": "State Check",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 330,
        "y": 4540,
        "wires": [
            [
                "7f43e84379a325f0"
            ]
        ]
    },
    {
        "id": "466c14c6527970fd",
        "type": "function",
        "z": "7b83b20cb732bf2a",
        "name": "Convert to ms",
        "func": "msg.delay = msg.payload * 3600 * 1000;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 720,
        "y": 4540,
        "wires": [
            [
                "82c75dbcb3b9b39b",
                "17f0b39b5693aa70"
            ]
        ]
    },
    {
        "id": "82c75dbcb3b9b39b",
        "type": "debug",
        "z": "7b83b20cb732bf2a",
        "name": "Debug Converted Delay",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 990,
        "y": 4680,
        "wires": []
    },
    {
        "id": "17f0b39b5693aa70",
        "type": "delay",
        "z": "7b83b20cb732bf2a",
        "name": "Delay",
        "pauseType": "delayv",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 930,
        "y": 4540,
        "wires": [
            [
                "e417af4fdca302a8"
            ]
        ]
    },
    {
        "id": "7f43e84379a325f0",
        "type": "change",
        "z": "7b83b20cb732bf2a",
        "name": "Get memory",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "#:(file)::vp_av_timer",
                "tot": "flow",
                "dc": true
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 530,
        "y": 4540,
        "wires": [
            [
                "466c14c6527970fd"
            ]
        ]
    },
    {
        "id": "6a0a75a72153f488",
        "type": "inject",
        "z": "7b83b20cb732bf2a",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "off",
        "payloadType": "str",
        "x": 930,
        "y": 4600,
        "wires": [
            [
                "e417af4fdca302a8"
            ]
        ]
    }
]

Can anyone tell me if this will work, the goal is to delay a action to run for several hours, based on the value it gets from the memory. The function node gives me this message while testing: { payload: "2.0", data: object, topic: "automation.adjust_heat_pump_te…", _msgid: "1685e656d76ca6ac", delay: 7200000 }

The only issue i see is the action , which i presume is "off" is overwritten by your change node. Why not call the flow var in the function
e.g.

[{"id":"6a0a75a72153f488","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":190,"y":4620,"wires":[["a11fe5d5f925d625"]]},{"id":"a11fe5d5f925d625","type":"switch","z":"d1395164b4eec73e","name":"State Check","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":4640,"wires":[["466c14c6527970fd"]]},{"id":"466c14c6527970fd","type":"function","z":"d1395164b4eec73e","name":"Convert to ms","func":"let vp_av_timer = flow.get(\"vp_av_timer\") ?? 0;\nmsg.delay = vp_av_timer * 3600 * 1000;\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":4640,"wires":[["82c75dbcb3b9b39b","17f0b39b5693aa70"]]},{"id":"82c75dbcb3b9b39b","type":"debug","z":"d1395164b4eec73e","name":"Debug Converted Delay","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":810,"y":4780,"wires":[]},{"id":"17f0b39b5693aa70","type":"delay","z":"d1395164b4eec73e","name":"Delay","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":750,"y":4640,"wires":[[]]}]

The action is off, when an automation gets turned off. I need to call for the value stored in memory, and after the time has run out, the automation gets turned on again. Why I havent done it like your suggestion here is lack of knowledge I believe.

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