niklaswall / node-red-contrib-light-scheduler

Light Scheduler is a node-red node that provides a weekly schedule mainly focused on controlling light in home automation scenarios.
Apache License 2.0
41 stars 15 forks source link

Node-RED crashes in HA #79

Open FredTing opened 2 years ago

FredTing commented 2 years ago

A not fully configured light-scheduler instance can make node-RED crash.

The json snippet causing the error

    {
        "id": "3c5b0f24801f377b",
        "type": "light-scheduler",
        "z": "8eb468b2f9aede5e",
        "settings": "",
        "events": "[{\"start\":{\"dow\":1,\"mod\":420},\"end\":{\"dow\":1,\"mod\":480}},{\"start\":{\"dow\":2,\"mod\":420},\"end\":{\"dow\":2,\"mod\":480}},{\"start\":{\"dow\":3,\"mod\":420},\"end\":{\"dow\":3,\"mod\":480}},{\"start\":{\"dow\":4,\"mod\":420},\"end\":{\"dow\":4,\"mod\":480}},{\"start\":{\"dow\":5,\"mod\":420},\"end\":{\"dow\":5,\"mod\":480}},{\"start\":{\"dow\":6,\"mod\":480},\"end\":{\"dow\":6,\"mod\":540}},{\"start\":{\"dow\":0,\"mod\":480},\"end\":{\"dow\":0,\"mod\":540}},{\"start\":{\"dow\":1,\"mod\":1260},\"end\":{\"dow\":1,\"mod\":1320}},{\"start\":{\"dow\":2,\"mod\":1260},\"end\":{\"dow\":2,\"mod\":1320}},{\"start\":{\"dow\":3,\"mod\":1260},\"end\":{\"dow\":3,\"mod\":1320}},{\"start\":{\"dow\":4,\"mod\":1260},\"end\":{\"dow\":4,\"mod\":1320}},{\"start\":{\"dow\":5,\"mod\":1260},\"end\":{\"dow\":5,\"mod\":1320}},{\"start\":{\"dow\":6,\"mod\":1260},\"end\":{\"dow\":6,\"mod\":1320}},{\"start\":{\"dow\":0,\"mod\":1260},\"end\":{\"dow\":0,\"mod\":1320}}]",
        "topic": "",
        "name": "Badkamer Schedule",
        "onPayload": "",
        "onPayloadType": "json",
        "offPayload": "OFF",
        "offPayloadType": "str",
        "onlyWhenDark": true,
        "scheduleRndMax": 0,
        "sunElevationThreshold": 6,
        "sunShowElevationInStatus": false,
        "outputfreq": "output.statechange.startup",
        "x": 290,
        "y": 760,
        "wires": [
            []
        ]
    }

Error log from HA

Welcome to Node-RED
===================
27 Nov 08:46:51 - [info] Node-RED version: v2.1.3
27 Nov 08:46:51 - [info] Node.js  version: v14.18.1
27 Nov 08:46:51 - [info] Linux 5.10.17-v8 arm64 LE
27 Nov 08:46:53 - [info] Loading palette nodes
2021/11/27 08:46:56 [error] 557#557: *268 connect() failed (111: Connection refused) while connecting to upstream, client: 172.30.32.2, server: a0d7b954-nodered, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:46836/", host: "homeassistant.local:8123", referrer: "http://homeassistant.local:8123/a0d7b954_nodered"
27 Nov 08:46:57 - [info] Dashboard version 3.1.1 started at /endpoint/ui
27 Nov 08:46:58 - [info] Settings file  : /etc/node-red/config.js
27 Nov 08:46:58 - [info] Context store  : 'default' [module=memory]
27 Nov 08:46:58 - [info] User directory : /config/node-red/
27 Nov 08:46:58 - [warn] Projects disabled : editorTheme.projects.enabled=false
27 Nov 08:46:58 - [info] Flows file     : /config/node-red/flows.json
27 Nov 08:46:58 - [info] Server now running at http://127.0.0.1:46836/
27 Nov 08:46:58 - [info] Starting flows
27 Nov 08:46:58 - [info] Started flows
27 Nov 08:46:59 - [warn] [light-scheduler:Badkamer Schedule] Longitude and Latitude not configured properly, unable to take sun position into calculation!
27 Nov 08:46:59 - [red] Uncaught Exception:
27 Nov 08:46:59 - [error] SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Object.evaluateNodeProperty (/opt/node_modules/@node-red/util/lib/util.js:614:23)
    at setState (/config/node-red/node_modules/node-red-contrib-light-scheduler/light-scheduler.js:68:39)
    at Timeout.evaluate [as _onTimeout] (/config/node-red/node_modules/node-red-contrib-light-scheduler/light-scheduler.js:112:37)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
[08:47:00] INFO: Starting Node-RED...
> start
> node $NODE_OPTIONS node_modules/node-red/red.js "--settings" "/etc/node-red/config.js"
27 Nov 08:47:03 - [info]