I have several nodes that don't regularly do what they're supposed to do. Most of the time/allways, when I (re-)deploy they start working. I think it's especially the ones that deal with Openhab-Input-nodes.
For example this one:
It takes the window state from openhab. When it's open it passes a text message after 5 minutes on to text output (local pc and alexa). This is repeated every 4 minutes until the window is closed.
Works fine, when it works. But sometimes it just doesn't. When I deploy again, it works. I can't really tell why.
Here's the nodes code (I'm very new to javascript, so excuse its quality and redundance; I'm mostly getting results by trial and error)
[
{
"id": "b71f1760.d269e8",
"type": "openhab2-in",
"z": "73aed84a.b4fae8",
"name": "",
"controller": "64883450.c1c2bc",
"itemname": "WC_Fensterstatus",
"x": 170,
"y": 1340,
"wires": [
[
"abc114cb.00c158"
],
[]
]
},
{
"id": "18f96336.32449d",
"type": "debug",
"z": "73aed84a.b4fae8",
"name": "Fenster WC",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1450,
"y": 1280,
"wires": []
},
{
"id": "dc0c97ff.302fd8",
"type": "looptimer-advanced",
"z": "73aed84a.b4fae8",
"duration": "4",
"units": "Minute",
"maxloops": "100",
"maxtimeout": "2",
"maxtimeoutunits": "Hour",
"name": "",
"x": 1220,
"y": 1360,
"wires": [
[
"bfad03f7.89295",
"18f96336.32449d",
"e740ecf2.d14d9"
],
[]
]
},
{
"id": "bfad03f7.89295",
"type": "play audio",
"z": "73aed84a.b4fae8",
"name": "",
"voice": "0",
"x": 1450,
"y": 1340,
"wires": []
},
{
"id": "4a595806.a0a888",
"type": "switch",
"z": "73aed84a.b4fae8",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "OPEN",
"vt": "str"
},
{
"t": "eq",
"v": "CLOSED",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 610,
"y": 1340,
"wires": [
[
"3dd1e5bc.3e3fca"
],
[
"19fb8ab1.290995"
]
]
},
{
"id": "3dd1e5bc.3e3fca",
"type": "change",
"z": "73aed84a.b4fae8",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Fenster WC bitte schließen",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 810,
"y": 1300,
"wires": [
[
"c3a1b09d.c4b9a",
"fc827de8.216c5"
]
]
},
{
"id": "19fb8ab1.290995",
"type": "change",
"z": "73aed84a.b4fae8",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "stop",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 810,
"y": 1380,
"wires": [
[
"dc0c97ff.302fd8",
"a6a6ada5.23962"
]
]
},
{
"id": "c3a1b09d.c4b9a",
"type": "delay",
"z": "73aed84a.b4fae8",
"name": "",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "minutes",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 1040,
"y": 1300,
"wires": [
[
"dc0c97ff.302fd8"
]
]
},
{
"id": "abc114cb.00c158",
"type": "function",
"z": "73aed84a.b4fae8",
"name": "Filter Sprachausgabe",
"func": "//x=msg.payload); // Variable X erhält/extrahiert von msg den Eingeschaftswert von payload und zur Sicherheit als Zahl definiert, so dass weiter unten die IF-Bedingung kein Problem gibt\nz = msg. payload;\n\n\nlet y=\"\"; //zur Definition von y, so dass kein Fehler wenn nichts reingeschreiben wird und dass nichts gesagt wird, wenn Sprachausgabe fals\n\n//Defintion der Variablen zur Steuerung der Sprachausgabe\n//pause = flow.get(\"ruhezeit\");\nvar time = new Date();\nvar hour = time.getHours(); //gibt in Kombi mit Zeile darüber die aktuelle Stunde\n\nzeit1=Date.now(); //dies gibt im Gegensatz zu new Date() einen Zahlenwert mit dem man rechnen kann\n//zeit2= flow.get(\"letztezeitXXX\") || 0; // dann wurde zum letzten Mal Text gesagt\n\n\nif ((flow.get(\"sprachschalter\") == true) // und nur wenn Sprachschalter ein\n&& (hour >= flow.get(\"sprachestart\") && hour <= flow.get(\"spracheende\") )) //und nur, wenn im erlaubten Sprachzeitraum, so dass nicht in der Nach gesprochen wird\n {\n return msg;\n } \n \n \n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 420,
"y": 1340,
"wires": [
[
"4a595806.a0a888"
]
]
},
{
"id": "4f48adcf.f41554",
"type": "comment",
"z": "73aed84a.b4fae8",
"name": "WC-Fnester schließen nach 5 Minuten mit Erinnerungen",
"info": "",
"x": 280,
"y": 1280,
"wires": []
},
{
"id": "e740ecf2.d14d9",
"type": "alexa-remote-routine",
"z": "73aed84a.b4fae8",
"name": "",
"account": "cc33e24e.100f5",
"routineNode": {
"type": "speak",
"payload": {
"type": "regular",
"text": {
"type": "msg",
"value": "payload"
},
"devices": [
"G090L910721302TW",
"G2A14R0395130ACR",
"G0911B05928309AT"
]
}
},
"x": 1460,
"y": 1420,
"wires": [
[]
]
},
{
"id": "fc827de8.216c5",
"type": "debug",
"z": "73aed84a.b4fae8",
"name": "Fenster schließen",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1010,
"y": 1240,
"wires": []
},
{
"id": "a6a6ada5.23962",
"type": "debug",
"z": "73aed84a.b4fae8",
"name": "stoppe loop",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 950,
"y": 1440,
"wires": []
},
{
"id": "64883450.c1c2bc",
"type": "openhab2-controller",
"name": "Openhab",
"protocol": "http",
"host": "openhabian",
"port": "8080",
"path": "",
"username": "",
"password": ""
},
{
"id": "cc33e24e.100f5",
"type": "alexa-remote-account",
"name": "Alexa",
"authMethod": "proxy",
"proxyOwnIp": "192.168.178.25",
"proxyPort": "4567",
"cookieFile": "amazonpasswort2",
"refreshInterval": "3",
"alexaServiceHost": "layla.amazon.de",
"amazonPage": "amazon.de",
"acceptLanguage": "de-DE",
"userAgent": "",
"useWsMqtt": "on",
"autoInit": "on"
}
]