Hi Wally
Thx, your info was the key.
As an example below a test of how I developed my configuration. The first function node is an example of data being collected in a dictionary. The second function node then contains on top some config to connect the data in the dictionary to the according HA tags and then a loop fires change value messages one after the other to HA.
[{"id":"fed93ee95d2f1bbc","type":"function","z":"8684c94f.6f8c6","name":"Prep HASS","func":"//**************************************************\n// tags\nvar t = {\n d1: {\n value1: { d: 'input_number', s: 'set_value', id: 'gtst_test1' },\n value2: { d: 'input_text', s: 'set_value', id: 'gtst_test3' },\n },\n d2: {\n value1: { d: 'input_number', s: 'set_value', id: 'gtst_test2' },\n value2: { d: 'input_text', s: 'set_value', id: 'gtst_test4' },\n },\n}\n//**************************************************\n// output HASS data one item after the other\nvar pl = msg.payload.data;\nfor (let key in pl) {\n let group = pl[key];\n for (let gkey in group) {\n let msgout = {\n payload: {\n domain : t[key][gkey].d,\n service : t[key][gkey].s,\n target : {\n entity_id: t[key][gkey].d + '.' + t[key][gkey].id,\n },\n data : {\n value : group[gkey],\n },\n },\n };\n node.send(msgout);\n };\n};\nreturn null;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1230,"y":720,"wires":[["b814a5cf602856ba"]],"icon":"font-awesome/fa-cogs"},{"id":"3e1e77f9626f8b59","type":"function","z":"8684c94f.6f8c6","name":"Collect Data","func":"//**************************************************\n// measurements 1\nvar d1 = {\n value1: 72.3,\n value2: 'value 23.7°C',\n}\n//**************************************************\n// measurements 2\nvar d2 = {\n value1: 61.2,\n value2: 'value 34.8°C',\n}\n//**************************************************\n// package message\nvar msgout = {\n payload: {\n data: {\n d1: d1,\n d2: d2,\n },\n },\n};\n//\nreturn msgout;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1050,"y":720,"wires":[["fed93ee95d2f1bbc"]],"icon":"node-red/status.svg"},{"id":"b814a5cf602856ba","type":"api-call-service","z":"8684c94f.6f8c6","name":"set","server":"d359d15ddc344f8c","version":5,"debugenabled":false,"domain":"homeassistant","service":"check_config","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"all","x":1390,"y":720,"wires":[["b0b05af47e243562"]]},{"id":"b0b05af47e243562","type":"debug","z":"8684c94f.6f8c6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1530,"y":720,"wires":[]},{"id":"ceb0ded25d97733e","type":"inject","z":"8684c94f.6f8c6","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":890,"y":720,"wires":[["3e1e77f9626f8b59"]]},{"id":"d359d15ddc344f8c","type":"server","name":"HASS_Athome","version":5,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":": ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"default","statusTimeFormat":"h:m","enableGlobalContextStore":false}]
Some other question:
If I want to provide eg room data from NR to HA, then I need to create a lot of helpers in HA:
- room1_temp
- room1_humidity
- room1_lightintensity
- room2_temp
- room2_humidity
- room2_lightintensity
- roomX_…
Is there a way to create a custom sensor “roomsensor”
- temp
- humidity
- lightintensity
that can be instantiated as room1sensor, room2sensor, roomXsensor …