Is there an example of a full blown Node-RED Entity
node?
I am hoping / trying to create + update a Climate entity.
Or something that I can create + feed a Generic Thermostat entity with (using temperature sensor).
Below is the work in progress. Tried to create Climate Entity
, but don’t think this will work.
Related, how can I use mustache variables in Home Assistant Config panel. See screenshot for name
.
The {{payload.cust_name}}
is not interpreted, but used literally.
Have you had any more luck with this? I’m trying to do the same thing.
No, no further progress yet.
The mustache issue is a problem for my use case, and the rest is too unclear for me.
Have you tried creating a global or flow variable using mustache prior to the create node? Then maybe you can just reference it that way like you did the other attributes (flow.blah.blah.blah).
That would still be in the form of mustache notation, right?
It seems that field is not interpreted, but stored literally (so: if I use a node to set flow.blah to interpret "wanted value {{payload.value1}} as “wanted value 123” then the Entity config field does not interpret {{flow.blah}} but stores “flow.blah”).
I guess you are right there. I didn’t realize until now that the Home Assistant Config part of the entity
node seems to just allow only text input.
Is your goal to have this flow creating lots of new entities for different customers thus the need to control the entity_name
?
Yes, in my case I have multiple thermostats.
I use API to get the details of the thermostats (JSON array) and then use split
to create a “for loop” for each thermostat where I create & update the Entity.
But once you create the entity do you really need to create them again? Why not just create the sensor in HA and then use NR to update them? You could actually create the mapping from the thermostat name to the entity_id
in an array in NR then loop through it like you are doing.
I do something similar with a TV Channel sensor. I have the mapping of channel number and channel names for my cable provider in a template node then use a CSV to Array node, then match the channel number I get from a tv sensor I have to set a payload variable to the channel name so in the end, I get set the HA entity <channel number>
and <channel name>
attributes.
a) I would like the setup to be as dynamic as possible. It is the API of the thermostat that determines which thermostats there are, and would be great if NR can create and update the related entities.
b) even if I create them in HA and fill them using NR, how can I feed split
node output to an Entity
node using dynamic data?
At the moment I have set in Entity Node > Home Assistant Config (optional) > name
: mythermostat_{{payload.cust_name}}
, which in HA shows up as sensor.mythermostat_payload_cust_name
. So: it seems the HA entity name is taken from that field.
And to go back to the main question: can I create a Climate
entity in Node-RED?
a) yeah I don’t think you will be able to do that from what it looks like as the entity node only takes “text” as in input for that field and not NR payloads, so no mustache either.
b) I think this can be done, you would do the split and then after that in the flow you could have the array look up to replace the name that HA has assigned.
I have no idea abut the Climate create question though.
If you have a look at this thread there is an example of how to set the climate entities as part of the node red scheduler example.
That link is about interacting with an existing climate entity.
My question was about creating a climate entity.
Can you post your node red flow and I’ll have a look as I can have a look.
Here’s a basic example of the work in progress, which results in the mustache issue.
(btw since then the custom component became available, which I am using instead of using Node-RED)
[{"id":"3b92267.32283da","type":"ha-entity","z":"a8a7e3db.c48fb","name":"thermostat","server":"59295238.0f105c","version":1,"debugenabled":true,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"uponor_{{payload.cust_name}}"},{"property":"device_class","value":"climate"},{"property":"icon","value":"mdi:thermostat"},{"property":"unit_of_measurement","value":"°C"}],"state":"payload.room_temperature","stateType":"msg","attributes":[{"property":"temperature_unit","value":"TEMP_CELSIUS","valueType":"str"},{"property":"current_temperature","value":"payload.room_temperature","valueType":"msg"},{"property":"current_humidity","value":"payload.rh","valueType":"msg"},{"property":"target_temperature","value":"payload.setpoint","valueType":"msg"},{"property":"min_temp","value":"payload.minimum_setpoint","valueType":"msg"},{"property":"max_temp","value":"payload.maximum_setpoint","valueType":"msg"},{"property":"last_updated","value":"","valueType":"date"},{"property":"actuator","value":"payload.actuator","valueType":"msg"},{"property":"friendly_name","value":"payload.cust_name","valueType":"msg"},{"property":"hvac_modes","value":"HVAC_MODE_OFF, HVAC_MODE_HEAT, HVAC_MODE_AUTO","valueType":"str"},{"property":"hvac_mode","value":"HVAC_MODE_OFF","valueType":"str"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":1190,"y":960,"wires":[[]]},{"id":"366277b8.24f048","type":"inject","z":"a8a7e3db.c48fb","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":660,"y":960,"wires":[["d6f5a679.498d08"]]},{"id":"d6f5a679.498d08","type":"function","z":"a8a7e3db.c48fb","name":"set thermostat data","func":"msg.payload = [\n{\n cust_name: 'office',\n room_temperature: 21.1,\n setpoint: 20,\n rh: 31,\n actuator: 0,\n},\n{\n cust_name: 'bedroom',\n room_temperature: 20.2,\n setpoint: 20,\n rh: 28,\n actuator: 0,\n}\n]\nreturn msg;","outputs":1,"noerr":0,"x":850,"y":960,"wires":[["f87b32ad.cfad"]]},{"id":"f87b32ad.cfad","type":"split","z":"a8a7e3db.c48fb","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1030,"y":960,"wires":[["3b92267.32283da"]]},{"id":"59295238.0f105c","type":"server","z":"","name":"Home Assistant"}]
Did you find a way to do this ?
No. My heating system is now supported in HA, so I have abandoned the Node-RED approach.