-
Notifications
You must be signed in to change notification settings - Fork 18
/
Node Red Push Nachrichten und Status Fenster
85 lines (85 loc) · 3.14 KB
/
Node Red Push Nachrichten und Status Fenster
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
[
{
"id": "736cb8af.30cdf8",
"type": "inject",
"z": "76b6d694.226ff8",
"name": "",
"topic": "",
"payload": "true",
"payloadType": "bool",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 270,
"y": 200,
"wires": [
[
"fbc74f2a.25e5d"
]
]
},
{
"id": "9c6139c5.4b7488",
"type": "link in",
"z": "76b6d694.226ff8",
"name": "",
"links": [
"2d175cfc.54ee54"
],
"x": 295,
"y": 160,
"wires": [
[
"fbc74f2a.25e5d"
]
]
},
{
"id": "6ac383fe.8e4c2c",
"type": "template",
"z": "76b6d694.226ff8",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "put:/homeegrams/29/actions/37?message={{payload}}",
"output": "str",
"x": 620,
"y": 160,
"wires": [
[
"8fbf1bca.216bf8"
]
]
},
{
"id": "8fbf1bca.216bf8",
"type": "link out",
"z": "76b6d694.226ff8",
"name": "",
"links": [
"e204158a.3c9808"
],
"x": 775,
"y": 160,
"wires": []
},
{
"id": "fbc74f2a.25e5d",
"type": "function",
"z": "76b6d694.226ff8",
"name": "Abfrage Fenster",
"func": "if (msg.payload.homeegram && msg.payload.homeegram.id === 29 && msg.payload.homeegram.play === 0){flow.set(\"state\", 0)}\nvar state = flow.get(\"state\")||0;\nif ((msg.payload.homeegram && msg.payload.homeegram.id === 29 && msg.payload.homeegram.play === 1 && state === 0)||msg.payload === true){\n flow.set(\"state\",1);\nconst attributes = global.get('homee.attributes');\nconst nodes = global.get('homee.nodes');\nvar ausgabe = \"\";\nvar test = attributes.filter(attribute => ((attribute.type === 10)||(attribute.type === 14)) && ((attribute.current_value ===1)||(attribute.current_value === 2)) )//.map(a => a.current_value).reduce((a,c) => a+c);\ntest.forEach(function(id){\n if(id.id === 0){return}// hier kommt die Attribut ID hin die gefiltert werden soll\n switch (id.current_value){\n case 0 : variable = \"geschlossen\";\n break;\n case 1 : variable = \"geöffnet \";\n break;\n case 2 : variable = \"gekippt\";\n break\n}\nvar nodename = nodes.filter(node => node.id === id.node_id ).map(a => a.name)\n komponente = \" \"+decodeURIComponent(nodename) +\" ist \"+ variable+\" \";\nif(ausgabe.length > 1 ){ausgabe =ausgabe + \"und\"}\nausgabe = ausgabe+komponente \n });\nnode.send({payload: ausgabe}) \nvar test2 = attributes.filter(attribute => (attribute.type === 10)||(attribute.type === 14)).map(a => a.current_value).reduce((a,c) => a+c);\nif (test2===0){return}\nreturn }\nreturn \n",
"outputs": 1,
"noerr": 0,
"x": 440,
"y": 160,
"wires": [
[
"6ac383fe.8e4c2c"
]
]
}
]