biddster / node-red-contrib-schedex

Scheduler for node-red which allows you to enter on/off times as 24hr clock (e.g. 01:10) or suncalc events (e.g. goldenHour). It also allows you to offset times and randomise the time within the offset.
23 stars 17 forks source link

Schedex is triggering in a weekend even when the displayed "on time" is the following monday #51

Closed ricmik closed 5 years ago

ricmik commented 5 years ago

Hi,

I have some schedex nodes that I configure programatically. There are multiple inputs that will configure weekend on/off, suspend on/off and time in HH:mm. For some reason the schedex node triggers on saturdays and sundays even when the input is to disable saturday and sunday. I migrated my custom docker Home Assistant install to a Hass.io install with the Node-RED add on. This flow worked fine in the custom docker install, but no longer in the Hass.io install.

As you can see in the screenshot, the ON and OFF time of the schedex node on the bottom are 2019-06-10 05:00, but the schedex node triggered at 2019-06-09 05:30 as you can see on the following node even when the displayed time were as shown in the screenshot. I can't really figure out why the time it triggered also is 30 minutes later than configured.

Maybe something has changed in the schedex code since my previous install? Or maybe something is incorrect with timezone settings in Node-RED? I configured the timezone for Node-RED by adding process.env.TZ = "Europe/Oslo"; in settings.js since it was using UTC by default.

Screenshot
biddster commented 5 years ago

Thanks for the report.

Do you have the offsets set to 0 in the schedex configuration? Check as that might explain the 30 minute offset?

I'll have to work up a unit test to simulate your situation.

ricmik commented 5 years ago

Hi @biddster ! Thanks for your reply.

The offsets are set to 0 in the schedex configuration, and I'm not configuring the offsets programatically.

I have exported the relevant nodes here if that's of any help:

[
    {
        "id": "a4311c2d.30a7f",
        "type": "inject",
        "z": "7e837918.8ccf08",
        "name": "Start soloppgang",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "30 05 * * *",
        "once": false,
        "onceDelay": 0.1,
        "x": 130,
        "y": 140,
        "wires": [
            [
                "2eba467c.50e12a"
            ]
        ]
    },
    {
        "id": "2eba467c.50e12a",
        "type": "api-current-state",
        "z": "7e837918.8ccf08",
        "name": "Noen hjemme?",
        "server": "e093419b.35fb5",
        "version": "1",
        "outputs": 2,
        "halt_if": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "group.family",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 660,
        "y": 120,
        "wires": [
            [
                "cbf5b083.31698"
            ],
            []
        ],
        "outputLabels": [
            "",
            "Ja"
        ]
    },
    {
        "id": "c6b944c3.984678",
        "type": "inject",
        "z": "7e837918.8ccf08",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "60",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 106,
        "y": 247,
        "wires": [
            [
                "7ef7c963.b255f8"
            ]
        ]
    },
    {
        "id": "7ef7c963.b255f8",
        "type": "api-current-state",
        "z": "7e837918.8ccf08",
        "name": "Alarm aktivert?",
        "server": "e093419b.35fb5",
        "version": 1,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "input_boolean.wakeup_routine",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 120,
        "y": 300,
        "wires": [
            [
                "753fda12.142dc4"
            ],
            [
                "78060d6b.8f9414"
            ]
        ]
    },
    {
        "id": "3da93870.189dd8",
        "type": "api-current-state",
        "z": "7e837918.8ccf08",
        "name": "Hent vekketid",
        "server": "e093419b.35fb5",
        "version": "1",
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "input_datetime.wakeup_time",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 120,
        "y": 420,
        "wires": [
            [
                "45bd1c1a.7df174",
                "52469455.52d1dc",
                "bdad6354.f0148",
                "876976d1.7e8298"
            ]
        ]
    },
    {
        "id": "45bd1c1a.7df174",
        "type": "moment",
        "z": "7e837918.8ccf08",
        "name": "Vekketid -1 time",
        "topic": "",
        "input": "payload",
        "inputType": "msg",
        "inTz": "Europe/Oslo",
        "adjAmount": "1",
        "adjType": "hours",
        "adjDir": "subtract",
        "format": "HH:mm",
        "locale": "C",
        "output": "payload",
        "outputType": "msg",
        "outTz": "Europe/Oslo",
        "x": 120,
        "y": 480,
        "wires": [
            [
                "1af9c335.d3b97d"
            ]
        ]
    },
    {
        "id": "52469455.52d1dc",
        "type": "moment",
        "z": "7e837918.8ccf08",
        "name": "Vekketid -30 minutter",
        "topic": "",
        "input": "payload",
        "inputType": "msg",
        "inTz": "Europe/Oslo",
        "adjAmount": "30",
        "adjType": "minutes",
        "adjDir": "subtract",
        "format": "HH:mm",
        "locale": "C",
        "output": "payload",
        "outputType": "msg",
        "outTz": "Europe/Oslo",
        "x": 140,
        "y": 520,
        "wires": [
            [
                "c7740059.3bec6"
            ]
        ]
    },
    {
        "id": "bdad6354.f0148",
        "type": "moment",
        "z": "7e837918.8ccf08",
        "name": "Vekketid -15 minutter",
        "topic": "",
        "input": "payload",
        "inputType": "msg",
        "inTz": "Europe/Oslo",
        "adjAmount": "15",
        "adjType": "minutes",
        "adjDir": "subtract",
        "format": "HH:mm",
        "locale": "C",
        "output": "payload",
        "outputType": "msg",
        "outTz": "Europe/Oslo",
        "x": 140,
        "y": 560,
        "wires": [
            [
                "804162bc.195ce"
            ]
        ]
    },
    {
        "id": "876976d1.7e8298",
        "type": "moment",
        "z": "7e837918.8ccf08",
        "name": "Vekketid",
        "topic": "",
        "input": "payload",
        "inputType": "msg",
        "inTz": "Europe/Oslo",
        "adjAmount": 0,
        "adjType": "days",
        "adjDir": "add",
        "format": "HH:mm",
        "locale": "C",
        "output": "payload",
        "outputType": "msg",
        "outTz": "Europe/Oslo",
        "x": 100,
        "y": 600,
        "wires": [
            [
                "4dc4c416.9545cc"
            ]
        ]
    },
    {
        "id": "87b3817b.675ff",
        "type": "schedex",
        "z": "7e837918.8ccf08",
        "name": "",
        "suspended": false,
        "lat": "",
        "lon": "",
        "ontime": "",
        "ontopic": "",
        "onpayload": "",
        "onoffset": 0,
        "onrandomoffset": 0,
        "offtime": "",
        "offtopic": "",
        "offpayload": "",
        "offoffset": 0,
        "offrandomoffset": 0,
        "mon": true,
        "tue": true,
        "wed": true,
        "thu": true,
        "fri": true,
        "sat": true,
        "sun": true,
        "x": 490,
        "y": 480,
        "wires": [
            [
                "2eba467c.50e12a"
            ]
        ]
    },
    {
        "id": "d0e8c1a0.9383c",
        "type": "schedex",
        "z": "7e837918.8ccf08",
        "name": "",
        "suspended": false,
        "lat": "",
        "lon": "",
        "ontime": "",
        "ontopic": "",
        "onpayload": "",
        "onoffset": 0,
        "onrandomoffset": 0,
        "offtime": "",
        "offtopic": "",
        "offpayload": "",
        "offoffset": 0,
        "offrandomoffset": 0,
        "mon": true,
        "tue": true,
        "wed": true,
        "thu": true,
        "fri": true,
        "sat": true,
        "sun": true,
        "x": 490,
        "y": 520,
        "wires": [
            [
                "3ebc3a17.bf16e6"
            ]
        ]
    },
    {
        "id": "7182dc4e.41eb34",
        "type": "schedex",
        "z": "7e837918.8ccf08",
        "name": "",
        "suspended": false,
        "lat": "",
        "lon": "",
        "ontime": "",
        "ontopic": "",
        "onpayload": "",
        "onoffset": 0,
        "onrandomoffset": 0,
        "offtime": "",
        "offtopic": "",
        "offpayload": "",
        "offoffset": 0,
        "offrandomoffset": 0,
        "mon": true,
        "tue": true,
        "wed": true,
        "thu": true,
        "fri": true,
        "sat": true,
        "sun": true,
        "x": 490,
        "y": 560,
        "wires": [
            []
        ]
    },
    {
        "id": "f10c06a0.db8bb8",
        "type": "schedex",
        "z": "7e837918.8ccf08",
        "name": "",
        "suspended": false,
        "lat": "",
        "lon": "",
        "ontime": "",
        "ontopic": "",
        "onpayload": "testON",
        "onoffset": 0,
        "onrandomoffset": 0,
        "offtime": "",
        "offtopic": "",
        "offpayload": "testOFF",
        "offoffset": 0,
        "offrandomoffset": 0,
        "mon": true,
        "tue": true,
        "wed": true,
        "thu": true,
        "fri": true,
        "sat": true,
        "sun": true,
        "x": 490,
        "y": 600,
        "wires": [
            []
        ]
    },
    {
        "id": "1af9c335.d3b97d",
        "type": "change",
        "z": "7e837918.8ccf08",
        "name": "Set timer",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\t   \"suspended\":false,\t   \"ontime\":msg.payload,\t   \"offtime\":msg.payload\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 480,
        "wires": [
            [
                "87b3817b.675ff"
            ]
        ]
    },
    {
        "id": "c7740059.3bec6",
        "type": "change",
        "z": "7e837918.8ccf08",
        "name": "Set timer",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{    \"suspended\":false,    \"ontime\":msg.payload,    \"offtime\":msg.payload }",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 520,
        "wires": [
            [
                "d0e8c1a0.9383c"
            ]
        ]
    },
    {
        "id": "804162bc.195ce",
        "type": "change",
        "z": "7e837918.8ccf08",
        "name": "Set timer",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{    \"suspended\":false,    \"ontime\":msg.payload,    \"offtime\":msg.payload }",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 560,
        "wires": [
            [
                "7182dc4e.41eb34"
            ]
        ]
    },
    {
        "id": "4dc4c416.9545cc",
        "type": "change",
        "z": "7e837918.8ccf08",
        "name": "Set timer",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{    \"suspended\":false,    \"ontime\":msg.payload,    \"offtime\":msg.payload }",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 600,
        "wires": [
            [
                "f10c06a0.db8bb8"
            ]
        ]
    },
    {
        "id": "78060d6b.8f9414",
        "type": "change",
        "z": "7e837918.8ccf08",
        "name": "Suspend schedules",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "suspended true",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 350,
        "y": 300,
        "wires": [
            [
                "87b3817b.675ff",
                "d0e8c1a0.9383c",
                "7182dc4e.41eb34",
                "f10c06a0.db8bb8"
            ]
        ]
    },
    {
        "id": "3ebc3a17.bf16e6",
        "type": "api-current-state",
        "z": "7e837918.8ccf08",
        "name": "Noen hjemme?",
        "server": "e093419b.35fb5",
        "version": "1",
        "outputs": 2,
        "halt_if": "home",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "group.family",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 660,
        "y": 720,
        "wires": [
            [
                "25292a50.263586"
            ],
            []
        ],
        "outputLabels": [
            "",
            "Ja"
        ]
    },
    {
        "id": "58d27879.0845e8",
        "type": "inject",
        "z": "7e837918.8ccf08",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 440,
        "y": 720,
        "wires": [
            [
                "3ebc3a17.bf16e6"
            ]
        ]
    },
    {
        "id": "753fda12.142dc4",
        "type": "api-current-state",
        "z": "7e837918.8ccf08",
        "name": "Helg aktivert?",
        "server": "e093419b.35fb5",
        "version": 1,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "input_boolean.wakeup_weekends",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 120,
        "y": 360,
        "wires": [
            [
                "f27e8bf.5339f78",
                "3da93870.189dd8"
            ]
        ]
    },
    {
        "id": "f27e8bf.5339f78",
        "type": "change",
        "z": "7e837918.8ccf08",
        "name": "Helgetimer",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "off",
                "fromt": "str",
                "to": "{\"sat\":false,\"sun\":false}",
                "tot": "json"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "on",
                "fromt": "str",
                "to": "{\"sat\":true,\"sun\":true}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 330,
        "y": 360,
        "wires": [
            [
                "87b3817b.675ff",
                "d0e8c1a0.9383c",
                "7182dc4e.41eb34",
                "f10c06a0.db8bb8"
            ]
        ]
    },
    {
        "id": "e093419b.35fb5",
        "type": "server",
        "z": "",
        "name": "Home Assistant"
    }
]
ricmik commented 5 years ago

Actually, it seems like the schedex node triggers both at 05:00 and 05:30 when the configured time is set to 05:00.

But anyway, that does not explain the triggering in weekends. 🤔

ricmik commented 5 years ago

I'm sorry, I think this issue is due to some testing I did on the first timestamp node in my flow. I thought I had removed that setting to inject at a specific time. I will close this issue now, and see what will happen the coming weekend.