Closed AxelRHD closed 2 months ago
Hi @AxelRHD,
firstly, I don't think you need to store the current state in the global context, since it's also stored / compared inside the set-value
node: https://github.com/ptweety/node-red-contrib-ccu/blob/35e926d1329567dfbdff0974dacdde85fda0c0a1/nodes/ccu-set-value.js#L267-L269
And in addition can you please share your flow?
The context values are part of the configuration. Is there a better solution? I am not that experienced with Node-RED yet.
Here is the flow group:
[
{
"id": "f6fb1ae483aac009",
"type": "light-scheduler",
"z": "4cf97e1278be2f9b",
"d": true,
"g": "ec89e9119f8fa937",
"settings": "fe6af9b20e97a02c",
"events": "[{\"start\":{\"dow\":1,\"mod\":450},\"end\":{\"dow\":1,\"mod\":540}},{\"start\":{\"dow\":3,\"mod\":450},\"end\":{\"dow\":3,\"mod\":540}},{\"start\":{\"dow\":2,\"mod\":360},\"end\":{\"dow\":2,\"mod\":450}},{\"start\":{\"dow\":4,\"mod\":360},\"end\":{\"dow\":4,\"mod\":450}},{\"start\":{\"dow\":5,\"mod\":360},\"end\":{\"dow\":5,\"mod\":450}},{\"start\":{\"dow\":1,\"mod\":990},\"end\":{\"dow\":1,\"mod\":1380}},{\"start\":{\"dow\":2,\"mod\":990},\"end\":{\"dow\":2,\"mod\":1380}},{\"start\":{\"dow\":3,\"mod\":990},\"end\":{\"dow\":3,\"mod\":1380}},{\"start\":{\"dow\":4,\"mod\":990},\"end\":{\"dow\":4,\"mod\":1380}},{\"start\":{\"dow\":5,\"mod\":990},\"end\":{\"dow\":5,\"mod\":1380}},{\"start\":{\"dow\":6,\"mod\":480},\"end\":{\"dow\":6,\"mod\":600}},{\"start\":{\"dow\":0,\"mod\":480},\"end\":{\"dow\":0,\"mod\":600}},{\"start\":{\"dow\":6,\"mod\":1140},\"end\":{\"dow\":6,\"mod\":1380}},{\"start\":{\"dow\":0,\"mod\":1140},\"end\":{\"dow\":0,\"mod\":1380}}]",
"topic": "bad",
"name": "Bad Heizung",
"onPayload": "temp_comfort",
"onPayloadType": "str",
"offPayload": "temp_eco",
"offPayloadType": "str",
"onlyWhenDark": false,
"scheduleRndMax": 0,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.minutely",
"x": 150,
"y": 320,
"wires": [
[
"22d46d165c16db65"
]
]
},
{
"id": "108b33031a632336",
"type": "comment",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"name": "HM Cron - Target Temperature",
"info": "BAD:\nWD 06:00 - 08:30\n 17:00 - 22:30\nWE 08:00 - 10:00\n 19:00 - 22:30\n\nECO:\n8:30 WD\n10:00 WE\n22:30\n\nCOMFORT:\n06:00 WD\n17:00 WD\n08:00 WE\n19:00 WE\n\n---\n\nWZ:\nWD 15:45 - 23:00\nWE 11:00 - 23:30\n\nECO\n23:00 WD\n23:30 WE\n\nCOMFORT\n15:45 WD\n11:00 WE\n\n---\n\nSZ:\nWD 20:00 - 09:00\nWE 21:00 - 11:00\n\nECO\n09:00 WD\n11:00 WE\n\nCOMFORT\n20:00 WD\n21:00 WE",
"x": 180,
"y": 80,
"wires": []
},
{
"id": "04641622958a6fe2",
"type": "light-scheduler",
"z": "4cf97e1278be2f9b",
"d": true,
"g": "ec89e9119f8fa937",
"settings": "fe6af9b20e97a02c",
"events": "[{\"start\":{\"dow\":1,\"mod\":930},\"end\":{\"dow\":1,\"mod\":1380}},{\"start\":{\"dow\":2,\"mod\":930},\"end\":{\"dow\":2,\"mod\":1380}},{\"start\":{\"dow\":3,\"mod\":930},\"end\":{\"dow\":3,\"mod\":1380}},{\"start\":{\"dow\":4,\"mod\":930},\"end\":{\"dow\":4,\"mod\":1380}},{\"start\":{\"dow\":5,\"mod\":930},\"end\":{\"dow\":5,\"mod\":1380}},{\"start\":{\"dow\":6,\"mod\":660},\"end\":{\"dow\":6,\"mod\":1410}},{\"start\":{\"dow\":0,\"mod\":660},\"end\":{\"dow\":0,\"mod\":1410}}]",
"topic": "wz",
"name": "WZ Heizung",
"onPayload": "temp_comfort",
"onPayloadType": "str",
"offPayload": "temp_eco",
"offPayloadType": "str",
"onlyWhenDark": false,
"scheduleRndMax": 0,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.minutely",
"x": 150,
"y": 380,
"wires": [
[
"22d46d165c16db65"
]
]
},
{
"id": "818ee8fb2e556fd9",
"type": "light-scheduler",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"settings": "fe6af9b20e97a02c",
"events": "[{\"start\":{\"dow\":1,\"mod\":0},\"end\":{\"dow\":1,\"mod\":540}},{\"start\":{\"dow\":2,\"mod\":0},\"end\":{\"dow\":2,\"mod\":540}},{\"start\":{\"dow\":3,\"mod\":0},\"end\":{\"dow\":3,\"mod\":540}},{\"start\":{\"dow\":4,\"mod\":0},\"end\":{\"dow\":4,\"mod\":540}},{\"start\":{\"dow\":5,\"mod\":0},\"end\":{\"dow\":5,\"mod\":540}},{\"start\":{\"dow\":6,\"mod\":0},\"end\":{\"dow\":6,\"mod\":660}},{\"start\":{\"dow\":0,\"mod\":0},\"end\":{\"dow\":0,\"mod\":660}},{\"start\":{\"dow\":1,\"mod\":1290},\"end\":{\"dow\":2,\"mod\":0}},{\"start\":{\"dow\":2,\"mod\":1290},\"end\":{\"dow\":3,\"mod\":0}},{\"start\":{\"dow\":3,\"mod\":1290},\"end\":{\"dow\":4,\"mod\":0}},{\"start\":{\"dow\":4,\"mod\":1290},\"end\":{\"dow\":5,\"mod\":0}},{\"start\":{\"dow\":5,\"mod\":1290},\"end\":{\"dow\":6,\"mod\":0}},{\"start\":{\"dow\":6,\"mod\":1350},\"end\":{\"dow\":0,\"mod\":0}},{\"start\":{\"dow\":0,\"mod\":1350},\"end\":{\"dow\":1,\"mod\":0}}]",
"topic": "sz",
"name": "SZ Heizung",
"onPayload": "temp_comfort",
"onPayloadType": "str",
"offPayload": "temp_eco",
"offPayloadType": "str",
"onlyWhenDark": false,
"scheduleRndMax": 0,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.statechange.startup",
"x": 150,
"y": 260,
"wires": [
[
"22d46d165c16db65"
]
]
},
{
"id": "2c6cf3ec6071cfc0",
"type": "light-scheduler",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"settings": "fe6af9b20e97a02c",
"events": "[{\"start\":{\"dow\":1,\"mod\":450},\"end\":{\"dow\":1,\"mod\":1380}},{\"start\":{\"dow\":3,\"mod\":450},\"end\":{\"dow\":3,\"mod\":1380}},{\"start\":{\"dow\":2,\"mod\":360},\"end\":{\"dow\":2,\"mod\":450}},{\"start\":{\"dow\":4,\"mod\":360},\"end\":{\"dow\":4,\"mod\":450}},{\"start\":{\"dow\":5,\"mod\":360},\"end\":{\"dow\":5,\"mod\":450}},{\"start\":{\"dow\":2,\"mod\":990},\"end\":{\"dow\":2,\"mod\":1380}},{\"start\":{\"dow\":4,\"mod\":990},\"end\":{\"dow\":4,\"mod\":1380}},{\"start\":{\"dow\":5,\"mod\":990},\"end\":{\"dow\":5,\"mod\":1380}},{\"start\":{\"dow\":6,\"mod\":480},\"end\":{\"dow\":6,\"mod\":600}},{\"start\":{\"dow\":0,\"mod\":480},\"end\":{\"dow\":0,\"mod\":600}},{\"start\":{\"dow\":6,\"mod\":1140},\"end\":{\"dow\":6,\"mod\":1380}},{\"start\":{\"dow\":0,\"mod\":1140},\"end\":{\"dow\":0,\"mod\":1380}}]",
"topic": "bad",
"name": "Bad Heizung",
"onPayload": "temp_comfort",
"onPayloadType": "str",
"offPayload": "temp_eco",
"offPayloadType": "str",
"onlyWhenDark": false,
"scheduleRndMax": 0,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.statechange.startup",
"x": 150,
"y": 140,
"wires": [
[
"22d46d165c16db65"
]
]
},
{
"id": "ce8013ca1f07fcfe",
"type": "light-scheduler",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"settings": "fe6af9b20e97a02c",
"events": "[{\"start\":{\"dow\":2,\"mod\":930},\"end\":{\"dow\":2,\"mod\":1380}},{\"start\":{\"dow\":4,\"mod\":930},\"end\":{\"dow\":4,\"mod\":1380}},{\"start\":{\"dow\":5,\"mod\":930},\"end\":{\"dow\":5,\"mod\":1380}},{\"start\":{\"dow\":6,\"mod\":660},\"end\":{\"dow\":6,\"mod\":1410}},{\"start\":{\"dow\":0,\"mod\":660},\"end\":{\"dow\":0,\"mod\":1410}},{\"start\":{\"dow\":1,\"mod\":540},\"end\":{\"dow\":1,\"mod\":1380}},{\"start\":{\"dow\":3,\"mod\":540},\"end\":{\"dow\":3,\"mod\":1380}}]",
"topic": "wz",
"name": "WZ Heizung",
"onPayload": "temp_comfort",
"onPayloadType": "str",
"offPayload": "temp_eco",
"offPayloadType": "str",
"onlyWhenDark": false,
"scheduleRndMax": 0,
"sunElevationThreshold": 6,
"sunShowElevationInStatus": false,
"outputfreq": "output.statechange.startup",
"x": 150,
"y": 200,
"wires": [
[
"22d46d165c16db65"
]
]
},
{
"id": "8d89feee5a077c62",
"type": "function",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"name": "create state messages",
"func": "let room = msg.topic;\nlet mode = msg.payload;\nlet data = global.get(room, 'file');\n\nlet device = global.get(`hm_devices.heating_${room}`, 'file');\nlet mode_temp = data[mode];\nlet target_temp = data['temp_target'];\n\nlet msg_state = {\n topic: 'temp_target',\n payload: mode_temp,\n group: room,\n original: msg\n};\n\nlet msg_switch = {\n payload: mode_temp,\n device: device,\n datapoint: 'MANU_MODE',\n original: msg\n};\n\n// only switch temperature, when on auto_mode\nif (data.auto_mode === false) {\n msg_switch = null;\n}\n\n// don't persist state, if values are equal\nif (target_temp == mode_temp) {\n return [null, msg_switch];\n}\n\nreturn [msg_state, msg_switch];",
"outputs": 2,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 480,
"y": 260,
"wires": [
[
"9bd529876e9e023f"
],
[
"d63840296e28e64e",
"a97dd479d9a89ae3"
]
]
},
{
"id": "9bd529876e9e023f",
"type": "link out",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"name": "heating-cron-schedule-out1",
"mode": "link",
"links": [
"3166c40877e92af5"
],
"x": 675,
"y": 220,
"wires": []
},
{
"id": "d63840296e28e64e",
"type": "debug",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"name": "heizung cron",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 730,
"y": 360,
"wires": []
},
{
"id": "48c905b3d09ae321",
"type": "inject",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "bad",
"payload": "temp_eco",
"payloadType": "str",
"x": 410,
"y": 200,
"wires": [
[
"8d89feee5a077c62"
]
]
},
{
"id": "418e4d760baf8db6",
"type": "inject",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "bad",
"payload": "temp_comfort",
"payloadType": "str",
"x": 430,
"y": 320,
"wires": [
[
"8d89feee5a077c62"
]
]
},
{
"id": "a97dd479d9a89ae3",
"type": "ccu-set-value",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"name": "HM-CC-RT-DN",
"iface": "BidCos-RF",
"ccuConfig": "9dc36826ee6c6798",
"rooms": "",
"roomsRx": "str",
"functions": "",
"functionsRx": "str",
"device": "",
"deviceRx": "str",
"deviceName": "",
"deviceNameRx": "str",
"deviceType": "HM-CC-RT-DN",
"deviceTypeRx": "str",
"channel": "",
"channelRx": "str",
"channelName": "",
"channelNameRx": "str",
"channelType": "",
"channelTypeRx": "str",
"channelIndex": "",
"channelIndexRx": "str",
"datapoint": "",
"datapointRx": "str",
"force": false,
"x": 740,
"y": 300,
"wires": []
},
{
"id": "22d46d165c16db65",
"type": "junction",
"z": "4cf97e1278be2f9b",
"g": "ec89e9119f8fa937",
"x": 320,
"y": 260,
"wires": [
[
"8d89feee5a077c62"
]
]
},
{
"id": "fe6af9b20e97a02c",
"type": "light-scheduler-settings",
"name": "GG",
"latitude": "49.601257",
"longitude": "8.505674"
},
{
"id": "9dc36826ee6c6798",
"type": "ccu-connection",
"name": "homematic-raspi",
"host": "homematic-raspi",
"regaEnabled": true,
"bcrfEnabled": true,
"iprfEnabled": true,
"virtEnabled": true,
"bcwiEnabled": false,
"jackEnabled": false,
"cuxdEnabled": false,
"regaPoll": true,
"regaInterval": "30",
"rpcPingTimeout": "60",
"rpcInitAddress": "192.168.2.215",
"rpcServerHost": "172.19.0.4",
"rpcBinPort": "2048",
"rpcXmlPort": "2049",
"tls": false,
"inSecure": false,
"authentication": false,
"username": "",
"password": "",
"queueTimeout": "5000",
"queuePause": "250",
"contextStore": ""
}
]
For the moment I work with 3 seperate output nodes and that works as expected.
First thank you for the incredible implementation.
I have a problem with the
set value
node:There are multiple schedules (one for each room) which trigger an event on startup and on every change. The messages are modified on a function node and forwarded to the
set value
node afterwards.On startup it seems, that there is only one message send to CCU. Do I have to use one output node for each device? I thought that I can use one monolite output in the flow.
The message contains the
device
,datapoint
and of course the value inmsg.payload
.This is the code of the function node: