Node Red Email Additional Filter

I created a pretty nice flow to announce whenever my son emails me from his school. This is quite useful in case I am in the house without my phone.

Anyway, the flow checks my email every 200 seconds and takes an email from my son’s email address and plays the content of the email over my sonos.

The difficult part of the Flow is that the message will continue to repeat every 200 seconds UNTIL I actually read the email.

Within the email Node there are a few options but I do NOT want the message marked as read (because what if I am not home).

Question: Using the Flow, is there a way to CAP the number of times a particular email is played on the Sonos speaker (ie. 3 times)?

[{"id":"709f957c51bf6c60","type":"ttsultimate","z":"d4f9ac9d.d5ff08","name":"","voice":"en-US","ssml":false,"sonosipaddress":"192.168.7.229","sonosvolume":"40","sonoshailing":"Hailing_Hailing.mp3","config":"4fb4091b8b8528dc","property":"payload","propertyType":{},"rules":[{"host":"192.168.7.198"},{"host":"192.168.7.206"}],"x":670,"y":1460,"wires":[["55a3e4a6e1183c42","aaa65b0c7ccd4c1f","08ac9c26ab520d6b"],[]]},{"id":"182bc5349cac4152","type":"switch","z":"d4f9ac9d.d5ff08","name":"","property":"from","propertyType":"msg","rules":[{"t":"cont","v":"[email protected]","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":430,"y":1480,"wires":[["709f957c51bf6c60","5788c1bbd85a477d","dd15d2c69d99be77"]]},{"id":"55a3e4a6e1183c42","type":"api-call-service","z":"d4f9ac9d.d5ff08","name":"Group Sonos Pool","server":"8efa78ba.f10338","version":3,"debugenabled":false,"service_domain":"sonos","service":"join","entityId":"media_player.gazebo_pool, media_player.unnamed_room","data":"{\"master\":\"media_player.gazebo_pool\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":890,"y":1420,"wires":[[]]},{"id":"aaa65b0c7ccd4c1f","type":"api-call-service","z":"d4f9ac9d.d5ff08","name":"Group Sonos Living Room","server":"8efa78ba.f10338","version":3,"debugenabled":false,"service_domain":"sonos","service":"join","entityId":"media_player.living_room, media_player.living_room_bar_connect","data":"{\"master\":\"media_player.living_room\"}","dataType":"json","mergecontext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","x":920,"y":1460,"wires":[[]]},{"id":"08ac9c26ab520d6b","type":"api-call-service","z":"d4f9ac9d.d5ff08","name":"Group Sonos","server":"8efa78ba.f10338","version":3,"debugenabled":false,"service_domain":"sonos","service":"join","entityId":"media_player.kitchen_tv_speaker, media_player.kitchen_overhead","data":"{\"master\":\"media_player.kitchen_tv_speaker\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":870,"y":1500,"wires":[["306a3e52788d5e62"]]},{"id":"72a884fa2ac45b4e","type":"e-mail in","z":"d4f9ac9d.d5ff08","name":"Matthew E-Mail","protocol":"IMAP","server":"imap.gmail.com","useSSL":true,"autotls":"never","port":"993","box":"INBOX","disposition":"None","criteria":"UNSEEN","repeat":"200","fetch":"auto","inputs":0,"x":100,"y":1480,"wires":[["182bc5349cac4152"]]},{"id":"5788c1bbd85a477d","type":"ha-get-entities","z":"d4f9ac9d.d5ff08","name":"","server":"8efa78ba.f10338","version":0,"rules":[{"property":"entity_id","logic":"includes","value":"media_player.gazebo_pool, media_player.kitchen_tv_speaker, media_player.laundry_room, media_player.living_room, media_player.living_room_bar_connect, media_player.portable, media_player.garage, media_player.kitchen_overhead","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":874,"y":1372,"wires":[["32d43d7608d8f6cf"]]},{"id":"dd15d2c69d99be77","type":"change","z":"d4f9ac9d.d5ff08","name":"","rules":[{"t":"change","p":"from","pt":"msg","from":"","fromt":"str","to":"","tot":"str"},{"t":"delete","p":"header","pt":"msg"},{"t":"delete","p":"date","pt":"msg"},{"t":"delete","p":"attachments","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":1540,"wires":[["1d3c71db36e5956f","08e7cb7ac42f7513"]]},{"id":"306a3e52788d5e62","type":"api-call-service","z":"d4f9ac9d.d5ff08","name":"Set Source TV and Volume","server":"8efa78ba.f10338","version":3,"debugenabled":false,"service_domain":"media_player","service":"select_source","entityId":"media_player.kitchen_tv_speaker","data":"{\"source\":\"TV\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1130,"y":1500,"wires":[[]]},{"id":"32d43d7608d8f6cf","type":"delay","z":"d4f9ac9d.d5ff08","name":"","pauseType":"delay","timeout":"17","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":1040,"y":1372,"wires":[["62e68563b62c597e"]]},{"id":"1d3c71db36e5956f","type":"api-call-service","z":"d4f9ac9d.d5ff08","name":"Notify","server":"8efa78ba.f10338","version":3,"debugenabled":false,"service_domain":"notify","service":"mobile_app_iphone","entityId":"","data":"{\"message\":\"Matthew sent an email with the subject line {{topic}}\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":620,"y":1520,"wires":[[]]},{"id":"08e7cb7ac42f7513","type":"debug","z":"d4f9ac9d.d5ff08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":1600,"wires":[]},{"id":"62e68563b62c597e","type":"api-call-service","z":"d4f9ac9d.d5ff08","name":"Revert Vol.","server":"8efa78ba.f10338","version":3,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"{{payload.entity_id}}","data":"{\"volume_level\":\"{{payload.attributes.volume_level}}\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1230,"y":1380,"wires":[[]]},{"id":"4fb4091b8b8528dc","type":"ttsultimate-config","name":"Config","noderedipaddress":"192.168.7.101","noderedport":"1980","purgediratrestart":"leave","ttsservice":"googletranslate"},{"id":"8efa78ba.f10338","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Store the email content in a flow variable and compare against this in a switch node before TTS

Yeah, I will need more detail on how to do that one #newbie

I’m typing from my phone so this is what I remember it as.

Add a change node after the TTS and change the drop-down that says msg to flow and type a variable name, like “content”.
Then you need to set what part of the message to save there, and that could probably be the TTS message

Before the TTS add a switch node and set it to not equal to the flow variable content.
And then at the top-ish of the configuration you set the setting that probably says msg.payload to what part of the message that is the email contents and/or the TTS message as above.