Hello.
These are my first steps with Node Red and Home Assistant. I have some battery-powered devices where I would like to send a notification when the battery runs low.
This has been my idea so far:
[{"id":"0ef04dc37c3d2c33","type":"tab","label":"Flow 3","disabled":false,"info":"","env":[]},{"id":"be534ff6981c7c7c","type":"api-call-service","z":"0ef04dc37c3d2c33","name":"Benachrichtigung R. Handy","server":"ea544f4f.d7486","version":4,"debugenabled":false,"domain":"notify","service":"mobile_app_rmx1993_roman","target":{"entityId":[],"areaId":[],"deviceId":[]},"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":840,"y":60,"wires":[[]]},{"id":"948391439ac32016","type":"server-state-changed","z":"0ef04dc37c3d2c33","name":"Wohnzimmer Fensterkontakt","server":"ea544f4f.d7486","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.wohnzimmer_fensterkontakt_hinten_battery","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":160,"y":40,"wires":[["dc4008089b6c239e"]]},{"id":"dc4008089b6c239e","type":"switch","z":"0ef04dc37c3d2c33","name":"Status bat_low","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"bat_low","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":60,"wires":[["e44370e6cd475414"]]},{"id":"e44370e6cd475414","type":"function","z":"0ef04dc37c3d2c33","name":"Msg","func":"msg.payload = {\"data\":{\"message\":\"Batterie von\" + \" ist schwach! \",\"title\":\"Wichtige Nachricht von HomeAssistant!\",\"data\":{\"group\":\"Batterie\"}}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":60,"wires":[["be534ff6981c7c7c"]]},{"id":"4a41b1aaac511640","type":"server-state-changed","z":"0ef04dc37c3d2c33","name":"Küche Fensterkontakt","server":"ea544f4f.d7486","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.kueche_fensterkontakt_battery","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":100,"wires":[["dc4008089b6c239e"]]},{"id":"ea544f4f.d7486","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":""}]
I hope this works the way I want it to. How do I get the name of the node or the friendly name in the function node? So that the name of the device is instead of the +.
function node:
msg.payload = {"data":{"message": "Batterie von" "+" " ist schwach! ","title":"Wichtige Nachricht von HomeAssistant!","data":{"group":"Batterie"}}};
return msg;
Or does someone have a better idea to implement my project? I would be very grateful for help.
Thank you.