Variable countdown timer

Hello,
I'm new to node-red, which I use with the Rhasspy voice assistant.
I'm trying to create a countdown whose duration is variable depending on the choice made vocally.
I manage to retrieve this value from the Rhasspy sentence, but can't figure out how to use it afterwards.

None of the nodes I've tried allow you to assign a variable to the countdown, all of them offer only fixed values (node-red-contrib-mytimeout and node-red-contrib-countdown-2).
Am I missing the right node or do I need to do something different?

I'd appreciate a clue,
Thanks

The trigger node will accept msg.delay in milliseconds to set a delay before passing on the second message. so set first output to nothing and check enable override with msg.delay. You can even set a unique topic and have multiple delays.

1 Like

Thanks for your reply
Using the delay module, I managed to cobble something together.
It's probably not the best, but it works pretty well :

[
    {
        "id": "e504dd10cbae1274",
        "type": "delay",
        "z": "2b2676f81a6deb7d",
        "name": "",
        "pauseType": "delayv",
        "timeout": "0",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 740,
        "y": 980,
        "wires": [
            [
                "af57212ef76772e9"
            ]
        ]
    },
    {
        "id": "50db0c636e060eab",
        "type": "http request",
        "z": "2b2676f81a6deb7d",
        "name": "Text to Speech",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://192.168.1.22:12101/api/text-to-speech",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "basic",
        "senderr": false,
        "headers": [],
        "x": 1080,
        "y": 980,
        "wires": [
            [
                "cce696cc46725848"
            ]
        ]
    },
    {
        "id": "af57212ef76772e9",
        "type": "function",
        "z": "2b2676f81a6deb7d",
        "name": "Terminé",
        "func": "msg.payload = \"\\\"Compte à rebours de \" + (msg.delay/60000) + \" minutes terminé.\\\"\"\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 900,
        "y": 980,
        "wires": [
            [
                "50db0c636e060eab"
            ]
        ]
    },
    {
        "id": "cce696cc46725848",
        "type": "repeat",
        "z": "2b2676f81a6deb7d",
        "name": "Repeat",
        "repetitions": "1",
        "elseOutput": false,
        "outputs": 1,
        "x": 1260,
        "y": 980,
        "wires": [
            [
                "af57212ef76772e9"
            ]
        ]
    },
    {
        "id": "6f7df16989fcca0f",
        "type": "function",
        "z": "2b2676f81a6deb7d",
        "name": "Compte Ă  rebours",
        "func": "msg.delay = (msg.payload.entities[0].value*60000); // conversion millisecondes en minutes\nmsg.payload = { \"speech\": { \"text\": \"J'active un compte Ă  rebours de \" + msg.payload.entities[0].value + \" minutes\" }};\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 550,
        "y": 980,
        "wires": [
            [
                "e504dd10cbae1274",
                "f2a97ecabff94b75"
            ]
        ]
    },
    {
        "id": "f2a97ecabff94b75",
        "type": "http response",
        "z": "2b2676f81a6deb7d",
        "name": "",
        "statusCode": "",
        "headers": {},
        "x": 750,
        "y": 940,
        "wires": []
    }
]

Not to put too fine a point but the mytimeout node will accept a timeout in the msg
msg = {
payload: 'on',
timeout: 60,
warning: 0,
topic: 'timer',
}

this set the time in the node, you can set it to any value you want and also several other parameters. They are listed in the node readme.

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