[
{
"id": "f8d04d869814ec04",
"type": "ha-api",
"z": "73a28f3f91660263",
"name": "sensor",
"server": "541ade28.b4a62",
"version": 1,
"debugenabled": false,
"protocol": "http",
"method": "post",
"path": "/api/states/{{entity_id}}",
"data": "",
"dataType": "json",
"responseType": "json",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "results"
}
],
"x": 1290,
"y": 380,
"wires": [
[]
]
},
{
"id": "91228a3cc7b45c6f",
"type": "function",
"z": "73a28f3f91660263",
"name": "make final payload",
"func": "// Node-RED Function Node\nconst topic = msg.topic; // Eingabe von msg.topic\nconst payload = msg.payload; // Eingabe von msg.payload (True/False)\n\n// Eindeutige ID generieren\nconst uniqueId = \"binary_sensor.kompressor_b_\" + msg.topic.toLowerCase();\n\nmsg.entity_id = \"binary_sensor.kompressor_b_\" + msg.topic.toLowerCase();\nmsg.name = uniqueId;\nmsg.payload = {\n data: {\n state: msg.payload ? 'on' : 'off',\n attributes: {\n name: msg.topic,\n state: payload ? 'on' : 'off',\n unique_id: \"binary_sensor.kompressor_b_\" + msg.topic.toLowerCase(),\n device_class: '',\n device: 'Kompressor',\n friendly_name: 'B_Kompressor Status '+msg.topic\n },\n context: {\n id: \"binary_sensor.kompressor_b_\" + msg.topic.toLowerCase(),\n parrent_id: ''\n\n }\n }\n};\ndelete msg.topic\nreturn msg;\n",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1070,
"y": 380,
"wires": [
[
"f8d04d869814ec04",
"4148e69f78a154c4"
]
]
},
{
"id": "541ade28.b4a62",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "",
"connectionDelay": false,
"cacheJson": false,
"heartbeat": false,
"heartbeatInterval": "",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": "at: ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": true
}
]
aktuell so, aber es kommt halt keine uniqueID 