Remove all tags <...> from payload?

So I have Template nodes containing SSML content to send to my Echo devices around the house. I recently implemented some flows which direct the SSML to only the Echo devices with active movement in those rooms.. but, here's my issue, if no rooms have activity (no motion) I have that flow setup to send me a notification on my phone/watch instead. Now obviously, it's sending me the contents of that template node with all the SSML stuff in it.

Is there a way to filter out all the <...> tags from a payload? that way I can put that just before my notification node and it'll send just the text content I need.

Thanks

Are you using XML markup e.g...

<speak>
    <amazon:domain name="conversational">I really didn't know how this morning was going to start. And if I had known, I think I might have just stayed in bed.</amazon:domain>
</speak>

If so, the pass it through an XML node & it will be converted to a JS object where you can simply access the properties directly e.g...

image

image


If it is not XML format, then please share a sample of the data.

1 Like

Thanks a lot, Thats actually getting me on the right track; but i am still experiencing some strange errors doing this.

heres he basic flow:

[{"id":"e40781cf.54e29","type":"link in","z":"b66e483.15a8eb8","name":"<< Sent TTS to Echos","links":["4f28f450.f51e3c"],"x":275,"y":1260,"wires":[["6ce5b55c.0cdcbc"]]},{"id":"6ce5b55c.0cdcbc","type":"api-current-state","z":"b66e483.15a8eb8","name":"Home?","server":"51dc55f8.24de7c","version":1,"outputs":2,"halt_if":"Home","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_select.alarm_state","state_type":"str","state_location":"payload2","override_payload":"msg","entity_location":"data2","override_data":"msg","blockInputOverrides":false,"x":380,"y":1260,"wires":[["dbbfc5f6.85e2e8"],["21c5f14f.b4ac4e"]]},{"id":"dbbfc5f6.85e2e8","type":"change","z":"b66e483.15a8eb8","name":"Save TTS to Topic","rules":[{"t":"move","p":"payload","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":1260,"wires":[["f8ab3415.64f848","6ba078a8.c4a668"]]},{"id":"21c5f14f.b4ac4e","type":"api-current-state","z":"b66e483.15a8eb8","name":"Driving/Walking","server":"51dc55f8.24de7c","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"device_tracker.life360_jon","state_type":"str","state_location":"payload3","override_payload":"msg","entity_location":"data3","override_data":"msg","blockInputOverrides":false,"x":560,"y":1340,"wires":[["261cbfdb.fe0d4"]]},{"id":"f8ab3415.64f848","type":"ha-get-entities","z":"b66e483.15a8eb8","server":"51dc55f8.24de7c","name":"Which Rooms Active","rules":[{"property":"attributes.device_class","logic":"is","value":"motion","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":900,"y":1260,"wires":[["aaf94c4b.12ec7","d82430c8.9cb72"]]},{"id":"6ba078a8.c4a668","type":"delay","z":"b66e483.15a8eb8","name":"OCD Flow Spacer","pauseType":"delay","timeout":"5","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":910,"y":1460,"wires":[["45217454.bd8bac"]]},{"id":"261cbfdb.fe0d4","type":"switch","z":"b66e483.15a8eb8","name":"","property":"data.attributes.driving","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":710,"y":1340,"wires":[["ea4b3e58.c4fd7"],["493caa9e.829324"]]},{"id":"aaf94c4b.12ec7","type":"change","z":"b66e483.15a8eb8","name":"Active Rooms = Stop Trigger","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1200,"y":1420,"wires":[[]]},{"id":"d82430c8.9cb72","type":"switch","z":"b66e483.15a8eb8","name":"Send TTS to Active Rooms","property":"payload.entity_id","propertyType":"msg","rules":[{"t":"cont","v":"bedroom","vt":"str"},{"t":"cont","v":"living_room","vt":"str"},{"t":"cont","v":"bathroom","vt":"str"},{"t":"cont","v":"office","vt":"str"},{"t":"cont","v":"kitchen","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":1200,"y":1260,"wires":[["d81fe7ee.edbdf8"],["d81fe7ee.edbdf8"],["d81fe7ee.edbdf8"],["d81fe7ee.edbdf8"],["d81fe7ee.edbdf8"]]},{"id":"45217454.bd8bac","type":"stoptimer","z":"b66e483.15a8eb8","duration":"5","units":"Second","payloadtype":"str","payloadval":"on","name":"No Results Trigger","x":1470,"y":1460,"wires":[["511472ba.c2405c"],[]]},{"id":"ea4b3e58.c4fd7","type":"alexa-remote-routine","z":"b66e483.15a8eb8","name":"IVY - SPEAK (Car)","account":"c5773ff3.aec1","routineNode":{"type":"speak","payload":{"type":"ssml","text":{"type":"msg","value":"payload"},"devices":["G0W0SW08023602CW"]}},"x":910,"y":1320,"wires":[[]]},{"id":"493caa9e.829324","type":"api-call-service","z":"b66e483.15a8eb8","name":"Send Notification >","server":"51dc55f8.24de7c","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_jc_xs","entityId":"","data":"{\"message\":\"{{payload}}\",\"title\":\"MSG From PiVY\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":910,"y":1360,"wires":[[]]},{"id":"d81fe7ee.edbdf8","type":"debug","z":"b66e483.15a8eb8","name":"Off to Specific Echo Devices >>","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1600,"y":1260,"wires":[]},{"id":"511472ba.c2405c","type":"change","z":"b66e483.15a8eb8","name":"Set TTS Topic Back to Payload","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1530,"y":1740,"wires":[["2bc94680.cccbea"]]},{"id":"2bc94680.cccbea","type":"xml","z":"b66e483.15a8eb8","name":"","property":"payload","attr":"","chr":"","x":1750,"y":1740,"wires":[["87ee29fa.de5288"]]},{"id":"87ee29fa.de5288","type":"change","z":"b66e483.15a8eb8","name":"Pull Stripped-Tag SSML","rules":[{"t":"delete","p":"payload2","pt":"msg"},{"t":"delete","p":"data2","pt":"msg"},{"t":"delete","p":"_timerpass","pt":"msg"},{"t":"move","p":"payload.speak.voice[0].s[0]","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1950,"y":1740,"wires":[["7525bbb2.8fde44","e571f22f.8ec04"]]},{"id":"7525bbb2.8fde44","type":"api-call-service","z":"b66e483.15a8eb8","name":"Send Notification >","server":"51dc55f8.24de7c","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_jc_xs","entityId":"","data":"{\"message\":\"{{payload.speak.voice[0].s[0]\",\"title\":\"MSG From PiVY\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2210,"y":1780,"wires":[[]]},{"id":"e571f22f.8ec04","type":"debug","z":"b66e483.15a8eb8","name":"DEBUG NOTIFY","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2430,"y":1740,"wires":[]},{"id":"3d2f875b.b9de18","type":"inject","z":"b66e483.15a8eb8","name":"INJECT","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":1160,"wires":[["5a256305.9ccf3c"]]},{"id":"5a256305.9ccf3c","type":"template","z":"b66e483.15a8eb8","name":"Ivy SSML","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<speak>    \n<voice name=\"Ivy\">\n   <s>This is a test</s>\n   <s>This is a test of line 2</s>\n   <s>This is a test of line 3</s>\n   </voice>\n</speak>","output":"str","x":380,"y":1160,"wires":[["4f28f450.f51e3c"]]},{"id":"4f28f450.f51e3c","type":"link out","z":"b66e483.15a8eb8","name":"TTS To Echos >>","links":["e40781cf.54e29"],"x":505,"y":1160,"wires":[]},{"id":"51dc55f8.24de7c","type":"server","z":"","name":"PiVY HOME ASSISTANT","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"c5773ff3.aec1","type":"alexa-remote-account","z":"","name":"Alexa Account","authMethod":"proxy","proxyOwnIp":"192.168.0.104","proxyPort":"3456","cookieFile":"/config/alexa-auth.yaml","refreshInterval":"3","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.ca","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"off"}]

The problem(s) im running into are:

  • Its only adding the 1st line of text in the XML/SSML node -- i have 3 in this case (as seen in the SSML named node in my flow by inject)

  • Its not sending the notification due to "Error: Unclosed tag at 67", which doesn't tell me much. I don't even have a node in this flow with 67 lines. So having a tough time tracking down that problem as well.

Annotation 2020-08-23 191548

After playing around for a couple hours, i dont think this method is going to work [efficiently] for my needed application. The problems lie in the formatting of the original template node with the XML content. Not every node sending TTS is formatted the same way. Some have more line breaks, some have more sentence tags, more paragraph tags etc etc, simply copying the path to only one of the payload array paths isnt going to properly display the content and send it to the notification. Also the notify service is very picky when it comes to any text formatting whatsoever. so even a simple line breaks throws "no extra keys allowed" errors.