Node-red-google-notify - can it read msg.payload?

Anybody know if the node-red-google-notify node can read/annouce msg.payload instead of actual text?

I placed "msg.payload" in the text box and it just read msg.payload.

thanks

According to the read me at the url provided by you. leave the text box empty and put the message in msg.playMessage.

thanks @E1cid so, do I have to create another output from my function node as msg.playMessage?

[{"id":"e6fe31c8a7856135","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"8c55593abb94ee48","type":"switch","z":"e6fe31c8a7856135","name":"65 and Over","property":"windspeed_reading","propertyType":"msg","rules":[{"t":"gte","v":"65","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":730,"y":340,"wires":[["10df65511acee883"]]},{"id":"3671c4a6be544480","type":"api-current-state","z":"e6fe31c8a7856135","name":"Wind Speed 65 km/h < 65","server":"f11241dc.5364d","version":3,"outputs":2,"halt_if":"65","halt_if_type":"num","halt_if_compare":"lt","entity_id":"{{data.entity_id}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"windspeed_reading","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":1230,"y":340,"wires":[["842a47faa025dfe6","73f9a70bb35eba81"],["d94b206ebbe4292b"]]},{"id":"d94b206ebbe4292b","type":"delay","z":"e6fe31c8a7856135","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"2","nbRateUnits":"30","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":1200,"y":420,"wires":[["3671c4a6be544480"]]},{"id":"10df65511acee883","type":"trigger","z":"e6fe31c8a7856135","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"topic","topic":"topic","outputs":1,"x":940,"y":340,"wires":[["3671c4a6be544480","a06cd7ed94489809"]]},{"id":"842a47faa025dfe6","type":"change","z":"e6fe31c8a7856135","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"yes","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":260,"wires":[["10df65511acee883"]]},{"id":"bacac2f01936ec61","type":"server-state-changed","z":"e6fe31c8a7856135","name":"Wind Speed Warning","server":"f11241dc.5364d","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.wind_speed_2","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":260,"y":340,"wires":[["b4eb1dd1769ba5ca"]]},{"id":"b4eb1dd1769ba5ca","type":"change","z":"e6fe31c8a7856135","name":"Set Wind Speed and topic","rules":[{"t":"set","p":"windspeed_reading","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Wind Speed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":340,"wires":[["8c55593abb94ee48"]]},{"id":"a06cd7ed94489809","type":"function","z":"e6fe31c8a7856135","name":"","func":"msg.payload = msg.topic + \" Wind Speed levels are at \" + msg.windspeed_reading + \" km/h\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1200,"y":480,"wires":[["13445f53af542d77","899c951cedc2ed58"]]},{"id":"73f9a70bb35eba81","type":"function","z":"e6fe31c8a7856135","name":"","func":"msg.payload = msg.topic + \" Wind Speed levels are now safe.\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1460,"y":340,"wires":[["1f5fcb0b50bdc98c","bff8a1379446ad40"]]},{"id":"1f5fcb0b50bdc98c","type":"debug","z":"e6fe31c8a7856135","name":"Safe Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1680,"y":340,"wires":[]},{"id":"13445f53af542d77","type":"debug","z":"e6fe31c8a7856135","name":"Danger Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1690,"y":560,"wires":[]},{"id":"899c951cedc2ed58","type":"google-notify","z":"e6fe31c8a7856135","server":"54d5eba8aec34a98","label":"Basement Bedroom Broadcast","playVolumeLevel":"60","playMessage":"Warning! The outdoor Wind Speed is over 65 km/h!","language":"config","speakSlow":"false","mediaUrl":"","mediaType":"mp3","x":1730,"y":600,"wires":[[]]},{"id":"bff8a1379446ad40","type":"api-call-service","z":"e6fe31c8a7856135","name":"Notify Me Sony Xperia Phone","server":"f11241dc.5364d","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_sony_xperia_zx1","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1720,"y":400,"wires":[[]]},{"id":"f11241dc.5364d","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"54d5eba8aec34a98","type":"google-notify-config","ipaddress":"192.168.1.94","name":"Basement Bedroom Clock","language":"en","playVolumeLevel":"20","speakSlow":true,"mediaServerUrl":"","mediaServerPort":"8098","cacheFolder":"/tmp"}]

If by output you mean msg property yes
e.g.

[{"id":"3671c4a6be544480","type":"api-current-state","z":"e6fe31c8a7856135","name":"Wind Speed 65 km/h < 65","server":"f11241dc.5364d","version":3,"outputs":2,"halt_if":"65","halt_if_type":"num","halt_if_compare":"lt","entity_id":"{{data.entity_id}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"windspeed_reading","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":1230,"y":340,"wires":[["842a47faa025dfe6","73f9a70bb35eba81"],["d94b206ebbe4292b"]]},{"id":"842a47faa025dfe6","type":"change","z":"e6fe31c8a7856135","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"yes","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":260,"wires":[["10df65511acee883"]]},{"id":"73f9a70bb35eba81","type":"function","z":"e6fe31c8a7856135","name":"","func":"msg.payload = msg.topic + \" Wind Speed levels are now safe.\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1460,"y":340,"wires":[["1f5fcb0b50bdc98c","bff8a1379446ad40"]]},{"id":"d94b206ebbe4292b","type":"delay","z":"e6fe31c8a7856135","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"2","nbRateUnits":"30","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":1200,"y":420,"wires":[["3671c4a6be544480"]]},{"id":"10df65511acee883","type":"trigger","z":"e6fe31c8a7856135","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"topic","topic":"topic","outputs":1,"x":940,"y":340,"wires":[["3671c4a6be544480","a06cd7ed94489809"]]},{"id":"1f5fcb0b50bdc98c","type":"debug","z":"e6fe31c8a7856135","name":"Safe Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1680,"y":340,"wires":[]},{"id":"bff8a1379446ad40","type":"api-call-service","z":"e6fe31c8a7856135","name":"Notify Me Sony Xperia Phone","server":"f11241dc.5364d","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_sony_xperia_zx1","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"{{payload}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1720,"y":400,"wires":[[]]},{"id":"8c55593abb94ee48","type":"switch","z":"e6fe31c8a7856135","name":"65 and Over","property":"windspeed_reading","propertyType":"msg","rules":[{"t":"gte","v":"65","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":730,"y":340,"wires":[["10df65511acee883"]]},{"id":"a06cd7ed94489809","type":"function","z":"e6fe31c8a7856135","name":"","func":"msg.playMessage = msg.topic + \" Wind Speed levels are at \" + msg.windspeed_reading + \" km/h\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1200,"y":480,"wires":[["13445f53af542d77","899c951cedc2ed58"]]},{"id":"b4eb1dd1769ba5ca","type":"change","z":"e6fe31c8a7856135","name":"Set Wind Speed and topic","rules":[{"t":"set","p":"windspeed_reading","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Wind Speed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":340,"wires":[["8c55593abb94ee48"]]},{"id":"13445f53af542d77","type":"debug","z":"e6fe31c8a7856135","name":"Danger Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1690,"y":560,"wires":[]},{"id":"899c951cedc2ed58","type":"google-notify","z":"e6fe31c8a7856135","server":"54d5eba8aec34a98","label":"Basement Bedroom Broadcast","playVolumeLevel":"60","playMessage":"","language":"config","speakSlow":"false","mediaUrl":"","mediaType":"mp3","x":1730,"y":600,"wires":[[]]},{"id":"bacac2f01936ec61","type":"server-state-changed","z":"e6fe31c8a7856135","name":"Wind Speed Warning","server":"f11241dc.5364d","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.wind_speed_2","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":260,"y":340,"wires":[["b4eb1dd1769ba5ca"]]}]

Fanstastic, that works! except it breaks my text message warnings because it wants msg.payload and not msg.playMessage

Now, I could change everything to msg.playMessage (but I have modify several nodes)...or is it possible, to make msg.payload = msg.playMessage just before it hits the google speaker notify node?

I don't see how it breaks your text message, as msg.playMessage only goes to google notify node in the example i showed. Are you implementing this any different to my example?

To answer this question specifically - yes you can use a Change node to do exactly that.

1 Like

thanks @E1cid and @knolleary, heres what I had to do:

change all msg.payload to msg.playMessage
delete text entries it google notify nodes (all blank now)

and now, with this set up like this, the message on all three notification platforms is the same:

  • dubug panel
  • HA (Home assistant) push notication on App
  • Google notifcation

with the actual values in the messages

It would have been a lot easier (for me at least) if I can change the node setup to read msg.payload rather than msg.playMessage.

Here's an example, what do you think?

[{"id":"516e5bcdddd06d97","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"99288887cf4bbf1b","type":"switch","z":"516e5bcdddd06d97","name":"70 and Over","property":"windgust_reading","propertyType":"msg","rules":[{"t":"gte","v":"70","vt":"num"}],"checkall":"false","repair":false,"outputs":1,"x":1590,"y":780,"wires":[["1274bb9fbefc2233"]]},{"id":"ae4d4f134067b063","type":"api-current-state","z":"516e5bcdddd06d97","name":"Wind Gust 70 km/h < 70","server":"f11241dc.5364d","version":3,"outputs":2,"halt_if":"70","halt_if_type":"num","halt_if_compare":"lt","entity_id":"{{data.entity_id}}","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"windgust_reading","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":2090,"y":780,"wires":[["4289e8ca821ca901","6e5a07104ed84963"],["23d0d48c4406b68c"]]},{"id":"23d0d48c4406b68c","type":"delay","z":"516e5bcdddd06d97","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"2","nbRateUnits":"30","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":2060,"y":860,"wires":[["ae4d4f134067b063"]]},{"id":"1274bb9fbefc2233","type":"trigger","z":"516e5bcdddd06d97","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"0","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"topic","topic":"topic","outputs":1,"x":1800,"y":780,"wires":[["ae4d4f134067b063","178ff60128efda3e"]]},{"id":"4289e8ca821ca901","type":"change","z":"516e5bcdddd06d97","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"yes","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2030,"y":700,"wires":[["1274bb9fbefc2233"]]},{"id":"06360c1cace233c5","type":"server-state-changed","z":"516e5bcdddd06d97","name":"Wind Gust Warning","server":"f11241dc.5364d","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.wind_gust_2","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":"playMessage","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":1110,"y":780,"wires":[["29f0a2e4588d9ba6"]]},{"id":"29f0a2e4588d9ba6","type":"change","z":"516e5bcdddd06d97","name":"Set Gust Speed and topic","rules":[{"t":"set","p":"windgust_reading","pt":"msg","to":"playMessage","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Wind Gust","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1370,"y":780,"wires":[["99288887cf4bbf1b"]]},{"id":"178ff60128efda3e","type":"function","z":"516e5bcdddd06d97","name":"","func":"msg.playMessage = \"Warning! \" + msg.topic + \" levels are at \" + msg.windgust_reading + \" km/h!\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2060,"y":920,"wires":[["08c2115bebe4be8c","802be617fc58f1f2","cfeb3514be04b2b1"]]},{"id":"6e5a07104ed84963","type":"function","z":"516e5bcdddd06d97","name":"","func":"msg.payload = msg.topic + \" Wind Gusts levels are now safe.\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2320,"y":780,"wires":[["768a73ec4d191e3d","c1c148b2fe623424"]]},{"id":"768a73ec4d191e3d","type":"debug","z":"516e5bcdddd06d97","name":"Safe Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"playMessage","targetType":"msg","statusVal":"","statusType":"auto","x":2540,"y":780,"wires":[]},{"id":"08c2115bebe4be8c","type":"debug","z":"516e5bcdddd06d97","name":"Danger Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"playMessage","targetType":"msg","statusVal":"","statusType":"auto","x":2550,"y":1000,"wires":[]},{"id":"802be617fc58f1f2","type":"google-notify","z":"516e5bcdddd06d97","server":"54d5eba8aec34a98","label":"Basement Bedroom Broadcast","playVolumeLevel":"60","playMessage":"","language":"config","speakSlow":"false","mediaUrl":"","mediaType":"mp3","x":2590,"y":1040,"wires":[[]]},{"id":"cfeb3514be04b2b1","type":"api-call-service","z":"516e5bcdddd06d97","name":"Notify Me Sony Xperia Phone","server":"f11241dc.5364d","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_sony_xperia_zx1","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"{{playMessage}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2590,"y":1100,"wires":[[]]},{"id":"c1c148b2fe623424","type":"api-call-service","z":"516e5bcdddd06d97","name":"Notify Me Sony Xperia Phone","server":"f11241dc.5364d","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_sony_xperia_zx1","areaId":[],"deviceId":[],"entityId":[],"data":"{\"message\":\"{{playMessage}}\"}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2580,"y":840,"wires":[[]]},{"id":"f11241dc.5364d","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"54d5eba8aec34a98","type":"google-notify-config","ipaddress":"192.168.1.94","name":"Basement Bedroom Clock","language":"en","playVolumeLevel":"20","speakSlow":true,"mediaServerUrl":"","mediaServerPort":"8098","cacheFolder":"/tmp"}]

Could you have just added a Change node setting msg.playMessage to msg.payload and leave everything else the same?

Yes, BUT i got that message too late ...so I just changed everything after the fact.

Now, thinking about it, I probably saved adding 30 extra nodes, however I spent almost 1.5 hrs updating the nodes...I don't know what is better. Time will tell if this change I made will be future proof.

Have you got 30 google-notify nodes?

I have about 112 of them, but maybe 50 of them (not 30) are associated with text warnings also.

You could add a feature request to the node's github page.

1 Like

will do, good idea!

Turns out, this was actually implemented in the last update (that it will announce what msg.payload is). I'll have to check if I have the latest version now!

no that note, how do I actually check my version of the plug-in on Home Assistant?

Look in the Menu > Manage Palette

ok, turns out I do have the latest version.

Now, come to think about it, had a I left the text box blank (instead of adding msg.payload or any other words in the text box of the google-notify node), it would have worked. I'll have to go back now and change all the:

msg.playMessage

to

msg.payload

Is there a quick way to do this without having me edit/open ~100 nodes to replace the value?

I guess I could export my flows, then do a word -replacement (like the one in MS Word, and others), but wonder how I could do this without messing up the formating, or even do it in the Node-Red environment.

Technically, I don't have to change it back, but I suspect you would want to change it back, too :slight_smile:

Ok, live and learn.

Thank you all for your help.

If you make a backup copy of your flows.json file then you could run a text editor on the original (a straight text editor, not a work processor) and do a search and replace. Then restart node-red. If it is a disaster then you can restore the orginal. In fact you no doubt take regular backups anyway so you may not even need to make an extra backup. Probably best anyway though. For the editor, on linux something like gedit would be fine.

1 Like

I can use the File Editor in HA to access the Node-Red files.

Which file(s) am I looking for exactly to do the word replacement?

The flows file. Nomally it would be flows.json. I have no idea what HA calls it or where itputs it, but on a normal install it would be in your .node-red folder.