Der Historian hat vom meinen Außensensor alle Werte, also war es naheliegend über jsonrpc darauf zuzugreifen.
Code: Alles auswählen
[
{
"id": "82629a6e.a15ba8",
"type": "tab",
"label": "Tagestemperatur CCU-Historian",
"disabled": false,
"info": ""
},
{
"id": "39352e8b.d8849a",
"type": "function",
"z": "82629a6e.a15ba8",
"name": "-24h",
"func": "msg.payload.params[1]=msg.payload.params[2]-1000*60*60*24;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 730,
"y": 260,
"wires": [
[
"32aad65b.54c002"
]
]
},
{
"id": "32aad65b.54c002",
"type": "http request",
"z": "82629a6e.a15ba8",
"name": "jsonrpc - CCU Historian",
"method": "GET",
"ret": "obj",
"paytoqs": "body",
"url": "http://localhost:8082/query/jsonrpc.gy",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 790,
"y": 320,
"wires": [
[
"1318f31d.bd571d"
]
]
},
{
"id": "1318f31d.bd571d",
"type": "function",
"z": "82629a6e.a15ba8",
"name": "Berechnung Tagesdurchschnitt",
"func": "let integr=0\nlet integrTime=0\nlet previous\n\nlet len = msg.payload.result.timestamps.length;\nfor (let i=0; i<len;i++)\n{\n// var msg2 = { timestamp: msg.payload.result.timestamps[i], payload: msg.payload.result.values[i] };\n// node.send (msg2);\n\n if (i!=0) \n {\n // Teilintegral berechnen: Messwert*Millisekunden\n let tt = msg.payload.result.timestamps[i]-previous;\n integr+=msg.payload.result.values[i] *tt;\n integrTime += tt;\n }\n previous=msg.payload.result.timestamps[i]; \n}\nlet dd = integr/integrTime;\nnode.send ({payload: dd, anz: len, zeit: integrTime/(1000*60*60), idDev: msg.payload.id, name: msg.payload.result.dataPoint.displayName, raum: msg.payload.result.dataPoint.attributes.room});\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 810,
"y": 380,
"wires": [
[
"18419c20.6af4fc"
]
]
},
{
"id": "dd1ef26.3d8ac9",
"type": "ccu-value",
"z": "82629a6e.a15ba8",
"name": "",
"iface": "HmIP-RF",
"channel": "0010DD899E5483:1 Außen-Temperatur:1",
"datapoint": "ACTUAL_TEMPERATURE",
"mode": "",
"start": true,
"change": true,
"cache": false,
"queue": false,
"on": 0,
"onType": "undefined",
"ramp": 0,
"rampType": "undefined",
"working": false,
"ccuConfig": "38263145.35ea0e",
"topic": "${CCU}/${Interface}/${channel}/${datapoint}",
"x": 160,
"y": 80,
"wires": [
[
"b3134fd2.491508"
]
]
},
{
"id": "8d26335c.3dccc8",
"type": "change",
"z": "82629a6e.a15ba8",
"name": "Aktuelle Zeit",
"rules": [
{
"t": "set",
"p": "payload.params[2]",
"pt": "msg",
"to": "",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 750,
"y": 200,
"wires": [
[
"39352e8b.d8849a"
]
]
},
{
"id": "1007f6da.d93ee9",
"type": "inject",
"z": "82629a6e.a15ba8",
"name": "Test",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 110,
"y": 280,
"wires": [
[
"31c93bc7.668ebc"
]
]
},
{
"id": "18419c20.6af4fc",
"type": "ccu-sysvar",
"z": "82629a6e.a15ba8",
"name": "Tagesmitteltemperatur.AußenNodeRed",
"ccuConfig": "38263145.35ea0e",
"topic": "ReGaHSS/${Name}",
"change": true,
"cache": true,
"x": 1130,
"y": 380,
"wires": [
[]
]
},
{
"id": "6c325671.f2cfa8",
"type": "template",
"z": "82629a6e.a15ba8",
"name": "getTimeSeries",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "{\n \"id\":\"{{payload.device}}\",\n \"method\":\"getTimeSeries\",\n \"params\":[\"{{payload.datapointName}}\"]\n}",
"output": "json",
"x": 760,
"y": 140,
"wires": [
[
"8d26335c.3dccc8"
]
]
},
{
"id": "e43ba732.7c2bd",
"type": "delay",
"z": "82629a6e.a15ba8",
"name": "",
"pauseType": "delay",
"timeout": "10",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 550,
"y": 140,
"wires": [
[
"6c325671.f2cfa8"
]
]
},
{
"id": "31c93bc7.668ebc",
"type": "ccu-get-value",
"z": "82629a6e.a15ba8",
"name": "Außen-Temperatur",
"ccuConfig": "38263145.35ea0e",
"iface": "HmIP-RF",
"channel": "0010DD899E5483:1 Außen-Temperatur:1",
"sysvar": "",
"sysvarProperty": "value",
"datapoint": "ACTUAL_TEMPERATURE",
"datapointProperty": "all",
"setProp": "payload",
"setPropType": "msg",
"x": 150,
"y": 220,
"wires": [
[
"6c325671.f2cfa8"
]
]
},
{
"id": "b3134fd2.491508",
"type": "change",
"z": "82629a6e.a15ba8",
"name": "",
"rules": [
{
"t": "delete",
"p": "payload",
"pt": "msg"
},
{
"t": "set",
"p": "payload.device",
"pt": "msg",
"to": "device",
"tot": "msg"
},
{
"t": "set",
"p": "payload.datapointName",
"pt": "msg",
"to": "datapointName",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 80,
"wires": [
[
"e43ba732.7c2bd"
]
]
},
{
"id": "76609b67.a89904",
"type": "comment",
"z": "82629a6e.a15ba8",
"name": "Sensor anpassen",
"info": "",
"x": 140,
"y": 60,
"wires": []
},
{
"id": "b74c3722.f52e3",
"type": "comment",
"z": "82629a6e.a15ba8",
"name": "Systemvariable anpassen",
"info": "",
"x": 1090,
"y": 360,
"wires": []
},
{
"id": "fc576b96.485da8",
"type": "comment",
"z": "82629a6e.a15ba8",
"name": "Sensor anpassen - nur zum Testen",
"info": "",
"x": 200,
"y": 200,
"wires": []
},
{
"id": "38263145.35ea0e",
"type": "ccu-connection",
"name": "localhost",
"host": "localhost",
"regaEnabled": true,
"bcrfEnabled": true,
"iprfEnabled": true,
"virtEnabled": true,
"bcwiEnabled": false,
"jackEnabled": true,
"cuxdEnabled": true,
"regaPoll": true,
"regaInterval": "30",
"rpcPingTimeout": "60",
"rpcInitAddress": "127.0.0.1",
"rpcServerHost": "127.0.0.1",
"rpcBinPort": "2047",
"rpcXmlPort": "2048",
"tls": false,
"inSecure": false,
"authentication": false,
"username": "nope",
"password": "nope",
"queueTimeout": "5000",
"queuePause": "250",
"contextStore": ""
}
]
Michael