Giter Club home page Giter Club logo

Comments (9)

rikki78 avatar rikki78 commented on July 30, 2024

I found that this only occurs the first seconds after Deploy. After +/- 5 seconds the error doesn't show anymore and the variable is set.

from node-red-contrib-pimatic.

mwittig avatar mwittig commented on July 30, 2024

Please give some more details:

  • Which node type is causing the "variable not found" error?
  • What are you accessing, i.e. a pimatic variable or device attribute which can be access via variables (deviceId.attributeId)?
  • What do you mean by "Deploy"? Is it the deployment of changes in the flow as part of node-red or do you create something on the pimatic side?

from node-red-contrib-pimatic.

rikki78 avatar rikki78 commented on July 30, 2024
  • I mean the "set variable" node.
  • It is a variable made in pimatic (lightStateWoonkamer)
  • The deployment of the flow, i.e. the red button in Node-red

from node-red-contrib-pimatic.

mwittig avatar mwittig commented on July 30, 2024

This seems to be edge case and I have problems to reporduce this. Can you please send me the example flow causing the error?

from node-red-contrib-pimatic.

rikki78 avatar rikki78 commented on July 30, 2024

Sure, here it is

[{"id":"37998bac.753654","type":"subflow","name":"Long press","info":"","in":[{"x":140,"y":300,"wires":[{"id":"34228f67.06e69"}]}],"out":[{"x":600,"y":180,"wires":[{"id":"34228f67.06e69","port":0}]},{"x":600,"y":240,"wires":[{"id":"34228f67.06e69","port":1}]},{"x":600,"y":300,"wires":[{"id":"34228f67.06e69","port":2}]},{"x":600,"y":360,"wires":[{"id":"34228f67.06e69","port":3}]},{"x":600,"y":420,"wires":[{"id":"34228f67.06e69","port":4}]}]},{"id":"34228f67.06e69","type":"function","z":"37998bac.753654","name":"detect long press","func":"\nvar timeDiff;\n\nif (msg.payload)    // switch activated\n{\n    flow.set('btnPressTime', new Date().getTime());\n}\nelse    // switch released\n{\n    timeDiff = new Date().getTime() - flow.get('btnPressTime');\n    node.warn(\"Diff \" + timeDiff + \", \" + (timeDiff / 1000).toFixed(0));\n}\nmsg.timeDiff = timeDiff;\n\nswitch ((timeDiff / 1000).toFixed(0))\n{\n    case '0':\n        return [msg, null, null, null, null];// activated\n    case '1':\n        return [null, msg, null, null, null];// 1 second\n    case '2':\n        return [null, null, msg, null, null];// 2 seconds\n    case '3':\n        return [null, null, null, msg, null];// 3 seconds\n    case '4':\n        return [null, null, null, null, msg];// 4 seconds\n    \n}\nreturn msg;","outputs":"5","noerr":0,"x":370,"y":300,"wires":[[],[],[],[],[]]},{"id":"c14dafac.f4d7b","type":"subflow","name":"Scenes","info":"","in":[{"x":500,"y":300,"wires":[{"id":"327ddc59.5d4964"}]}],"out":[{"x":1000,"y":200,"wires":[{"id":"327ddc59.5d4964","port":0}]},{"x":1000,"y":260,"wires":[{"id":"327ddc59.5d4964","port":1}]},{"x":1000,"y":320,"wires":[{"id":"327ddc59.5d4964","port":2}]},{"x":1000,"y":380,"wires":[{"id":"327ddc59.5d4964","port":3}]}]},{"id":"327ddc59.5d4964","type":"function","z":"c14dafac.f4d7b","name":"Scenes","func":"var topic;\n\nif (flow.get('sceneSettings') === undefined && msg.topic !== 'parameters') // no parameters set yet, wait for initialisation\n{\n    node.warn(\"wait for initialisation of parameters\");\n    return null;\n}\nelse if (msg.topic === 'parameters')\n{\n //   node.warn(\"initialisation\");\n    loadConfigVal();\n    return;\n}\nvar sceneSettings = flow.get('sceneSettings');\n\nif (msg.topic === 'init' || flow.get('sceneStatus') === undefined)\n{\n    createVar();\n    if (msg.topic === 'init')\n        return;\n}\nvar sceneStatus = flow.get('sceneStatus');\nvar outMsg = []; \nfor (var i = 0; i < 4; i++)\n{\n    outMsg.push({});\n    if (sceneSettings.lampValues[i] === undefined)\n        outMsg[i] = null;\n}\nif (msg.topic === 'off')\n{\n  msg.topic = 'scene';\n  msg.payload = 0;\n}\n\nif (msg.topic)\n{\n    switch (msg.topic)\n    {\n      case 'up':\n        if (msg.payload === true)\n        {\n            if (sceneStatus.scene === 0) // now off\n            {\n                if (sceneStatus.lastScene)  // only if it is set\n                    sceneStatus.scene = sceneStatus.lastScene;\n                else\n                    sceneStatus.scene = 1;\n            }\n            else\n            {    \n                sceneStatus.scene++;\n                if (sceneStatus.scene >= sceneSettings.lampValues[0].sceneValues.length)\n                    sceneStatus.scene = 1;\n            }\n            if (sceneStatus.scene)  // only if it is set\n                sceneStatus.lastScene = sceneStatus.scene;\n            for (var i in sceneSettings.lampValues)\n              outMsg[i].payload = sceneSettings.lampValues[i].sceneValues[sceneStatus.scene];\n            \n            node.warn(sceneStatus.area + \": scene up to \" + sceneStatus.scene);\n            if (msg.name)\n                node.warn(sceneStatus.area + \" from \" + msg.name);\n            if (msg.variable)\n                node.warn(sceneStatus.area + \" from \" + msg.variable);\n            \n        }\n        else\n            return null;\n        break;\n      \n      case 'down':\n        return null;\n        \n      case 'scene':\n        sceneStatus.scene = Number(msg.payload);\n        node.log(sceneStatus.area + \": activating scene \" + sceneStatus.scene);\n        for (var i in sceneSettings.lampValues)\n        {\n          outMsg[i].payload = sceneSettings.lampValues[i].sceneValues[sceneStatus.scene];\n         // node.warn(\"Setting \" + i + \" to \" + outMsg[i].payload + \"\");\n        }\n        if (sceneStatus.scene)  // only if it is set\n            sceneStatus.lastScene = sceneStatus.scene;\n        node.log(sceneStatus.area + \": scene \" + sceneStatus.scene);\n        if (msg.variable)\n            node.warn(sceneStatus.area + \" from \" + msg.variable);\n        if (msg.name)\n            node.warn(sceneStatus.area + \" from \" + msg.name);\n        break;\n     \n    }\n}\n/*\nfor (i = 0; i < sceneSettings.lampValues.length; i++)\n  node.send(outMsg[i]);\n*/\nreturn[ outMsg[0], outMsg[1], outMsg[2], outMsg[3] ];\n\n//return null;\n\nfunction createVar()\n{\n  var sceneStatus = {\n    scene : 0, \n    lastScene : 0, \n    area : 0,\n    lampValues : [{   \n        name : 0,\n        currentValue : 0\n        }]\n    };\n    for (var i = 0; i < 4; i++)\n    {\n        sceneStatus.lampValues.push({});\n\n    }\n    sceneStatus.area = sceneSettings.area;\n    flow.set('sceneStatus', sceneStatus);\n}\n\n\nfunction loadConfigVal()\n{\n  for (var i in msg.payload.parameters)\n  {\n    if (msg.payload.parameters[i].area.toLowerCase() == msg.area.toLowerCase())\n    {\n      sceneSettings = msg.payload.parameters[i];\n      //msg.payload = sceneSettings;\n      flow.set('sceneSettings', sceneSettings);\n    //  initVar();\n    }\n  }\n}\n","outputs":"4","noerr":0,"x":780,"y":300,"wires":[[],[],[],[]]},{"id":"c8498f8c.266c7","type":"change","z":"c14dafac.f4d7b","name":"up","rules":[{"t":"set","p":"topic","pt":"msg","to":"up","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":460,"wires":[[]]},{"id":"631a5362.f2e3ac","type":"change","z":"c14dafac.f4d7b","name":"down","rules":[{"t":"set","p":"topic","pt":"msg","to":"down","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":520,"wires":[[]]},{"id":"e085a674.0dcd68","type":"change","z":"c14dafac.f4d7b","name":"scene","rules":[{"t":"set","p":"topic","pt":"msg","to":"scene","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":580,"wires":[[]]},{"id":"7f24a400.bc30ec","type":"change","z":"c14dafac.f4d7b","name":"off","rules":[{"t":"set","p":"topic","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":640,"wires":[[]]},{"id":"a605cbeb.177358","type":"comment","z":"c14dafac.f4d7b","name":"Input values in topic","info":"","x":330,"y":560,"wires":[]},{"id":"342e341d.a0b50c","type":"switch","z":"c14dafac.f4d7b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"getStatus","vt":"str"},{"t":"eq","v":"getSettings","vt":"str"}],"checkall":"true","outputs":2,"x":530,"y":700,"wires":[["b3c8f894.c8f2f8"],["d996df2b.8d753"]]},{"id":"b3c8f894.c8f2f8","type":"change","z":"c14dafac.f4d7b","name":"sceneStatus","rules":[{"t":"set","p":"payload","pt":"msg","to":"sceneStatus","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":680,"wires":[["68f73dd2.06cb34"]]},{"id":"d996df2b.8d753","type":"change","z":"c14dafac.f4d7b","name":"sceneSettings","rules":[{"t":"set","p":"payload","pt":"msg","to":"sceneSettings","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":720,"wires":[["9661c419.4d19f8"]]},{"id":"68f73dd2.06cb34","type":"debug","z":"c14dafac.f4d7b","name":"","active":true,"console":"false","complete":"payload","x":890,"y":680,"wires":[]},{"id":"9661c419.4d19f8","type":"debug","z":"c14dafac.f4d7b","name":"","active":true,"console":"false","complete":"payload","x":890,"y":720,"wires":[]},{"id":"3ec21d64.945c72","type":"subflow","name":"Light states","info":"","in":[{"x":212,"y":137,"wires":[{"id":"986809b2.ae63a8"},{"id":"c73063f0.8ea41"}]}],"out":[{"x":640,"y":40,"wires":[{"id":"986809b2.ae63a8","port":0}]},{"x":639.0000095367432,"y":78.00000190734863,"wires":[{"id":"986809b2.ae63a8","port":1}]},{"x":640,"y":120,"wires":[{"id":"986809b2.ae63a8","port":2}]},{"x":640,"y":160,"wires":[{"id":"986809b2.ae63a8","port":3}]},{"x":640,"y":200,"wires":[{"id":"986809b2.ae63a8","port":4}]},{"x":640,"y":240,"wires":[{"id":"986809b2.ae63a8","port":5},{"id":"8d0fcc00.d731f","port":0},{"id":"4e459744.07d418","port":0}]}]},{"id":"986809b2.ae63a8","type":"function","z":"3ec21d64.945c72","name":"Light states","func":"// initVar();\nvar currentTime = new Date().getTime();\nvar topic;\nvar area;\nvar logString;\nvar lightName;\nvar allOff = false;\nvar outMsg = []; \nfor (var i = 0; i < 6; i++)\n    outMsg.push({});\n\nfor (var i = 0; i < 4; i++)\n    outMsg[i] = null;\nvar lightStateInText;\n\nif (flow.get('settings') === undefined && msg.topic !== 'parameters') // no parameters set yet, wait for initialisation\n{\n    node.warn(\"wait for initialisation of light state parameters\");\n    return null;\n}\nelse if (msg.topic === 'parameters')\n{\n  //  node.warn(\"initialisation\");\n    loadConfigVal();\n}\nvar settings = flow.get('settings');\n\nif (msg.topic === 'init' || flow.get('status') === undefined)\n    createVar();\nvar status = flow.get('status');\n\nstatus.currentTime = new Date().getTime();\nlogString = status.area + \": \";\n\nhandleTopic();\nlowLightDetection(); \n\n\nif (status.enableAutomatic === true)\n{\n    switch (status.lightState)\n    {\n        case 0: // off\n            if (status.motion && status.lowLightLevel)\n            {\n                logString += \"Motion detected, switching on\";\n                node.warn(logString);\n                switchOn(settings.lightOnTime);\n       /*          if (status.dimOutput === '1')\n                    node.send([null, msg]); // outMsg[1] = msg;\n                else\n                    node.send([msg, null]); // outMsg[0] = msg; */\n                outMsg[0] = msg;\n            }\n            if (!allOff && status.lightsChanged && currentTime > status.endChangeTime )  // lights changed manually before motion was detected\n            {\n                logString += \"Lights changed manually before motion\";\n                node.warn(logString);\n                \n                switchOnManually(settings.lightOnTimeManual);\n            }\n            else if (status.lightsChanged)\n            {\n                node.warn(\"lightsCh \" + status.lightsChanged + \" Alloff \" + allOff);\n                status.lightsChanged = false;\n            }\n            break;\n        \n        case 1: // switching on, wait for first change\n            if (currentTime > status.endChangeTime )\n            {\n                status.lightsChanged = false;\n                status.lightState = 2;\n            }\n            break;\n            \n        case 2: // on\n            if (status.motion && status.lowLightLevel)    // extend timer\n                status.endTime = currentTime + settings.lightOnTime * 1000;\n            if (status.motionSec && status.lowLightLevel)    // extend timer secondary sensor\n                status.endTimeDimSec = currentTime + (settings.dimSecBeforeOffTime * 1000);\n            if (allOff) // manual switch off\n            {\n              manualOff(settings.lightOnTimeManualOff);\n            }\n            else if ( (currentTime > status.endTime || !status.lowLightLevel) && // timeout passed or low light cleared\n            (status.watchingTV === false ||        // and not watching tv or watching tv when it is light\n            (status.watchingTV === true && !status.lowLightLevel) ) )    \n            {\n                if (status.lowLightLevel && \n                   (settings.dimBeforeOffTime !== 0 || // first dim lights before going off\n                   (settings.dimSecBeforeOffTime !== 0 && status.endTimeDim > currentTime) ) )   // activity on secondary pir and not timed out yet\n                {                \n                    if (settings.dimSecBeforeOffTime !== 0)\n                      dimOnSecondary();\n                    else if (settings.dimBeforeOffTime !== 0)\n                      dimBeforeGoingOff();\n                }\n                else \n                {\n                  timedOff();\n                }\n            }\n            break;\n        \n        case 3: // switched on manually. Wait for long timeout \n            if (status.motion && status.lowLightLevel)    // extend timer\n            {\n                status.lightState = 2; // handle normally\n                status.lightsChanged = false;\n                status.endTime = currentTime + (settings.lightOnTime * 1000);\n            }\n            else if (status.motion)  // motion but no low light\n              status.endTime = currentTime + (settings.lightOnTimeManual * 1000);\n            if (status.motionSec && status.lowLightLevel)    // extend timer secondary sensor\n            {\n                status.lightState = 2; // handle normally\n                status.lightsChanged = false;\n                status.endTimeDimSec = currentTime + (settings.dimSecBeforeOffTime * 1000);\n            }\n            if (currentTime > status.endTime)    // timeout passed\n            {   \n              timedOff();\n            }\n            if (allOff) // manual switch off\n            {\n                manualOff(0);\n            }\n            break;\n        \n        case 4: // dim lights before going off\n            if (currentTime > status.endTimeDim || !status.lowLightLevel)    // timeout on dimming passed, now go off\n            {\n                timedOff();\n            }\n            if (status.motion && status.lowLightLevel)    // activate lights again\n            {\n                switchOn(settings.lightOnTime);\n                logString += \"Motion detected during dimming, switching on\";\n                node.warn(logString);\n                outMsg[0] = msg;\n            } \n            if (status.motionSec && status.lowLightLevel && settings.dimSecBeforeOffTime !== 0)    // extend timer\n            {\n                status.endTimeDimSec = currentTime + (settings.dimSecBeforeOffTime * 1000);\n               // node.warn(\"Extending\");\n            }\n            if (allOff) // manual switch off\n            {\n                manualOff(settings.lightOnTimeManualOff);\n            }\n            break;\n            \n        case 5:     // secondary PIR is active, primary not\n            if (status.motion && status.lowLightLevel)    // switch on\n            {\n              switchOn(settings.lightOnTime);\n              logString += \"Motion during dimming from secondary PIR, switching on\";\n              outMsg[0] = msg;\n            }\n            if (status.motionSec && status.lowLightLevel && settings.dimSecBeforeOffTime !== 0)    // extend timer\n                status.endTimeDimSec = currentTime + (settings.dimSecBeforeOffTime * 1000);\n            if (currentTime > status.endTimeDimSec || !status.lowLightLevel)    // timeout passed, now go off\n            {\n                if (settings.dimBeforeOffTime !== 0)\n                    dimBeforeGoingOff();\n                else\n                    timedOff();\n            }\n            if (allOff) // manual switch off\n            {\n              manualOff(settings.lightOnTimeManualOff);\n            }\n            break;\n        \n        case 6: // lights switched off manually, wait a while before going to automatic again\n            if (status.motion)    // extend timer\n                status.endTime = currentTime + (settings.lightOnTimeManualOff * 1000);\n            if (currentTime > status.endTime)    // timeout passed, now go to automatic\n            {\n              timedOff();\n              logString += \"Time out after lights off, automatic enabled\";\n              node.warn(logString);\n            }\n            if (!allOff && status.lightsChanged && currentTime > status.endChangeTime )  // lights changed manually before motion was detected\n            {\n                logString += \"Lights changed manually\";\n                node.warn(logString);\n                switchOnManually(settings.lightOnTime);\n            }\n            break;\n    }\n}\nmakeStatus();\nflow.set('status', status);\noutMsg[4].payload = lightStateInText;\noutMsg[5].status = status;\noutMsg[5].settings = settings;\n\n// 0: normal, 1: after timeout but dimming period, 2: on secondary sensor, 3: off, 4: status text, 5: debug values output\nreturn [outMsg[0], outMsg[1], outMsg[2], outMsg[3], outMsg[4], outMsg[5]];\n\n\nfunction lowLightDetection()\n{\n    switch (status.lowLightDetectState)\n    {\n        case 0:  // init\n            if (status.lightLevel <= settings.lowLightThreshold)\n            {\n                status.lowLightLevel = true;\n                status.lowLightDetectState = 2;\n            }\n            else\n            {\n                status.lowLightLevel = false;\n                status.lowLightDetectState = 1;\n            }\n            break;\n            \n        case 1: // no low light\n            if (status.lightLevel <= settings.lowLightThreshold)\n            {\n                logString += \"Low light detected: cur \" + status.lightLevel + \", thr \" + settings.lowLightThreshold;\n                node.warn(logString);\n                status.lowLightLevel = true;\n                status.lowLightDetectState = 2;\n            }\n            break;\n            \n        case 2: // low light    \n            if (status.lightLevel > Number(settings.highLightThreshold + status.lightCorrection))\n            {\n                status.highLightEndTime = currentTime + (settings.lowLightClearTime * 1000);\n                status.lowLightDetectState = 3;\n            }\n            break;\n        \n        case 3: // high light, timer running\n            if (status.lightLevel <= settings.lowLightThreshold)\n            {\n                logString += \"Low light detected: cur \" + status.lightLevel + \", thr \" + settings.lowLightThreshold;\n                node.warn(logString);\n                status.lowLightLevel = true;\n                status.lowLightDetectState = 2;\n            }\n            else if (currentTime > status.highLightEndTime) \n            {\n                logString += \"Low light cleared \";\n                node.warn(logString);\n                status.lowLightLevel = false;\n                status.lowLightDetectState = 1;\n            }  \n            break;\n        \n        \n        default:\n            status.lowLightDetectState = 0;\n            break;\n    }\n}\n\nfunction handleTopic()\n{\n    if (msg.variable)\n    {\n        topic = msg.variable.substring(msg.variable.lastIndexOf('.') + 1, msg.variable.length).toLowerCase(); // between last . and end, so the device type (PIR/Light)\n    }\n    \n    if (msg.topic) // messages not from a variable\n    {\n        switch (msg.topic.toLowerCase())\n        {\n            case \"dimlevel\":\n                var lightName;\n                if (msg.variable)\n                    lightName = msg.variable.substring(0, msg.variable.indexOf('.')).toLowerCase(); \n                if (msg.name)\n                    lightName = msg.name; \n              //  node.warn(lightName);\n                var found = false;\n                status.lightCorrection = 0;\n                for (var i in settings.lampValues)  // use only the configured ones\n                {\n                    if (status.lampValues[i].name === lightName) // found the light in buffer\n                    {\n                        found = true;\n                        if (status.lampValues[i].currentValue != msg.payload)  // check if the lamp value was changed\n                        {\n                            status.lightsChanged = true;\n                            status.lampValues[i].currentValue = msg.payload; // store the last value\n                        }\n                    }\n                    else if  (status.lampValues[i].name === 0 && !found) // empty place\n                    {\n                        //node.warn(\"adding to \" + i + \" found \" + found);\n                        status.lampValues[i].name = lightName;\n                        status.lampValues[i].currentValue = msg.payload;\n                    }\n                   \n                }\n                for (i in settings.lampValues)\n                {\n                    var j = Math.floor(status.lampValues[i].currentValue / 10);\n                    status.lightCorrection += settings.lampValues[i].lightCorrections[j];  // calculate the light correction\n                    // node.warn('Corrected ' + settings.lampValues[i].lightCorrections[j]);\n                }\n                node.warn(lightName + ': Correction ' + status.lightCorrection);\n                \n                allOff = true;\n                for (i in settings.lampValues)\n                {\n                    if (status.lampValues[i].name !== 0)\n                    {\n                        if (status.lampValues[i].currentValue !== 0)\n                        {\n                            allOff = false;\n                        }\n                    }\n                }\n            //    if (status.lightsChanged)\n              //      node.warn(lightName + \" changed to \" + msg.payload + \" alloff \" + allOff);\n                break;\n            \n            case \"light\":\n                status.lightLevel = msg.payload;\n            //    status.area = msg.variable.substring(msg.variable.lastIndexOf('-') + 1, msg.variable.lastIndexOf('.')).toLowerCase(); \n                break;\n                \n            case \"pir\":\n                \n                status.motion = convertBoolean(msg.payload);\n             //   status.area = msg.variable.substring(msg.variable.lastIndexOf('-') + 1, msg.variable.lastIndexOf('.')).toLowerCase(); \n                break;\n            \n            case \"pir_sec\":    \n                status.motionSec = convertBoolean(msg.payload);\n                // node.warn('Sec pir ' + status.motionSec);\n                break;  \n                \n            case \"watchingtv\":    \n                status.watchingTV = convertBoolean(msg.payload);\n                //node.warn('TV ' + status.watchingTV);\n                break;      \n                \n            case 'enableautomatic':\n                // logString += \"Automatic mode to \" + convertBoolean(msg.payload);\n                node.warn(logString);\n                status.enableAutomatic = convertBoolean(msg.payload);\n                break;\n                \n        }\n  \n    }\n}\n\nfunction convertBoolean(input)\n{\n    switch (input)\n    {\n        case true:\n        case '1':\n        case 1:\n        case 'true':\n        case 'ON':\n            return(true);\n            \n        case false:\n        case '0':\n        case 0:\n        case 'false':\n        case 'OFF':\n            return(false);\n    }\n    return(false);\n}\n\n            \n\nfunction createVar()\n{\n  var status = {\n    lowLightLevel : 0, \n    lightLevel : 0, \n    lowLightDetectState : 0, \n    highLightEndTime : 0,\n    lightState : 0,\n    lightCorrection : 0, \n    motion : false, \n    motionSec : false, \n    startTime : 0, \n    startTimeSec : 0, \n    lightsChanged : 0, \n    enableAutomatic : true, \n    area : 0,\n    endTime : 0,\n    endTimeDim : 0,\n    endTimeDimSec : 0,\n    endChangeTime : 0,\n    watchingTV : false,\n    currentTime : 0,\n    lampValues : [{   \n        name : settings.lampValues[0].name,\n        currentValue : 0\n        }]\n    };\n    for (var i = 1; i < settings.lampValues.length; i++)\n    {\n        status.lampValues.push({});\n        status.lampValues[i] = {\n            name : settings.lampValues[i].name,\n            currentValue : 0\n            };\n    }\n    status.area = settings.area; \n/*  for (var i = 0; i < 5; i++)\n  {\n    status.lampValues[i].name = settings.lampValues[i].name;\n    status.lampValues[i].currentValue = 0;\n  }*/\n  flow.set('status', status);\n  \n//  node.warn(\"Created var\");\n}  \n\n\n\nfunction switchOn(timeInSeconds)\n{\n // \n//  status.startTime = currentTime;\n  status.endTime = currentTime + (timeInSeconds * 1000);\n  status.lightsChanged = false;\n  status.endChangeTime = currentTime + (settings.lightChangeTime * 1000);\n  status.lightState = 2; \n}\n\nfunction switchOnManually(timeInSeconds)\n{\n // \n//  status.startTime = currentTime;\n  status.endTime = currentTime + (timeInSeconds * 1000);\n  status.lightsChanged = false;\n  status.endChangeTime = currentTime + (settings.lightChangeTime * 1000);\n  status.lightState = 3; \n}\n\nfunction manualOff(timeInSeconds)\n{\n  status.endTime = currentTime + (timeInSeconds * 1000);\n  status.endChangeTime = currentTime + (settings.lightChangeTime * 1000);\n  logString += \"Manual switch off, wait for no motion\";\n  node.warn(logString);\n  status.lightsChanged = false;\n  status.lightState = 6;\n}\n\nfunction timedOff()\n{\n    status.lightsChanged = false;\n  logString += \"Timeout, lights off\";\n  node.warn(logString);\n  status.lightState = 0;  // switch off\n  status.endChangeTime = currentTime + (settings.lightChangeTime * 1000);\n  outMsg[3] = msg;\n}\n\nfunction dimBeforeGoingOff()\n{\n  status.endTimeDim = currentTime + (settings.dimBeforeOffTime * 1000);\n  status.endChangeTime = currentTime + (settings.lightChangeTime * 1000);\n  logString += \"Timeout, dim lights before going off\";\n  node.warn(logString);\n\n  outMsg[1] = msg;\n  status.lightState = 4;  // dim lights\n}\n  \nfunction dimOnSecondary()\n{\n  status.endTimeDimSec = currentTime + (settings.dimSecBeforeOffTime * 1000);\n  status.endChangeTime = currentTime + (settings.lightChangeTime * 1000);\n\n  logString += \"Timeout on primary, dim lights\";\n  node.warn(logString);\n  outMsg[2] = msg;\n\n  status.lightState = 5;  // dim lights\n}\n  \nfunction makeStatus()\n{\n  lowLightStateDescriptions = [\"Init\", \"No low light\", \"Low light\", \"High light after \"];\n  lightStateDescriptions = [\"Off\", \"Switching on\", \"On \", \"Values modified manually \", \"Dimming \", \"2nd PIR active \", \"Manual switched off \"];\n\n  if (status.enableAutomatic)\n  {\n      switch (status.lightState)\n      {\n          case 0:\n              data = lightStateDescriptions[status.lightState];\n              break;\n          case 1:\n              data = lightStateDescriptions[status.lightState] + secToTime((status.endChangeTime - currentTime) / 1000);\n              break;\n          case 2:\n              data = lightStateDescriptions[status.lightState] + secToTime((status.endTime - currentTime) / 1000);\n              break;\n          case 3:\n              data = lightStateDescriptions[status.lightState] + secToTime((status.endTime - currentTime) / 1000);\n              break;\n          case 4:\n              data = lightStateDescriptions[status.lightState] + secToTime((status.endTimeDim - currentTime) / 1000); \n              break;\n          case 5:\n              data = lightStateDescriptions[status.lightState] + secToTime((status.endTimeDimSec - currentTime) / 1000); \n              break;\n          case 6:\n              data = lightStateDescriptions[status.lightState] + secToTime((status.endTime - currentTime) / 1000); \n              break;\n      }\n  }\n  else\n      data = \"Manual\";\n\n  switch (status.lowLightDetectState)\n  {\n      case 0:\n          data2 = \"Initialising\";\n          break;\n      case 1:\n          data2 = lowLightStateDescriptions[status.lowLightDetectState]  + \" (low @ \" + settings.lowLightThreshold + \", cur \" + status.lightLevel + \")\";\n          break;\n      case 2:\n          data2 = lowLightStateDescriptions[status.lowLightDetectState] + \" (high @ \" + Number(settings.lowLightThreshold + status.lightCorrection) + \", cur \" + status.lightLevel + \")\";\n          break;\n      case 3:\n          data2 = lowLightStateDescriptions[status.lowLightDetectState] + secToTime((status.highLightEndTime - currentTime) / 1000) + \" (low @ \" + settings.lowLightThreshold + \", cur \" + status.lightLevel + \")\";\n          break;\n  }\n\n  lightStateInText = data + \", \" + data2;\n\n}\n\nfunction secToTime(secondsIn)\n{\n  var minutes, seconds;\n\n  minutes = Math.floor(secondsIn / 60);\n  seconds = Math.floor(secondsIn % 60);\n  if (seconds < 10 && seconds > 0)\n      seconds = \"0\" + seconds;\n  else if (seconds <= 0)\n      seconds = '00';\n  if (minutes < 0)\n      minutes = '0';\n      \n  var string = minutes + \":\" + seconds;\n // node.warn(\"input \" + secondsIn + \" out \" + string);\n  return string;\n}\n\nfunction loadConfigVal()\n{\n    for (var i in msg.payload.parameters)\n    {\n      //  node.warn(\"i = \" + i + \" len \" + msg.payload.parameters.length + \" area \" + msg.payload.parameters[i].area);\n        if (msg.payload.parameters[i].area.toLowerCase() == msg.area.toLowerCase())\n        {\n            settings = msg.payload.parameters[i];\n            \n            //msg.payload = settings;\n            // node.log(\"Using area \" + msg.payload.parameters[i].area);\n            node.send([null,null,null,null,null,msg]);\n            flow.set('settings', settings);\n        //  initVar();\n        }\n    \n        \n    }   \n}\n","outputs":"6","noerr":0,"x":405,"y":137,"wires":[[],[],[],[],[],[]]},{"id":"c73063f0.8ea41","type":"switch","z":"3ec21d64.945c72","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"getStatus","vt":"str"},{"t":"eq","v":"getSettings","vt":"str"}],"checkall":"true","outputs":2,"x":350,"y":360,"wires":[["8d0fcc00.d731f"],["4e459744.07d418"]]},{"id":"4e459744.07d418","type":"change","z":"3ec21d64.945c72","name":"settings","rules":[{"t":"set","p":"payload","pt":"msg","to":"settings","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":380,"wires":[["294b1d6a.bd7412"]]},{"id":"8d0fcc00.d731f","type":"change","z":"3ec21d64.945c72","name":"status","rules":[{"t":"set","p":"payload","pt":"msg","to":"status","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":340,"wires":[["a8239f26.ba5ee"]]},{"id":"a8239f26.ba5ee","type":"debug","z":"3ec21d64.945c72","name":"","active":true,"console":"false","complete":"payload","x":710,"y":340,"wires":[]},{"id":"294b1d6a.bd7412","type":"debug","z":"3ec21d64.945c72","name":"","active":true,"console":"false","complete":"payload","x":710,"y":380,"wires":[]},{"id":"d2f50c9d.a0f0a","type":"change","z":"3ec21d64.945c72","name":"pir","rules":[{"t":"set","p":"topic","pt":"msg","to":"pir","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":440,"wires":[[]]},{"id":"b48d7e7d.374a3","type":"change","z":"3ec21d64.945c72","name":"light","rules":[{"t":"set","p":"topic","pt":"msg","to":"light","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":500,"wires":[[]]},{"id":"e816354f.f7d698","type":"change","z":"3ec21d64.945c72","name":"pir_sec","rules":[{"t":"set","p":"topic","pt":"msg","to":"pir_sec","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":560,"wires":[[]]},{"id":"24e739a7.644106","type":"change","z":"3ec21d64.945c72","name":"enableAutomatic","rules":[{"t":"set","p":"topic","pt":"msg","to":"enableAutomatic","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":620,"wires":[[]]},{"id":"9e7accc1.e11bb","type":"change","z":"3ec21d64.945c72","name":"dimLevel","rules":[{"t":"set","p":"topic","pt":"msg","to":"dimLevel","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":680,"wires":[[]]},{"id":"c6078cde.13cb3","type":"change","z":"3ec21d64.945c72","name":"watchingTV","rules":[{"t":"set","p":"topic","pt":"msg","to":"watchingTV","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":740,"wires":[[]]},{"id":"e332b280.904ae","type":"comment","z":"3ec21d64.945c72","name":"Input values in topic","info":"","x":185.91250610351562,"y":556.3749465942383,"wires":[]},{"id":"9de0e0f8.1545b","type":"change","z":"3ec21d64.945c72","name":"On","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":40,"wires":[[]]},{"id":"3ddaaa64.febcb6","type":"change","z":"3ec21d64.945c72","name":"Timeout 1","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":80,"wires":[[]]},{"id":"f040005c.0fdb8","type":"change","z":"3ec21d64.945c72","name":"Secondary PIR","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":120,"wires":[[]]},{"id":"522fcac5.395294","type":"change","z":"3ec21d64.945c72","name":"Off","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":160,"wires":[[]]},{"id":"8af39671.cc3bc8","type":"change","z":"3ec21d64.945c72","name":"Status","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":200,"wires":[[]]},{"id":"84212f94.78b6b","type":"change","z":"3ec21d64.945c72","name":"Debug out","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":240,"wires":[[]]},{"id":"c07b6986.57a8d8","type":"tab","label":"Woonkamer","disabled":false,"info":""},{"id":"928b10bf.1d8f1","type":"inject","z":"c07b6986.57a8d8","name":"","topic":"init","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":130,"y":620,"wires":[["61cb301.ff4c3d"]]},{"id":"3160d994.0d8736","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":970,"y":720,"wires":[]},{"id":"3d13e94b.93f136","type":"change","z":"c07b6986.57a8d8","name":"pir","rules":[{"t":"set","p":"topic","pt":"msg","to":"pir","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":100,"wires":[["88b5eb9c.6be778"]]},{"id":"6ce2e349.5b440c","type":"change","z":"c07b6986.57a8d8","name":"light","rules":[{"t":"set","p":"topic","pt":"msg","to":"light","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":140,"wires":[["88b5eb9c.6be778"]]},{"id":"40951026.e042e","type":"change","z":"c07b6986.57a8d8","name":"pir_sec","rules":[{"t":"set","p":"topic","pt":"msg","to":"pir_sec","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":180,"wires":[["88b5eb9c.6be778"]]},{"id":"5a9392f7.e5f9cc","type":"change","z":"c07b6986.57a8d8","name":"enableAutomatic","rules":[{"t":"set","p":"topic","pt":"msg","to":"enableAutomatic","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":220,"wires":[["88b5eb9c.6be778"]]},{"id":"c10bdde.654652","type":"change","z":"c07b6986.57a8d8","name":"dimLevel","rules":[{"t":"set","p":"topic","pt":"msg","to":"dimLevel","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":260,"wires":[["88b5eb9c.6be778"]]},{"id":"a537a01c.1c5bf","type":"change","z":"c07b6986.57a8d8","name":"pir","rules":[{"t":"set","p":"topic","pt":"msg","to":"pir","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":300,"wires":[["88b5eb9c.6be778"]]},{"id":"82a747b8.d7fdb8","type":"change","z":"c07b6986.57a8d8","name":"On","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":520,"wires":[["eccbd663.0b2e68"]]},{"id":"cd93e820.bea4e8","type":"change","z":"c07b6986.57a8d8","name":"Timeout 1","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1180,"y":560,"wires":[["820b2edb.8df1"]]},{"id":"1138dcb2.9365c3","type":"change","z":"c07b6986.57a8d8","name":"Secondary PIR","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":600,"wires":[["8ba5a411.e07878"]]},{"id":"f94409af.816ed8","type":"change","z":"c07b6986.57a8d8","name":"Off","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":640,"wires":[["9c9036a4.e40d18"]]},{"id":"319d395f.72c2b6","type":"change","z":"c07b6986.57a8d8","name":"Status","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1190,"y":680,"wires":[["a401492b.7b5b18"]]},{"id":"5bfb0ed2.92eb5","type":"change","z":"c07b6986.57a8d8","name":"Debug out","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":720,"wires":[[]]},{"id":"a502f8f7.ea1618","type":"inject","z":"c07b6986.57a8d8","name":"Interval","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"x":120,"y":660,"wires":[["61cb301.ff4c3d"]]},{"id":"fcfb6d6c.3cf1a","type":"inject","z":"c07b6986.57a8d8","name":"","topic":"","payload":"getStatus","payloadType":"str","repeat":"","crontab":"","once":false,"x":120,"y":700,"wires":[["61cb301.ff4c3d"]]},{"id":"88b5eb9c.6be778","type":"change","z":"c07b6986.57a8d8","name":"","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":180,"wires":[["61cb301.ff4c3d"]]},{"id":"61cb301.ff4c3d","type":"subflow:3ec21d64.945c72","z":"c07b6986.57a8d8","name":"","x":710,"y":620,"wires":[["1f7293ec.8fb57c","82a747b8.d7fdb8"],["3ef94015.6ac39","cd93e820.bea4e8"],["747a5dd6.fde4a4","1138dcb2.9365c3"],["1a8c135b.e128ed","f94409af.816ed8"],["309898e0.bcac88","319d395f.72c2b6"],["3160d994.0d8736","5bfb0ed2.92eb5"]]},{"id":"2ecaa0a7.4294f","type":"inject","z":"c07b6986.57a8d8","name":"","topic":"","payload":"getSettings","payloadType":"str","repeat":"","crontab":"","once":false,"x":120,"y":740,"wires":[["61cb301.ff4c3d"]]},{"id":"3ef94015.6ac39","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":970,"y":560,"wires":[]},{"id":"1f7293ec.8fb57c","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":970,"y":520,"wires":[]},{"id":"309898e0.bcac88","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":970,"y":680,"wires":[]},{"id":"cd18a7a5.792a88","type":"change","z":"c07b6986.57a8d8","name":"bank","rules":[{"t":"set","p":"name","pt":"msg","to":"bank","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":260,"wires":[["c10bdde.654652"]]},{"id":"35d915a1.bb021a","type":"change","z":"c07b6986.57a8d8","name":"up","rules":[{"t":"set","p":"topic","pt":"msg","to":"up","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1060,"wires":[["f5753d61.a6e7c"]]},{"id":"85bafdb4.49aae","type":"change","z":"c07b6986.57a8d8","name":"down","rules":[{"t":"set","p":"topic","pt":"msg","to":"down","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1120,"wires":[["f5753d61.a6e7c"]]},{"id":"1b6f440b.77a07c","type":"change","z":"c07b6986.57a8d8","name":"scene","rules":[{"t":"set","p":"topic","pt":"msg","to":"scene","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1180,"wires":[["f5753d61.a6e7c"]]},{"id":"6b9287a6.40cc18","type":"change","z":"c07b6986.57a8d8","name":"off","rules":[{"t":"set","p":"topic","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1240,"wires":[["f5753d61.a6e7c"]]},{"id":"ff4fcada.2dd4b8","type":"change","z":"c07b6986.57a8d8","name":"dressoir","rules":[{"t":"set","p":"name","pt":"msg","to":"dressoir","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":340,"wires":[["5aa8ba6c.712ad4"]]},{"id":"5aa8ba6c.712ad4","type":"change","z":"c07b6986.57a8d8","name":"dimLevel","rules":[{"t":"set","p":"topic","pt":"msg","to":"dimLevel","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":340,"wires":[["88b5eb9c.6be778"]]},{"id":"b4f1a0cf.40816","type":"inject","z":"c07b6986.57a8d8","name":"","topic":"init","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":130,"y":1020,"wires":[["f5753d61.a6e7c"]]},{"id":"ce099428.dfc948","type":"file in","z":"c07b6986.57a8d8","name":"","filename":"/home/pi/pimatic-app/parameters.json","format":"utf8","x":450,"y":920,"wires":[["7c4985be.d157ec","dbf73522.e1c1e8"]]},{"id":"56e69a7d.00c024","type":"change","z":"c07b6986.57a8d8","name":"parameters","rules":[{"t":"set","p":"topic","pt":"msg","to":"parameters","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":920,"wires":[["a65df525.6e01c8"]]},{"id":"ee6ca359.4d86c","type":"inject","z":"c07b6986.57a8d8","name":"","topic":"parameters","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":160,"y":920,"wires":[["ce099428.dfc948"]]},{"id":"77fd1e9.5a782e","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"payload.parameters[0]","x":1260,"y":920,"wires":[]},{"id":"a65df525.6e01c8","type":"change","z":"c07b6986.57a8d8","name":"Woonkamer","rules":[{"t":"set","p":"area","pt":"msg","to":"woonkamer","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":920,"wires":[["77fd1e9.5a782e","61cb301.ff4c3d","f5753d61.a6e7c"]]},{"id":"7c4985be.d157ec","type":"json","z":"c07b6986.57a8d8","name":"","x":690,"y":920,"wires":[["56e69a7d.00c024"]]},{"id":"37a97b40.ed5534","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":1170,"y":1000,"wires":[]},{"id":"85fd7ba7.fb1a38","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":1170,"y":1240,"wires":[]},{"id":"747a5dd6.fde4a4","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":970,"y":600,"wires":[]},{"id":"1a8c135b.e128ed","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":970,"y":640,"wires":[]},{"id":"eccbd663.0b2e68","type":"change","z":"c07b6986.57a8d8","name":"scene = 3","rules":[{"t":"set","p":"payload","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1340,"y":520,"wires":[["8e44646e.0348b8"]]},{"id":"820b2edb.8df1","type":"change","z":"c07b6986.57a8d8","name":"scene = 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1340,"y":560,"wires":[["8e44646e.0348b8"]]},{"id":"8ba5a411.e07878","type":"change","z":"c07b6986.57a8d8","name":"scene = 3","rules":[{"t":"set","p":"payload","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1340,"y":600,"wires":[["8e44646e.0348b8"]]},{"id":"9c9036a4.e40d18","type":"change","z":"c07b6986.57a8d8","name":"scene = 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1340,"y":640,"wires":[["8e44646e.0348b8"]]},{"id":"64c09369.bc6c1c","type":"switch","z":"c07b6986.57a8d8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"neq","v":"0","vt":"num"}],"checkall":"true","outputs":2,"x":1170,"y":1040,"wires":[["daad895.9ebb378","62ca31ce.c629d","a324f0d1.4eadc"],["f60d6c36.1a59"]]},{"id":"8e7ff97d.aebd68","type":"switch","z":"c07b6986.57a8d8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"neq","v":"0","vt":"num"}],"checkall":"true","outputs":2,"x":1170,"y":1200,"wires":[["358934ec.7ed30c"],["2c9b0485.4e00bc"]]},{"id":"f60d6c36.1a59","type":"change","z":"c07b6986.57a8d8","name":"","rules":[{"t":"set","p":"dimlevel","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1345.7143325805664,"y":1084.2857313156128,"wires":[["2ec8af3d.93443","a2630626.5775d8","4e31fdac.5ba374"]]},{"id":"2c9b0485.4e00bc","type":"change","z":"c07b6986.57a8d8","name":"","rules":[{"t":"set","p":"parameter","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1330,"y":1220,"wires":[["9e461ee9.31b7c"]]},{"id":"8e44646e.0348b8","type":"change","z":"c07b6986.57a8d8","name":"","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1520,"y":580,"wires":[["1b6f440b.77a07c"]]},{"id":"e48a4581.e76cc8","type":"function","z":"c07b6986.57a8d8","name":"invert","func":"msg.payload = !msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":1060,"wires":[["35d915a1.bb021a"]]},{"id":"ddeb66cf.1bda18","type":"function","z":"c07b6986.57a8d8","name":"invert","func":"msg.payload = !msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":1240,"wires":[["26891256.d455de","dbb3bf0f.cd256"]]},{"id":"a401492b.7b5b18","type":"change","z":"c07b6986.57a8d8","name":"name","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1330,"y":680,"wires":[[]]},{"id":"a547d9d.3c2d528","type":"inject","z":"c07b6986.57a8d8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":190,"y":140,"wires":[[]]},{"id":"313ee8aa.bdf788","type":"bigtimer","z":"c07b6986.57a8d8","outtopic":"scene","outpayload1":"2","outpayload2":"0","name":"scene","lat":"52.6470701","lon":"5.0635475","starttime":"1200","endtime":"1335","startoff":0,"endoff":"0","offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"suspend":false,"random":false,"repeat":false,"atstart":true,"x":790,"y":1460,"wires":[["38b90822.8fb6c8","1b6f440b.77a07c"],[],[]]},{"id":"38b90822.8fb6c8","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":950,"y":1460,"wires":[]},{"id":"dd2315fd.c3d1a8","type":"switch","z":"c07b6986.57a8d8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"true","outputs":2,"x":490,"y":1460,"wires":[["b09a31ab.e183a"],["9993c36e.9f768"]]},{"id":"b09a31ab.e183a","type":"change","z":"c07b6986.57a8d8","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1460,"wires":[["313ee8aa.bdf788"]]},{"id":"9993c36e.9f768","type":"change","z":"c07b6986.57a8d8","name":"auto","rules":[{"t":"set","p":"payload","pt":"msg","to":"auto","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1500,"wires":[["313ee8aa.bdf788"]]},{"id":"ace7bea1.21f83","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":479.66667556762695,"y":1526.1667737960815,"wires":[]},{"id":"f5753d61.a6e7c","type":"subflow:c14dafac.f4d7b","z":"c07b6986.57a8d8","name":"","x":940,"y":1060,"wires":[[],[],[],["85fd7ba7.fb1a38"]]},{"id":"5a1bb922.7baa78","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":1110,"y":1660,"wires":[]},{"id":"d7c74021.27faf","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":1110,"y":1700,"wires":[]},{"id":"e04b571d.d14d18","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":1110,"y":1740,"wires":[]},{"id":"9a527d10.f8bdb","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":1110,"y":1780,"wires":[]},{"id":"fd195479.852328","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":1110,"y":1820,"wires":[]},{"id":"5c83c1f1.a4e01","type":"inject","z":"c07b6986.57a8d8","name":"0","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"x":550,"y":1620,"wires":[[]]},{"id":"1cadf76f.4f3f69","type":"inject","z":"c07b6986.57a8d8","name":"1","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"x":550,"y":1660,"wires":[[]]},{"id":"6cc992e6.9f099c","type":"function","z":"c07b6986.57a8d8","name":"invert","func":"msg.payload = !msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":1760,"wires":[["cd7ac756.d08928","10d4f499.a2d2bb"]]},{"id":"cd7ac756.d08928","type":"subflow:37998bac.753654","z":"c07b6986.57a8d8","name":"","x":640,"y":1760,"wires":[[],[],["211da182.ea03ce"],[],[]]},{"id":"211da182.ea03ce","type":"change","z":"c07b6986.57a8d8","name":"scene = 4","rules":[{"t":"set","p":"payload","pt":"msg","to":"4","tot":"num"},{"t":"set","p":"topic","pt":"msg","to":"scene","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":1760,"wires":[[]]},{"id":"e22b58ee.790158","type":"inject","z":"c07b6986.57a8d8","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":true,"x":190,"y":300,"wires":[[]]},{"id":"dbf73522.e1c1e8","type":"debug","z":"c07b6986.57a8d8","name":"","active":false,"console":"false","complete":"true","x":690,"y":860,"wires":[]},{"id":"2409b511.54fa1a","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"Molgan-Woonkamer.PIR","filter":true,"output":"on-both","name":"","x":450,"y":100,"wires":[["3d13e94b.93f136"]]},{"id":"adb6eeb3.0baa","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"Molgan-Woonkamer.Light","filter":true,"output":"on-both","name":"","x":450,"y":140,"wires":[["6ce2e349.5b440c"]]},{"id":"f9b44698.77da28","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"Molgan-Eetkamer.Light","filter":true,"output":"on-both","name":"","x":156.42857360839844,"y":68.57142066955566,"wires":[[]]},{"id":"54802a0a.40cb14","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"Molgan-Eetkamer.PIR","filter":true,"output":"on-both","name":"","x":460,"y":180,"wires":[["40951026.e042e"]]},{"id":"d826aaeb.e51888","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"automatic-switch-woonkamer.state","filter":true,"output":"on-both","name":"","x":420,"y":220,"wires":[["5a9392f7.e5f9cc"]]},{"id":"daad895.9ebb378","type":"device action","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","deviceId":"bank-dimmer-achter","action":"turnOff","parameterName":"","parameterValue":"","messageOnError":false,"name":"","x":1860,"y":920,"wires":[[]]},{"id":"a2630626.5775d8","type":"device action","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","deviceId":"bank-dimmer-achter","action":"changeDimlevelTo","parameterName":"dimlevel","parameterValue":"","messageOnError":false,"name":"","x":1900,"y":1080,"wires":[[]]},{"id":"2ec8af3d.93443","type":"device action","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","deviceId":"bank-dimmer-zij","action":"changeDimlevelTo","parameterName":"dimlevel","parameterValue":"","messageOnError":false,"name":"","x":1890,"y":1040,"wires":[[]]},{"id":"62ca31ce.c629d","type":"device action","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","deviceId":"bank-dimmer-zij","action":"turnOff","parameterName":"","parameterValue":"","messageOnError":false,"name":"","x":1850,"y":960,"wires":[[]]},{"id":"acd06017.6926","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"Bank.dimlevel","filter":true,"output":"on-both","name":"","x":360,"y":260,"wires":[["cd18a7a5.792a88"]]},{"id":"1f5d23d7.0c19bc","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"Dressoir.dimlevel","filter":true,"output":"on-both","name":"","x":370,"y":340,"wires":[["ff4fcada.2dd4b8"]]},{"id":"1a5c897c.c21c17","type":"set variable","z":"c07b6986.57a8d8","name":"","controller":"3d64668e.d548ca","variable":"lightStateWoonkamer","unit":"","value":"","x":1620,"y":680,"wires":[[]]},{"id":"4e31fdac.5ba374","type":"device action","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","deviceId":"Bank","action":"changeDimlevelTo","parameterName":"dimlevel","parameterValue":"","messageOnError":false,"name":"","x":1850,"y":1120,"wires":[[]]},{"id":"a324f0d1.4eadc","type":"device action","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","deviceId":"Bank","action":"turnOff","parameterName":"","parameterValue":"","messageOnError":false,"name":"","x":1820,"y":1000,"wires":[[]]},{"id":"358934ec.7ed30c","type":"device action","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","deviceId":"Dressoir","action":"turnOff","parameterName":"","parameterValue":"","messageOnError":false,"name":"","x":1830,"y":1200,"wires":[[]]},{"id":"9e461ee9.31b7c","type":"device action","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","deviceId":"Dressoir","action":"changeDimlevelTo","parameterName":"dimlevel","parameterValue":"","messageOnError":false,"name":"","x":1860,"y":1240,"wires":[[]]},{"id":"2d0f76f9.53153a","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"SwitchLeft-On-Woonkamer.contact","filter":true,"output":"on-change","name":"","x":180,"y":1060,"wires":[["e48a4581.e76cc8"]]},{"id":"a1f6012e.688c4","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"SwitchLeft-Off-Woonkamer.contact","filter":true,"output":"on-change","name":"","x":180,"y":1220,"wires":[["ddeb66cf.1bda18"]]},{"id":"375cd18a.9e395e","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"SwitchLeft-Off-Keuken.contact","filter":true,"output":"on-change","name":"","x":170,"y":1260,"wires":[["ddeb66cf.1bda18"]]},{"id":"b303ea17.e58868","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"SwitchLeft-On-Keuken.contact","filter":true,"output":"on-change","name":"","x":170,"y":1100,"wires":[["e48a4581.e76cc8"]]},{"id":"cf6f3e40.a29cb","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"scene-woon","filter":false,"output":"on-change","name":"","x":110,"y":1180,"wires":[["1b6f440b.77a07c","686a832.c3db07c"]]},{"id":"f0846654.234c78","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"tijdschakelaar.state","filter":true,"output":"on-both","name":"","x":310,"y":1460,"wires":[["dd2315fd.c3d1a8","ace7bea1.21f83"]]},{"id":"601ddf8e.df147","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"SwitchLeft-On-Woonkamer.contact","filter":true,"output":"on-change","name":"","x":200,"y":1760,"wires":[["6cc992e6.9f099c"]]},{"id":"6ed4a77b.ae1738","type":"get variable","z":"c07b6986.57a8d8","controller":"3d64668e.d548ca","variable":"SwitchLeft-On-Keuken.contact","filter":true,"output":"on-change","name":"","x":190,"y":1800,"wires":[["6cc992e6.9f099c"]]},{"id":"9d62f0c8.06d31","type":"inject","z":"c07b6986.57a8d8","name":"","topic":"","payload":"40","payloadType":"str","repeat":"","crontab":"","once":false,"x":950,"y":1120,"wires":[["64c09369.bc6c1c","8e7ff97d.aebd68"]]},{"id":"8b3d1c48.9d1a1","type":"inject","z":"c07b6986.57a8d8","name":"","topic":"","payload":"80","payloadType":"str","repeat":"","crontab":"","once":false,"x":950,"y":1160,"wires":[["64c09369.bc6c1c","8e7ff97d.aebd68"]]},{"id":"10d4f499.a2d2bb","type":"debug","z":"c07b6986.57a8d8","name":"","active":true,"console":"false","complete":"true","x":610,"y":1700,"wires":[]},{"id":"26891256.d455de","type":"debug","z":"c07b6986.57a8d8","name":"","active":true,"console":"false","complete":"true","x":610,"y":1300,"wires":[]},{"id":"dbb3bf0f.cd256","type":"switch","z":"c07b6986.57a8d8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","outputs":1,"x":610,"y":1240,"wires":[["6b9287a6.40cc18"]]},{"id":"686a832.c3db07c","type":"debug","z":"c07b6986.57a8d8","name":"","active":true,"console":"false","complete":"true","x":394,"y":1145,"wires":[]},{"id":"3d64668e.d548ca","type":"controller","z":"","name":"pimatic","protocol":"http","host":"localhost","port":"4000","path":"","username":"","password":""}]

from node-red-contrib-pimatic.

mwittig avatar mwittig commented on July 30, 2024

Thanks a lot. I transformed your flow by substituting variables and device ids, but then I still can't reproduce the error in my test setup. As far as I can see there only one (unconnected) node using variable "lightStateWoonkamer", right? Try to change this to some other defined variable to see whether or not the error also occurs.

Maybe it is a timing issue and it occurs in your setup as you have a lot of variables / rules / devices. Do you have rough figures for that?

from node-red-contrib-pimatic.

rikki78 avatar rikki78 commented on July 30, 2024

Yes it is not connected, as it is used by the current setup (node-red as pimatic plugin). I'm looking into moving the regular node-red.
Other variables that are being written have the same issue, right after Deploy. I agree with you on the timing issue. Can I do some debugging myself?
I have around 80 variables in pimatic and 120 devices

from node-red-contrib-pimatic.

mwittig avatar mwittig commented on July 30, 2024

What can I do to debug this?

  • Shutdown node-red if you're using a service wrapper to run it
  • Make sure you have channel with uid which normally runs node-red
  • export PIMATIC_DEBUG="DEBUG"
  • Run node-red from the command line and capture the console output, for example:
script -a node-red.log
node-red
# use Ctrl-C to terminate node-red when the error occured at least once
# then use Ctrl-D to terminate the logging shell forked by the script command

from node-red-contrib-pimatic.

rikki78 avatar rikki78 commented on July 30, 2024

First of all, Happy New Year. Thank you for your kind support!

Here is the output file. I hope it helps.
node-red.log

from node-red-contrib-pimatic.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.