Hi @Kermit
Could you advise on how i do this flow with get entities.
basically when i press my ikea button i want it to check the sensors and if any are open send a notification to me and my wifes phone but if everything is closed i want it t do a call service (mqtt publish) that turns on my house alarm.
It checks the sensors and notifies the phones no problem if something is open i just can’t figure out how to have it do the call service if everything is fine.
Thanks
[{"id":"2a64f2bf.cb9eae","type":"inject","z":"f61766ce.f85398","name":"button","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":178,"y":4848,"wires":[["71924764.2a30e8"]]},{"id":"71924764.2a30e8","type":"ha-get-entities","z":"f61766ce.f85398","name":"","server":"","version":0,"rules":[{"property":"entity_id","logic":"includes","value":"binary_sensor.one, binary_sensor.two","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":326,"y":4848,"wires":[["4f1a26c4.00a2a8"]]},{"id":"4f1a26c4.00a2a8","type":"switch","z":"f61766ce.f85398","name":"count","property":"payload.length","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":482,"y":4848,"wires":[["3ab50530.78f91a"],["9f5e5fbe.1ce6e"]]},{"id":"3ab50530.78f91a","type":"api-call-service","z":"f61766ce.f85398","name":"Turn alarm on","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":656,"y":4800,"wires":[[]]},{"id":"c2652c5a.061a2","type":"template","z":"f61766ce.f85398","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"This is the payload: {{payload}} !","output":"str","x":764,"y":4848,"wires":[["4ee39c28.629f54"]]},{"id":"9f5e5fbe.1ce6e","type":"split","z":"f61766ce.f85398","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":626,"y":4848,"wires":[["c2652c5a.061a2"]]},{"id":"4ee39c28.629f54","type":"join","z":"f61766ce.f85398","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":"false","timeout":"","count":"","reduceRight":false,"x":898,"y":4848,"wires":[["b9206ed1.826a9","c66be9a3.7c0f38"]]},{"id":"b9206ed1.826a9","type":"api-call-service","z":"f61766ce.f85398","name":"Steve Notifaction","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1066,"y":4848,"wires":[[]]},{"id":"c66be9a3.7c0f38","type":"api-call-service","z":"f61766ce.f85398","name":"Sara Notifaction","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1056,"y":4896,"wires":[[]]}]
Thanks for that i would never have worked that out just configuring it to my entities now
Hi I’m being a bit thick I’ve just set it up and it does seem to work as it sets the alarm off everything is closed but the notification didn’t list the device just said [object object] where the device name should be
I know it’s me probably doing something wrong.
Did you change the template node? I think I just left it blank. You’ll need to put something like {{msg.payload.attributes.friendly_name}}
or whatever you probably had before.
Ah right yeah I wasn’t sure what went in there so just left {{payload}}.
I’ve copied in that text now but can’t test now as the family’s gone to bed.
But thanks again
Hi I’m looking for a little help with the Get Entities node.
I’m trying to query any entities that match ‘binary.sensors.window*’ or 'binary.sensors.door* and are also “open” and then pass the output as a single array.
I dont know how to create an “or” within get entities which I thought could be a simple approach.
I’ve also tried joining two get entities nodes using a join node, but I appear to get two arrays…
Would love some pointers!
[{"id":"38f9166d.585bea","type":"ha-get-entities","z":"36a1103a.71fc2","name":"","server":"7038aa85.7503b4","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"binary_sensor.window","valueType":"str"},{"property":"state","logic":"includes","value":"off","valueType":"str"}],"output_type":"split","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":370,"y":900,"wires":[["8a212f39.ad44"]]},{"id":"99a66475.adf878","type":"inject","z":"36a1103a.71fc2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":900,"wires":[["38f9166d.585bea","acc54dde.a07d6"]]},{"id":"8a212f39.ad44","type":"join","z":"36a1103a.71fc2","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":590,"y":920,"wires":[["747a728e.fba73c"]]},{"id":"acc54dde.a07d6","type":"ha-get-entities","z":"36a1103a.71fc2","name":"","server":"7038aa85.7503b4","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"binary_sensor.door","valueType":"str"},{"property":"state","logic":"includes","value":"off","valueType":"str"}],"output_type":"split","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":370,"y":960,"wires":[["8a212f39.ad44"]]},{"id":"7038aa85.7503b4","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
You can use a regular expression for the entity id.
binary_sensors\.(?:window|door).*
Howdy all, I’m new to Node Red and I’ve cribbed a bit of announcement magic and I am running into a problem. I have a flow that is supposed to monitor the state of whether me and the wife are at home and announce our arrival / departure. If I inject after a state change after the get entities node I can get the notification to fire but I don’t get the proper names delivered to the function node. I’ve tried watching the get entities node with debug but I get nothing out at all…a push in the right direction would be great.
A bit more looking and it seems I’m not configuring the “get entities” node properly parse the entities that have the state “home”…tried a few different things and I’m not getting anywhere. Thoughts?
[{"id":"2b5d3c6b.d68bb4","type":"debug","z":"729d4aa5.48ac54","name":"Coming Home","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":900,"y":200,"wires":[]},{"id":"fb0a5779.ee1c58","type":"join","z":"729d4aa5.48ac54","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":", ","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":790,"y":120,"wires":[["2b5d3c6b.d68bb4"]]},{"id":"6a94e4c7.d74b7c","type":"template","z":"729d4aa5.48ac54","name":"Format Names","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.data.attributes.friendly_name}}","output":"str","x":640,"y":120,"wires":[["fb0a5779.ee1c58"]]},{"id":"7c17b95e.d8e048","type":"inject","z":"729d4aa5.48ac54","name":"Paul Home","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"topic\":\"person.paul_carson\",\"payload\":\"home\",\"data\":{\"entity_id\":\"person.paul_carson\",\"old_state\":{\"entity_id\":\"person.paul_carson\",\"state\":\"not_home\",\"attributes\":{\"editable\":false,\"id\":\"paul_carson\",\"latitude\":38.3092331,\"longitude\":-76.5652201,\"gps_accuracy\":14,\"source\":\"device_tracker.pixel_5\",\"user_id\":\"4e1bdd31b52b480b95927830eb56d2d1\",\"friendly_name\":\"Paul\"},\"last_changed\":\"2021-06-08T20:27:31.614106+00:00\",\"last_updated\":\"2021-06-08T20:27:31.614106+00:00\",\"context\":{\"id\":\"f664793b6c72d6fb5f071657fb0b8640\",\"parent_id\":null,\"user_id\":\"4e1bdd31b52b480b95927830eb56d2d1\"},\"original_state\":\"not_home\"},\"new_state\":{\"entity_id\":\"person.paul_carson\",\"state\":\"home\",\"attributes\":{\"editable\":false,\"id\":\"paul_carson\",\"latitude\":38.3092331,\"longitude\":-76.5652201,\"gps_accuracy\":14,\"source\":\"device_tracker.pixel_5\",\"user_id\":\"4e1bdd31b52b480b95927830eb56d2d1\",\"friendly_name\":\"Paul\"},\"last_changed\":\"2021-06-08T20:27:47.881904+00:00\",\"last_updated\":\"2021-06-08T20:27:47.881904+00:00\",\"context\":{\"id\":\"9a0fef9200bfa0815fd24c81faafb9c2\",\"parent_id\":null,\"user_id\":\"4e1bdd31b52b480b95927830eb56d2d1\"},\"original_state\":\"home\",\"timeSinceChangedMs\":11}},\"_msgid\":\"55955244.6efbec\"}","payloadType":"json","x":480,"y":180,"wires":[["c287b2d.1e7eb5"]]},{"id":"c287b2d.1e7eb5","type":"ha-get-entities","z":"729d4aa5.48ac54","server":"e0e5de46.64d5","name":"","rules":[{"property":"attributes.user_id","logic":"includes","value":"person.paul_carson, person.cris","valueType":"str"},{"property":"state","logic":"is","value":"home","valueType":"str"},{"property":"timesincechangedms","logic":"lt","value":"300000","valueType":"num"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":450,"y":120,"wires":[[]]},{"id":"3601c3e8.628edc","type":"server-state-changed","z":"729d4aa5.48ac54","name":"Paul","server":"e0e5de46.64d5","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"person.paul_carson","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"home","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":70,"y":120,"wires":[["c287b2d.1e7eb5"],["65b42cb7.666674"]]},{"id":"e0e5de46.64d5","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
If anyone comes for a similar answer. My problem ended up being that timesincechangedms should have ben timeSinceChangedMs…remember boys and girls capitalization matters
I’m a bit new with node red and got some things working now.
busy with the entities node, just want to send a telegram message with buienradar weather info
some sensor states just all
Got it working with a single sensor state send at a specifick time.
But I want to use the entities nodes and send 4 or 5 lines with data of the wheater in it.
the entity debug gives
msg.payload : array[106]
array[106]
[0 … 9]
etc etc...
[10 … 19]
10: object
entity_id: "sensor.buienradar_humidity"
state: "89"
attributes: object
attribution: "Data provided by buienradar.nl"
Stationname: "De Bilt (6260)"
Measured: "Mon Jul 26 19:20:00 2021"
unit_of_measurement: "%"
friendly_name: "Buienradar Humidity"
icon: "mdi:water-percent"
last_changed: "2021-07-26T17:38:38.940997+00:00"
last_updated: "2021-07-26T17:38:38.940997+00:00"
the flow is simple for now
time - entity - template - telegram
in the template I got
propety. payload
and template
{{payload.attributes.Buienradar Wind direction}}
{{msg.payload.attributes.Buienradar Humidity}}
🌡️ Temparatuur Morgen = {{"sensor.buienradar_temperature_1d' }}°C
🌡️ Temparatuur Overmorgen = ?? °C
🌧️ Regen verwachting = ?? mm
🌧️ Regen percantage = ?? %
🌬️ Wind kracht nu = ?? Bft
🌬️ Wind Kracht morgen = ?? Bft"
tried some things but i won’t get the data behind the tekst in the message
I thing i’m almost there but still far away
You are probably better off using several current state node in series and setting the output properties to custom locations depending on the data you need from each one.
Temp = {{sensor1}}
Wind Direction = {{sensor2Data.attributes.windDirection}}
Humidity = {{sensor2Data.attributes.humidity}}
thanks for the reply. I want to try this but it looks like I have a other current state node?
don’t have the output properties.
Putting nodes in serie won’t get what I wanted
I have found my soloution.
Only the entities - funciton - telegram nodes.
Entities I read out and with the function I made the message with the right value’s and information combined with the text I want.
In the funciton node the follow codes
msg.payload = {
"chatId": "xxxxxxxx",
"type":"message",
"content":
"**WEERBERICHT** \n" +
"Weerbericht Morgen = \n" + msg.payload[101].state +
"\n \n Temparatuur Morgen = " + msg.payload[26].state +
" °C\n Regenhoeveelheid morgen = " + msg.payload[36].state +
"mm\n Regenverwachting morgen = " + msg.payload[51].state +
"%\n WindKracht morgen = " + msg.payload[61].state +
" Bft\n \n Weerbericht OverMorgen = \n" + msg.payload[102].state +
"\n \n Temparatuur OverMorgen = " + msg.payload[27].state +
" °C\n Regenhoeveelheid Overmorgen = " + msg.payload[37].state +
"mm\n Regenverwachting Overmorgen = " + msg.payload[52].state +
"%\n WindKracht Overmorgen = " + msg.payload[62].state +" Bft"
};
return msg;
Is there an equivalent tigger node similar to this “get entities node” that can use regex on attribute? See below screenshot, how can I get trigger node with these condition? Thanks.
[{"id":"fc0f30a1625cdb45","type":"server-state-changed","z":"ffbd7f06.4a014","name":"","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":".*","entityidfiltertype":"regex","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"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":"eventData"}],"x":816,"y":304,"wires":[["c16934adedc4a6a8"],[]]},{"id":"6a06ddeb482437a8","type":"debug","z":"ffbd7f06.4a014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1160,"y":304,"wires":[]},{"id":"c16934adedc4a6a8","type":"switch","z":"ffbd7f06.4a014","name":"","property":"payload.new_state.attributes.friendly_name","propertyType":"msg","rules":[{"t":"regex","v":"wyze","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":1,"x":996,"y":304,"wires":[["6a06ddeb482437a8"]]}]
that’s smart usage. thanks!
Ok. But anyone can tell me how to use it to send some message to people who are actually in “home” i use get entity node, it work well but have no idea how to send notification to that one entity.
i mean. i left home, and 3 more person still in home. then something happend and wont to that 3 person get notification about that, without me cuz im not “home”
[{"id":"0c0ac1bad0f3dd34","type":"inject","z":"894a6b3077af9604","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":282,"y":784,"wires":[["6804063ea0604dc8"]]},{"id":"6804063ea0604dc8","type":"ha-get-entities","z":"894a6b3077af9604","name":"","server":"","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"device_tracker.","valueType":"str"},{"property":"state","logic":"is","value":"home","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":454,"y":784,"wires":[["d801a3b8a45754cc"]]},{"id":"d801a3b8a45754cc","type":"function","z":"894a6b3077af9604","name":"","func":"const userMap = {\n \"device_tracker.homer\": \"mobile_app_homer\",\n \"device_tracker.marge\": \"mobile_app_marge\",\n \"device_tracker.bart\": \"mobile_app_bart\",\n \"device_tracker.lisa\": \"mobile_app_lisa\"\n};\n\n\nif(userMap[msg.payload.entity_id]) {\n msg.payload = {\n service: userMap[msg.payload.entity_id]\n };\n \n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":784,"wires":[["ce38aaf1ee9ee9ec"]]},{"id":"ce38aaf1ee9ee9ec","type":"api-call-service","z":"894a6b3077af9604","name":"","server":"","version":3,"debugenabled":false,"service_domain":"notify","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":784,"wires":[[]]}]