node-red-contrib-schedex icon indicating copy to clipboard operation
node-red-contrib-schedex copied to clipboard

Emit only once

Open HarvsG opened this issue 3 years ago • 0 comments

I use the schedex node to schedule my heating to come on 45mins before the first wake up alarm in the house. However if no one is home, and so no alarms are set, the schedex node is not updated with a new schedule time, and so it will continue to emit at the same time the next day (and the next).

The result is that, if no one is home our heating has still been turning on.

Is there an easy way to make the schedex node emit only once per input?

Otherwise I will use a delay node on the output looping back to the input with msg.payload.suspended=True and then pass msg.payload.suspended=False with each alarm time.

This is my current, quite inelegant solution: image

Subflow JSON Code
[
    {
        "id": "2f794da7e733327a",
        "type": "subflow",
        "name": "Schedex only once",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 40,
                "y": 20,
                "wires": [
                    {
                        "id": "9fcfd7dba035dae7"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 620,
                "y": 180,
                "wires": [
                    {
                        "id": "cf459ec1.27a26",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [],
        "meta": {},
        "color": "#DDAA99",
        "status": {
            "x": 540,
            "y": 60,
            "wires": [
                {
                    "id": "d865f92bb79fcaaa",
                    "port": 0
                }
            ]
        }
    },
    {
        "id": "a339de3651f36661",
        "type": "change",
        "z": "2f794da7e733327a",
        "name": "payload.suspended T",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{}",
                "tot": "json"
            },
            {
                "t": "set",
                "p": "payload.suspended",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 420,
        "y": 320,
        "wires": [
            [
                "cf459ec1.27a26"
            ]
        ]
    },
    {
        "id": "cf459ec1.27a26",
        "type": "schedex",
        "z": "2f794da7e733327a",
        "name": "X Min B4 First Alarm",
        "passthroughunhandled": false,
        "suspended": false,
        "lat": "",
        "lon": "",
        "ontime": "",
        "ontopic": "",
        "onpayload": "1",
        "onoffset": "",
        "onrandomoffset": 0,
        "offtime": "",
        "offtopic": "",
        "offpayload": "",
        "offoffset": "1",
        "offrandomoffset": 0,
        "mon": true,
        "tue": true,
        "wed": true,
        "thu": true,
        "fri": true,
        "sat": true,
        "sun": true,
        "x": 440,
        "y": 180,
        "wires": [
            [
                "2b0741bfb01ad8f5"
            ]
        ]
    },
    {
        "id": "2b0741bfb01ad8f5",
        "type": "delay",
        "z": "2f794da7e733327a",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "x": 620,
        "y": 260,
        "wires": [
            [
                "a339de3651f36661"
            ]
        ]
    },
    {
        "id": "9fcfd7dba035dae7",
        "type": "change",
        "z": "2f794da7e733327a",
        "name": "payload.suspended F",
        "rules": [
            {
                "t": "set",
                "p": "payload.suspended",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 260,
        "y": 120,
        "wires": [
            [
                "cf459ec1.27a26"
            ]
        ]
    },
    {
        "id": "d865f92bb79fcaaa",
        "type": "status",
        "z": "2f794da7e733327a",
        "name": "",
        "scope": [
            "cf459ec1.27a26"
        ],
        "x": 420,
        "y": 60,
        "wires": [
            []
        ]
    }
]

HarvsG avatar Dec 25 '21 11:12 HarvsG