Huge thanks for this, really helped get room aware stuff working that I’ve been wanting to do for years with Alexa. Thought I’d share some small tweaks I made to the original approach to cut down on some repetition. Main changes from the original posted at top of the thread:
- Check the domain is “HomeAutomation” which filters out extra calls from other Echos in the area
- Cleared the data payload to avoid some down flow errors
- Set actions in the msg body earlier in the flow so there isn’t duplication
- Route based on device name as opposed to serial number
- Added replies for devices where the command doesn’t apply
Few other notes:
- 586837r doesn’t seem to be maintaining node-red-contrib-alexa-remote2 anymore, I strongly suggest using the node-red-contrib-alexa-cakebaked fork instead
- This flow doesn’t actually create any of the devices in Alexa, you’ll need to create dummy devices through one of the many other means (for example I have a device named “fan” that doesn’t actually control anything)
Here is my config that controls a series of Fans, TVs (including inputs for TiVo, Shield, & Games), and Blinds.
[{"id":"35964044.fcf53","type":"tab","label":"Contextual Alexa Routines","disabled":false,"info":""},{"id":"35bdb0e0.53f29","type":"alexa-remote-event","z":"35964044.fcf53","name":"","account":"bdd909b1.9333d8","event":"ws-device-activity","x":170,"y":460,"wires":[["a35c1f26.931b78"]]},{"id":"545ebb02.da3e74","type":"switch","z":"35964044.fcf53","name":"Contextual Route Fan","property":"payload.description.summary","propertyType":"msg","rules":[{"t":"regex","v":"turn off (the )?fan","vt":"str","case":false},{"t":"regex","v":"turn (the )?fan off","vt":"str","case":false},{"t":"regex","v":"(set|turn) (the )?fan ((on|to) )?low","vt":"str","case":false},{"t":"regex","v":"turn on (the )?fan","vt":"str","case":false},{"t":"regex","v":"turn (the )?fan on","vt":"str","case":false},{"t":"regex","v":"(set|turn) (the )?fan ((on|to) )?medium","vt":"str","case":false},{"t":"regex","v":"(set|turn) (the )?fan ((on|to) )?high","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":7,"x":240,"y":700,"wires":[["a5e841f2.f27e3"],["a5e841f2.f27e3"],["ccb08023.484cf"],["1c9d257.9d0bedb"],["1c9d257.9d0bedb"],["1c9d257.9d0bedb"],["71a0931e.3c22dc"]],"outputLabels":["Turn off","Turn off","Set low","Turn on","Turn on","Set medium","Set high"]},{"id":"a26a3b25.554268","type":"change","z":"35964044.fcf53","name":"Strip Wake Word","rules":[{"t":"change","p":"payload.description.summary","pt":"msg","from":"^(alexa )?","fromt":"re","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":460,"wires":[["b85b7c8f.607a2"]]},{"id":"5a07462b.4472c","type":"switch","z":"35964044.fcf53","name":"Route on Echo","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"Basement","vt":"str"},{"t":"eq","v":"Bathroom","vt":"str"},{"t":"eq","v":"Cai","vt":"str"},{"t":"eq","v":"Dining Room","vt":"str"},{"t":"eq","v":"Family Room","vt":"str"},{"t":"eq","v":"GR Charcoal","vt":"str"},{"t":"eq","v":"GR Gray","vt":"str"},{"t":"eq","v":"Garage","vt":"str"},{"t":"eq","v":"Guestroom","vt":"str"},{"t":"eq","v":"Immi","vt":"str"},{"t":"eq","v":"Kitchen","vt":"str"},{"t":"eq","v":"Living Room","vt":"str"},{"t":"eq","v":"Loft","vt":"str"},{"t":"eq","v":"Master Bedroom","vt":"str"},{"t":"eq","v":"Office","vt":"str"},{"t":"eq","v":"Storage Room","vt":"str"}],"checkall":"false","repair":false,"outputs":16,"x":820,"y":700,"wires":[["543e5a18.1f3c7c"],["93c46a5.7c6d698"],["db111ac0.9fbb98"],["543e5a18.1f3c7c"],["543e5a18.1f3c7c"],["543e5a18.1f3c7c"],["543e5a18.1f3c7c"],["543e5a18.1f3c7c"],["15edaef8.5de451"],["cd349e29.dc0088"],["543e5a18.1f3c7c"],["543e5a18.1f3c7c"],["f0e77184.cf113"],["6c0dbee5.0fb8f8"],["3e1e5997.8e223e"],["543e5a18.1f3c7c"]]},{"id":"21d6328e.003396","type":"api-call-service","z":"35964044.fcf53","name":"Bathroom Fan","server":"3ddda582.b891ea","version":1,"debugenabled":false,"service_domain":"switch","service":"{{ my_service }}","entityId":"switch.master_bath_fan_switch","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1220,"y":460,"wires":[[]]},{"id":"db111ac0.9fbb98","type":"api-call-service","z":"35964044.fcf53","name":"Cais Fan","server":"3ddda582.b891ea","version":1,"debugenabled":false,"service_domain":"fan","service":"{{ my_service }}","entityId":"fan.v_cai_fan","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1040,"y":520,"wires":[[]]},{"id":"6c0dbee5.0fb8f8","type":"api-call-service","z":"35964044.fcf53","name":"Master Bedroom Fan","server":"3ddda582.b891ea","version":1,"debugenabled":false,"service_domain":"fan","service":"{{ my_service }}","entityId":"fan.v_master_fan","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1080,"y":820,"wires":[[]]},{"id":"f0e77184.cf113","type":"api-call-service","z":"35964044.fcf53","name":"Loft Fan","server":"3ddda582.b891ea","version":1,"debugenabled":false,"service_domain":"fan","service":"{{ my_service }}","entityId":"fan.v_loft_fan","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1040,"y":760,"wires":[[]]},{"id":"cd349e29.dc0088","type":"api-call-service","z":"35964044.fcf53","name":"Immis Fan","server":"3ddda582.b891ea","version":1,"debugenabled":true,"service_domain":"fan","service":"{{ my_service }}","entityId":"fan.v_immi_fan","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1050,"y":640,"wires":[[]]},{"id":"15edaef8.5de451","type":"api-call-service","z":"35964044.fcf53","name":"Guest Room Fan","server":"3ddda582.b891ea","version":1,"debugenabled":false,"service_domain":"fan","service":"{{ my_service }}","entityId":"fan.v_guest_room_fan","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1070,"y":580,"wires":[[]]},{"id":"3e1e5997.8e223e","type":"api-call-service","z":"35964044.fcf53","name":"Office Fan","server":"3ddda582.b891ea","version":1,"debugenabled":false,"service_domain":"fan","service":"{{ my_service }}","entityId":"fan.v_office_fan","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1050,"y":880,"wires":[[]]},{"id":"b85b7c8f.607a2","type":"change","z":"35964044.fcf53","name":"Clear Data","rules":[{"t":"delete","p":"payload.data","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":460,"wires":[["64f34a83.dfdb14"]]},{"id":"a35c1f26.931b78","type":"switch","z":"35964044.fcf53","name":"Check for Domain is HA","property":"payload.data.domain","propertyType":"msg","rules":[{"t":"eq","v":"HomeAutomation","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":460,"wires":[["a26a3b25.554268"],[]]},{"id":"a5e841f2.f27e3","type":"change","z":"35964044.fcf53","name":"Set Service Off","rules":[{"t":"set","p":"my_service","pt":"msg","to":"turn_off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":640,"wires":[["5a07462b.4472c"]]},{"id":"ccb08023.484cf","type":"change","z":"35964044.fcf53","name":"Set Service Low","rules":[{"t":"set","p":"my_service","pt":"msg","to":"set_percentage","tot":"str"},{"t":"set","p":"payload.data","pt":"msg","to":"{\"percentage\":\"33\"}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":680,"wires":[["5a07462b.4472c"]]},{"id":"1c9d257.9d0bedb","type":"change","z":"35964044.fcf53","name":"Set Service Medium","rules":[{"t":"set","p":"my_service","pt":"msg","to":"set_percentage","tot":"str"},{"t":"set","p":"payload.data","pt":"msg","to":"{\"percentage\":\"66\"}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":720,"wires":[["5a07462b.4472c"]]},{"id":"71a0931e.3c22dc","type":"change","z":"35964044.fcf53","name":"Set Service High","rules":[{"t":"set","p":"my_service","pt":"msg","to":"set_percentage","tot":"str"},{"t":"set","p":"payload.data","pt":"msg","to":"{\"percentage\":\"100\"}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":760,"wires":[["5a07462b.4472c"]]},{"id":"93c46a5.7c6d698","type":"change","z":"35964044.fcf53","name":"Fix Service","rules":[{"t":"change","p":"my_service","pt":"msg","from":"set_speed","fromt":"str","to":"turn_on","tot":"str"},{"t":"delete","p":"payload.data","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":460,"wires":[["21d6328e.003396"]]},{"id":"64f34a83.dfdb14","type":"link out","z":"35964044.fcf53","name":"","links":["cc31fdeb.12866","aae19fb5.03a968","752ea04e.199d","8a0ffdcc.f54ff"],"x":895,"y":460,"wires":[]},{"id":"cc31fdeb.12866","type":"link in","z":"35964044.fcf53","name":"","links":["64f34a83.dfdb14"],"x":95,"y":700,"wires":[["545ebb02.da3e74"]]},{"id":"9e64cd95.94afd8","type":"switch","z":"35964044.fcf53","name":"Contextual Route TV","property":"payload.description.summary","propertyType":"msg","rules":[{"t":"regex","v":"turn off (the )?tv","vt":"str","case":false},{"t":"regex","v":"turn (the )?tv off","vt":"str","case":false},{"t":"regex","v":"turn on (the )?tv","vt":"str","case":false},{"t":"regex","v":"turn (the )?tv on","vt":"str","case":false},{"t":"regex","v":"turn on (the )?shield","vt":"str","case":false},{"t":"regex","v":"turn (the )?shield on","vt":"str","case":false},{"t":"regex","v":"turn on (the )?tivo","vt":"str","case":false},{"t":"regex","v":"turn (the )?tivo on","vt":"str","case":false},{"t":"regex","v":"turn on (the )?games","vt":"str","case":false},{"t":"regex","v":"turn (the )?games on","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":10,"x":240,"y":980,"wires":[["f0064aef.d42ea8"],["f0064aef.d42ea8"],["50771b1a.865df4"],["50771b1a.865df4"],["50771b1a.865df4"],["50771b1a.865df4"],["53f2024b.1785b4"],["53f2024b.1785b4"],["7213a01d.4b8a"],["7213a01d.4b8a"]],"outputLabels":["Turn off","Turn off","Turn on","Turn on","","","","","",""]},{"id":"aae19fb5.03a968","type":"link in","z":"35964044.fcf53","name":"","links":["64f34a83.dfdb14"],"x":95,"y":980,"wires":[["9e64cd95.94afd8"]]},{"id":"c932d4e.8cf19a8","type":"switch","z":"35964044.fcf53","name":"Route on Echo","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"Basement","vt":"str"},{"t":"eq","v":"Bathroom","vt":"str"},{"t":"eq","v":"Cai","vt":"str"},{"t":"eq","v":"Dining Room","vt":"str"},{"t":"eq","v":"Family Room","vt":"str"},{"t":"eq","v":"GR Charcoal","vt":"str"},{"t":"eq","v":"GR Gray","vt":"str"},{"t":"eq","v":"Garage","vt":"str"},{"t":"eq","v":"Guestroom","vt":"str"},{"t":"eq","v":"Immi","vt":"str"},{"t":"eq","v":"Kitchen","vt":"str"},{"t":"eq","v":"Living Room","vt":"str"},{"t":"eq","v":"Loft","vt":"str"},{"t":"eq","v":"Master Bedroom","vt":"str"},{"t":"eq","v":"Office","vt":"str"},{"t":"eq","v":"Storage Room","vt":"str"}],"checkall":"false","repair":false,"outputs":16,"x":720,"y":1000,"wires":[["8ee233f8.3f8ba"],["8ee233f8.3f8ba"],["8ee233f8.3f8ba"],["1e5ddcfb.b25833"],["1e5ddcfb.b25833"],["8ee233f8.3f8ba"],["8ee233f8.3f8ba"],["8ee233f8.3f8ba"],[],["8ee233f8.3f8ba"],["1e5ddcfb.b25833"],["1e5ddcfb.b25833"],["8ee233f8.3f8ba"],["9e17091e.f6885"],["9c4dad67.291ca"],["8ee233f8.3f8ba"]]},{"id":"1e5ddcfb.b25833","type":"api-call-service","z":"35964044.fcf53","name":"Family Room TV","server":"3ddda582.b891ea","version":1,"debugenabled":true,"service_domain":"remote","service":"{{ my_service }}","entityId":"remote.family_room_hub","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":960,"y":940,"wires":[[]]},{"id":"f0064aef.d42ea8","type":"change","z":"35964044.fcf53","name":"Set Service Off","rules":[{"t":"set","p":"my_service","pt":"msg","to":"turn_off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":920,"wires":[["c932d4e.8cf19a8"]]},{"id":"9e17091e.f6885","type":"api-call-service","z":"35964044.fcf53","name":"Master Bedroom TV","server":"3ddda582.b891ea","version":1,"debugenabled":true,"service_domain":"remote","service":"{{ my_service }}","entityId":"remote.master_bedroom_hub","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":980,"y":1060,"wires":[[]]},{"id":"9c4dad67.291ca","type":"api-call-service","z":"35964044.fcf53","name":"Office TV","server":"3ddda582.b891ea","version":1,"debugenabled":false,"service_domain":"remote","service":"{{ my_service }}","entityId":"remote.office_hub","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":940,"y":1120,"wires":[[]]},{"id":"50771b1a.865df4","type":"change","z":"35964044.fcf53","name":"Set Service Shield","rules":[{"t":"set","p":"my_service","pt":"msg","to":"turn_on","tot":"str"},{"t":"set","p":"payload.data","pt":"msg","to":"{\"activity\":\"Shield\"}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":960,"wires":[["c932d4e.8cf19a8"]]},{"id":"53f2024b.1785b4","type":"change","z":"35964044.fcf53","name":"Set Service Tivo","rules":[{"t":"set","p":"my_service","pt":"msg","to":"turn_on","tot":"str"},{"t":"set","p":"payload.data","pt":"msg","to":"{\"activity\":\"Live TV - TiVo\"}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":1000,"wires":[["c932d4e.8cf19a8"]]},{"id":"7213a01d.4b8a","type":"change","z":"35964044.fcf53","name":"Set Service Games","rules":[{"t":"set","p":"my_service","pt":"msg","to":"turn_on","tot":"str"},{"t":"set","p":"payload.data","pt":"msg","to":"{\"activity\":\"Games\"}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":1040,"wires":[["c932d4e.8cf19a8"]]},{"id":"8ee233f8.3f8ba","type":"alexa-remote-routine","z":"35964044.fcf53","name":"No TV Here","account":"bdd909b1.9333d8","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"str","value":"You know there is no TV in this room"},"devices":{"type":"msg","value":"payload.name"}}},"x":950,"y":1000,"wires":[[]]},{"id":"543e5a18.1f3c7c","type":"alexa-remote-routine","z":"35964044.fcf53","name":"No Fan Here","account":"bdd909b1.9333d8","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"str","value":"You know perfectly well that there is no fan in this room"},"devices":{"type":"msg","value":"payload.name"}}},"x":1050,"y":700,"wires":[[]]},{"id":"8a0ffdcc.f54ff","type":"link in","z":"35964044.fcf53","name":"","links":["64f34a83.dfdb14"],"x":95,"y":1320,"wires":[["1ee69e09.660c6a"]]},{"id":"544b1da8.3708c4","type":"switch","z":"35964044.fcf53","name":"Route on Echo","property":"payload.name","propertyType":"msg","rules":[{"t":"eq","v":"Basement","vt":"str"},{"t":"eq","v":"Bathroom","vt":"str"},{"t":"eq","v":"Cai","vt":"str"},{"t":"eq","v":"Dining Room","vt":"str"},{"t":"eq","v":"Family Room","vt":"str"},{"t":"eq","v":"GR Charcoal","vt":"str"},{"t":"eq","v":"GR Gray","vt":"str"},{"t":"eq","v":"Garage","vt":"str"},{"t":"eq","v":"Guestroom","vt":"str"},{"t":"eq","v":"Immi","vt":"str"},{"t":"eq","v":"Kitchen","vt":"str"},{"t":"eq","v":"Living Room","vt":"str"},{"t":"eq","v":"Loft","vt":"str"},{"t":"eq","v":"Master Bedroom","vt":"str"},{"t":"eq","v":"Office","vt":"str"},{"t":"eq","v":"Storage Room","vt":"str"}],"checkall":"false","repair":false,"outputs":16,"x":720,"y":1320,"wires":[["ba1670d5.0887d8"],["ba1670d5.0887d8"],["33ad898c.47a7e6"],["ba1670d5.0887d8"],["ba1670d5.0887d8"],["ef14fb09.3303b"],["ef14fb09.3303b"],["ba1670d5.0887d8"],["ba1670d5.0887d8"],["ba1670d5.0887d8"],["ba1670d5.0887d8"],["ba1670d5.0887d8"],["ba1670d5.0887d8"],["ba1670d5.0887d8"],["ba1670d5.0887d8"],["ba1670d5.0887d8"]]},{"id":"ef14fb09.3303b","type":"api-call-service","z":"35964044.fcf53","name":"Game Room Blinds","server":"3ddda582.b891ea","version":1,"debugenabled":true,"service_domain":"cover","service":"{{ my_service }}","entityId":"cover.game_room_blind","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":950,"y":1320,"wires":[[]]},{"id":"ba1670d5.0887d8","type":"alexa-remote-routine","z":"35964044.fcf53","name":"No Blinds Here","account":"bdd909b1.9333d8","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"str","value":"You know there are no blinds in this room"},"devices":{"type":"msg","value":"payload.name"}}},"x":940,"y":1380,"wires":[[]]},{"id":"1ee69e09.660c6a","type":"switch","z":"35964044.fcf53","name":"Contextual Route Blinds","property":"payload.description.summary","propertyType":"msg","rules":[{"t":"regex","v":"open (the )?blind(s)?","vt":"str","case":false},{"t":"regex","v":"close (the )?blind(s)?","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":2,"x":250,"y":1320,"wires":[["33a52ec9.d6846a"],["63fb65aa.39d62c"]],"outputLabels":["Open","Close"]},{"id":"33a52ec9.d6846a","type":"change","z":"35964044.fcf53","name":"Set Service Open","rules":[{"t":"set","p":"my_service","pt":"msg","to":"open_cover","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":1300,"wires":[["544b1da8.3708c4"]]},{"id":"63fb65aa.39d62c","type":"change","z":"35964044.fcf53","name":"Set Service Close","rules":[{"t":"set","p":"my_service","pt":"msg","to":"close_cover","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":1340,"wires":[["544b1da8.3708c4"]]},{"id":"33ad898c.47a7e6","type":"api-call-service","z":"35964044.fcf53","name":"Cais Blinds","server":"3ddda582.b891ea","version":1,"debugenabled":true,"service_domain":"cover","service":"{{ my_service }}","entityId":"cover.cais_blinds","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":930,"y":1260,"wires":[[]]},{"id":"bdd909b1.9333d8","type":"alexa-remote-account","name":"Alexa Account","authMethod":"proxy","proxyOwnIp":"192.168.0.5","proxyPort":"3456","cookieFile":"/data/alexa-auth-file","refreshInterval":"3","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"on"},{"id":"3ddda582.b891ea","type":"server","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]