rdmtc / node-red-contrib-sun-position

This is a ultimate Node-Red Timer, Sun, Moon and Blind flow control.
Apache License 2.0
109 stars 25 forks source link

Variable not respected in rule evaluation #481

Open mvandenabeele opened 2 years ago

mvandenabeele commented 2 years ago

I have a boolean global variable that is set when we're on holidays, so the blinds would go up a bit later. This would allow us to get a little more sleep. For some reason, whatever the state of global.verlof, the rule with the later opening is always used.

Here's how the node is configured:

[ { "id": "5ceef1f7062c9faa", "type": "server-state-changed", "z": "d2f7660c.c7c468", "name": "Verlof?", "server": "9679e544.6229a8", "version": 4, "exposeToHomeAssistant": false, "haConfig": [ { "property": "name", "value": "" }, { "property": "icon", "value": "" } ], "entityidfilter": "input_boolean.verlof", "entityidfiltertype": "exact", "outputinitially": true, "state_type": "str", "haltifstate": "", "halt_if_type": "str", "halt_if_compare": "is", "outputs": 1, "output_only_on_state_change": true, "for": 0, "forType": "num", "forUnits": "minutes", "ignorePrevStateNull": false, "ignorePrevStateUnknown": false, "ignorePrevStateUnavailable": false, "ignoreCurrentStateUnknown": false, "ignoreCurrentStateUnavailable": false, "outputProperties": [ { "property": "payload", "propertyType": "msg", "value": "", "valueType": "entityState" }, { "property": "data", "propertyType": "msg", "value": "", "valueType": "eventData" }, { "property": "topic", "propertyType": "msg", "value": "", "valueType": "triggerId" } ], "x": 530, "y": 580, "wires": [ [ "bc935c7d2a61ff9b" ] ] }, { "id": "bc935c7d2a61ff9b", "type": "change", "z": "d2f7660c.c7c468", "name": "", "rules": [ { "t": "set", "p": "verlof", "pt": "global", "to": "$.payload = 'on'", "tot": "jsonata" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 700, "y": 580, "wires": [ [ "5786b06c787483ed" ] ] }, { "id": "52cb3a42.9a0494", "type": "blind-control", "z": "d2f7660c.c7c468", "name": "", "topic": "", "addIdType": "none", "addId": "", "positionConfig": "23787bb9.ec4374", "autoTrigger": false, "autoTriggerTime": "600000", "startDelayTime": "15000", "contextStore": "", "results": [ { "p": "", "pt": "msgTopic", "v": "", "vt": "topic" }, { "p": "", "pt": "msgPayload", "v": "", "vt": "level" }, { "p": "slat", "pt": "msg", "v": "", "vt": "slat" }, { "p": "blindCtrl", "pt": "msg", "v": "", "vt": "ctrlObj" } ], "blindIncrement": "1", "blindOpenPos": "100", "blindClosedPos": "0", "blindPosReverse": false, "blindPosDefault": "open (max)", "blindPosDefaultType": "levelFixed", "slatPosDefault": "", "slatPosDefaultType": "none", "overwriteExpire": "7200000", "rules": [ { "index": 0, "name": "open on civilDawn, but not before 7", "version": 3, "enabled": true, "isValid": true, "conditions": [ { "valueType": "global", "value": "verlof", "operator": "false", "operatorText": "is false", "thresholdType": "str", "threshold": "off" } ], "level": { "type": "levelFixed", "value": "closed (min)", "operator": 0, "operatorText": "↕ absolute" }, "slat": { "type": "none", "value": "" }, "topic": "", "resetOverwrite": false, "importance": 0, "time": { "type": "pdsTime", "value": "sunriseEnd", "operator": 0, "operatorText": "↥ until", "offsetType": "none", "offset": "1", "multiplier": 1, "days": "1,2,3,4,5", "months": "*" }, "timeMin": { "type": "entered", "value": "7:00", "offsetType": "none", "offset": "1", "multiplier": 60000 }, "description": "<div><i class=\"fa fa-code-fork\" aria-hidden=\"true\"></i> <var>global.verlof</var> is false</div><div><i class=\"fa fa-clock-o\" aria-hidden=\"true\"></i> ↥ until <var>sunrise end</var><div class=\"indent-time-text\"><i class=\"fa fa-step-backward\" aria-hidden=\"true\"></i> <span>at the earliest (min)</span> <var>7:00</var></div><div class=\"indent-time-days\"><i class=\"fa fa-calendar-o\" aria-hidden=\"true\"></i> <span>only on day</span> <var>Mon-Fri</var></div></div><div><div class=\"indent-level-text\"> <i class=\"fa fa-angle-down\" aria-hidden=\"true\"></i><span>blind position: </span> ↕ absolute <var>closed (min)</var></div></div>" }, { "index": 1, "name": "open on civilDawn, but not before 9", "version": 3, "enabled": true, "isValid": true, "conditions": [], "level": { "type": "levelFixed", "value": "closed (min)", "operator": 0, "operatorText": "↕ absolute" }, "slat": { "type": "none", "value": "" }, "topic": "", "resetOverwrite": false, "importance": 0, "time": { "type": "pdsTime", "value": "sunriseEnd", "operator": 0, "operatorText": "↥ until", "offsetType": "none", "offset": "1", "multiplier": 1, "days": "*", "months": "*" }, "timeMin": { "type": "entered", "value": "9:00", "offsetType": "none", "offset": "1", "multiplier": 60000 }, "description": "<div><i class=\"fa fa-clock-o\" aria-hidden=\"true\"></i> ↥ until <var>sunrise end</var><div class=\"indent-time-text\"><i class=\"fa fa-step-backward\" aria-hidden=\"true\"></i> <span>at the earliest (min)</span> <var>9:00</var></div></div><div><div class=\"indent-level-text\"> <i class=\"fa fa-angle-down\" aria-hidden=\"true\"></i><span>blind position: </span> ↕ absolute <var>closed (min)</var></div></div>" }, { "index": 2, "name": "close at blue hour, but not later than 21:00", "version": 3, "enabled": true, "isValid": true, "conditions": [], "level": { "type": "levelFixed", "value": "closed (min)", "operator": 0, "operatorText": "↕ absolute" }, "slat": { "type": "none", "value": "" }, "topic": "", "resetOverwrite": false, "importance": 0, "time": { "type": "pdsTime", "value": "goldenHourDuskEnd", "operator": 1, "operatorText": "↧ from", "offsetType": "none", "offset": "1", "multiplier": 1, "days": "*", "months": "*" }, "timeMax": { "type": "entered", "value": "21:00", "offsetType": "none", "offset": "1", "multiplier": 60000 }, "description": "<div><i class=\"fa fa-clock-o\" aria-hidden=\"true\"></i> ↧ from <var>golden hour dusk end</var><div class=\"indent-time-text\"><i class=\"fa fa-step-forward\" aria-hidden=\"true\"></i> <span>no later than (max)</span> <var>21:00</var></div></div><div><div class=\"indent-level-text\"> <i class=\"fa fa-angle-down\" aria-hidden=\"true\"></i><span>blind position: </span> ↕ absolute <var>closed (min)</var></div></div>" } ], "sunControlMode": 16, "sunFloorLengthType": "num", "sunFloorLength": "", "sunMinDelta": "", "blindPosMin": "21", "blindPosMinType": "num", "blindPosMax": "open (max)", "blindPosMaxType": "levelFixed", "blindOpenPosOffset": "", "blindClosedPosOffset": "", "sunSlat": "", "sunSlatType": "none", "smoothTime": "", "sunTopic": "", "windowTopType": "num", "windowTop": "169", "windowBottomType": "num", "windowBottom": "10", "windowAzimuthStartType": "numAzimuth", "windowAzimuthStart": "120", "windowAzimuthEndType": "numAzimuth", "windowAzimuthEnd": "286", "oversteers": [], "oversteerTopic": "", "x": 990, "y": 720, "wires": [ [ "f791b5e7.e9aaa8" ], [] ] }, { "id": "9679e544.6229a8", "type": "server", "name": "Home Assistant", "version": 4, "addon": true, "rejectUnauthorizedCerts": true, "ha_boolean": "y|yes|true|on|home|open", "connectionDelay": true, "cacheJson": true, "heartbeat": false, "heartbeatInterval": 30, "areaSelector": "friendlyName", "deviceSelector": "friendlyName", "entitySelector": "friendlyName", "statusSeparator": "at: ", "statusYear": "hidden", "statusMonth": "short", "statusDay": "numeric", "statusHourCycle": "h23", "statusTimeFormat": "h:m" }, { "id": "23787bb9.ec4374", "type": "position-config", "name": "Thuis", "isValide": "true", "longitude": "0", "latitude": "0", "angleType": "deg", "timeZoneOffset": 99, "timeZoneDST": 0, "stateTimeFormat": "3", "stateDateFormat": "12" } ]

I also tried with msg.verlof instead of global.verlof but that didn't help. Note that the msg.window_open flag does work as expected, which makes me think I'm doing something wrong.

image

image

mvandenabeele commented 2 years ago

Forgot to mention: using version 2.1.1