Approaches to room aware voice commands for Alexa with Node-Red

I updated the NR nodes with the ones here:

It solved the problem for me.

2 Likes

Yesterday, I replaced node-red-contrib-alexa-remote2-cakebaked with node-red-contrib-alexa-remote2-applestrudel. It works but, like with all previous versions of alexa-remote2, its reliability is the question and it may take a week or more to answer that.

Anyway, so far so good; this morning’s announcement played on schedule and room-awareness is functional.

1 Like

Looks like the apple strudel version doesn’t work now. :frowning:

Anyone found an alternative way to get around this problem?

1 Like

I can confirm that it is no longer able to connect to Amazon Alexa’s services.

The author of apple strudel believes the API may have changed.

I am experiencing the same issue with Apple Strudel. I ensured I had the latest version but receiving device activity is no longer operational.

I found a workaround to the problem using the last_alexa sensor. I’ve implemented it in my setup and it seems to be working well. I’ll summarize the approach here, and can provide more detail if anyone is interested.

  1. Set up the sensor. last_alexa entity as described here Home · custom-components/alexa_media_player Wiki · GitHub (search for Setting Up a Last Alexa Sensor)
  2. Next, set up an automation to update the last_alexa entity. A good way is described here: Using Alexa Media Player “last called” service - #13 by Didgeridrew. I also did a Node Red subflow that I will attach in a response to this topic and you can find below.
  3. Set up three helper entities. As an example, I’ll use ones for turning on the TV. The helper entities should look like:
    input_button.room_aware_tv_on
    input_button.room_aware_tv_off
    input_button.room_aware_tv_dummy
  4. Expose these entities to Alexa using Nabu Casa, the smarthome skill, or whatever way you normally do it. It is important that the “DUMMY” entity be given the Alexa friendly name of “TV”. The friendly names for the other two don’t matter, but don’t name them TV or anything similar in order not to confuse Alexa. Make sure you tell Alexa to discover new devices.
  5. Create two Alexa routines. The first one will trigger when it hears “Alexa, turn on the TV” and should have as an action to TURN ON input_button.room_aware_tv_on. The second one should listen for “Alexa, turn off the TV” and should have as an action to TURN ON (not a typo) input_button.room_aware_tv_off. You don’t have to do anything with the “DUMMY” entity, it is simply there so that Alexa doesn’t say it can’t find the device.
  6. Go back to Home Assistant, and create an automation (or Node Red flow), that listens for the input_button.room_aware_tv_on to be pressed. When it sees that it was pressed, it should first trigger the automation you created in 2) above in order to update the sensor.last_alexa entity, and then based on the value of this entity, issue the turn_on command to the appropriate TV in the room corresponding to the last Alexa used. Do the same thing for the input_button.room_aware_tv_off entity.

And that’s it. Every time you say Alexa, turn the TV on (or off), it will press the appropriate button entity, update last_alexa to make sure it knows where the command came from, and take the appropriate action.

Hope this helps.

1 Like

Please use instead the corrected code a couple of comments down in sdholden28’s post. It fixes a quotes problem in my copy/paste:

[{“id”:“8116afd9f6a8b5a2”,“type”:“subflow”,“name”:“Last Alexa Update”,“info”:"",“category”:"",“in”:[{“x”:60,“y”:80,“wires”:[{“id”:“d04bccee3a13c251”}]}],“out”:[{“x”:990,“y”:80,“wires”:[{“id”:“f64e0ac29a8ea48b”,“port”:0}]}],“env”:[],“meta”:{},“color”:"#DDAA99",“inputLabels”:[“Trigger”],“outputLabels”:[“Last Alexa Device”],“status”:{“x”:920,“y”:140,“wires”:[{“id”:“f64e0ac29a8ea48b”,“port”:0}]}},{“id”:“f64e0ac29a8ea48b”,“type”:“api-current-state”,“z”:“8116afd9f6a8b5a2”,“name”:“Last”,“server”:“38c68cbe.2f0d04”,“version”:3,“outputs”:1,“halt_if”:"",“halt_if_type”:“str”,“halt_if_compare”:“is”,“entity_id”:“sensor.last_alexa”,“state_type”:“str”,“blockInputOverrides”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:"",“valueType”:“entityState”},{“property”:“data”,“propertyType”:“msg”,“value”:"",“valueType”:“entity”}],“for”:“0”,“forType”:“num”,“forUnits”:“minutes”,“override_topic”:false,“state_location”:“payload”,“override_payload”:“msg”,“entity_location”:“data”,“override_data”:“msg”,“x”:790,“y”:80,“wires”:[[]]},{“id”:“d04bccee3a13c251”,“type”:“api-call-service”,“z”:“8116afd9f6a8b5a2”,“name”:“Update”,“server”:“38c68cbe.2f0d04”,“version”:5,“debugenabled”:false,“domain”:“alexa_media”,“service”:“update_last_called”,“areaId”:[],“deviceId”:[],“entityId”:[],“data”:"",“dataType”:“jsonata”,“mergeContext”:"",“mustacheAltTags”:false,“outputProperties”:[],“queue”:“none”,“x”:200,“y”:80,“wires”:[[“b62733f0cd2b5907”]]},{“id”:“b62733f0cd2b5907”,“type”:“delay”,“z”:“8116afd9f6a8b5a2”,“name”:"",“pauseType”:“delay”,“timeout”:“500”,“timeoutUnits”:“milliseconds”,“rate”:“1”,“nbRateUnits”:“1”,“rateUnits”:“second”,“randomFirst”:“1”,“randomLast”:“5”,“randomUnits”:“seconds”,“drop”:false,“allowrate”:false,“outputs”:1,“x”:350,“y”:80,“wires”:[[“b95a3fa218952ff4”]]},{“id”:“b95a3fa218952ff4”,“type”:“api-call-service”,“z”:“8116afd9f6a8b5a2”,“name”:“Update”,“server”:“38c68cbe.2f0d04”,“version”:5,“debugenabled”:false,“domain”:“homeassistant”,“service”:“update_entity”,“areaId”:[],“deviceId”:[],“entityId”:[“sensor.last_alexa”],“data”:"",“dataType”:“jsonata”,“mergeContext”:"",“mustacheAltTags”:false,“outputProperties”:[],“queue”:“none”,“x”:500,“y”:80,“wires”:[[“e6cdb2622ecbcf55”]]},{“id”:“e6cdb2622ecbcf55”,“type”:“delay”,“z”:“8116afd9f6a8b5a2”,“name”:"",“pauseType”:“delay”,“timeout”:“500”,“timeoutUnits”:“milliseconds”,“rate”:“1”,“nbRateUnits”:“1”,“rateUnits”:“second”,“randomFirst”:“1”,“randomLast”:“5”,“randomUnits”:“seconds”,“drop”:false,“allowrate”:false,“outputs”:1,“x”:650,“y”:80,“wires”:[[“f64e0ac29a8ea48b”]]},{“id”:“38c68cbe.2f0d04”,“type”:“server”,“name”:“Home Assistant”,“version”:5,“addon”:true,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:false,“cacheJson”:true,“heartbeat”:false,“heartbeatInterval”:“30”,“areaSelector”:“friendlyName”,“deviceSelector”:“friendlyName”,“entitySelector”:“friendlyName”,“statusSeparator”:“at: “,“statusYear”:“hidden”,“statusMonth”:“short”,“statusDay”:“numeric”,“statusHourCycle”:“h23”,“statusTimeFormat”:“h:m”,“enableGlobalContextStore”:true},{“id”:“776d982283c2ed89”,“type”:“subflow:8116afd9f6a8b5a2”,“z”:“e9714a8c.da0318”,“name”:””,“x”:1190,“y”:1600,“wires”:[[“f03293ea83414171”]]}]

1 Like

There is an easy fix to one file on the Node Red Community Forum. It worked for me.

According to a post in Node red community linked above, the pallet and offending node have been fixed officially.

not anymore, unfortunately. The same problem has reared its ugly head, I.e. no information being passed with device activity

The quotation marks got messed up here when you copied/pasted. I fixed them via find/replace and was able to import the flow and it works well. Thank you. Fixed flow is copied below and should work straight away if anyone wishes to use it.

[{"id":"8116afd9f6a8b5a2","type":"subflow","name":"Last Alexa Update","info":"","category":"","in":[{"x":60,"y":80,"wires":[{"id":"d04bccee3a13c251"}]}],"out":[{"x":990,"y":80,"wires":[{"id":"f64e0ac29a8ea48b","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","inputLabels":["Trigger"],"outputLabels":["Last Alexa Device"],"status":{"x":920,"y":140,"wires":[{"id":"f64e0ac29a8ea48b","port":0}]}},{"id":"f64e0ac29a8ea48b","type":"api-current-state","z":"8116afd9f6a8b5a2","name":"Last","server":"38c68cbe.2f0d04","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.last_alexa","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":790,"y":80,"wires":[[]]},{"id":"d04bccee3a13c251","type":"api-call-service","z":"8116afd9f6a8b5a2","name":"Update","server":"38c68cbe.2f0d04","version":5,"debugenabled":false,"domain":"alexa_media","service":"update_last_called","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":200,"y":80,"wires":[["b62733f0cd2b5907"]]},{"id":"b62733f0cd2b5907","type":"delay","z":"8116afd9f6a8b5a2","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":350,"y":80,"wires":[["b95a3fa218952ff4"]]},{"id":"b95a3fa218952ff4","type":"api-call-service","z":"8116afd9f6a8b5a2","name":"Update","server":"38c68cbe.2f0d04","version":5,"debugenabled":false,"domain":"homeassistant","service":"update_entity","areaId":[],"deviceId":[],"entityId":["sensor.last_alexa"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":500,"y":80,"wires":[["e6cdb2622ecbcf55"]]},{"id":"e6cdb2622ecbcf55","type":"delay","z":"8116afd9f6a8b5a2","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":650,"y":80,"wires":[["f64e0ac29a8ea48b"]]},{"id":"38c68cbe.2f0d04","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"057610b1c46d0bb6","type":"tab","label":"Update Last Alexa","disabled":false,"info":"","env":[]},{"id":"776d982283c2ed89","type":"subflow:8116afd9f6a8b5a2","z":"057610b1c46d0bb6","name":"","x":170,"y":80,"wires":[[]]}]
1 Like

Sorry about that. Thank you for fixing it

How does it trigger the polling/updating of the “sensor.last_alexa” entity? I can manually trigger your subflow, and it works, but nothing seems to fire it without my intervention. Am I missing something?

Thanks!

If you’re using node_red, then use an event: state node that is looking for a change in state of the input_buttons that get pressed when use Alexa. For example, when you say “Alexa, turn on the tv” , it triggers a routine that presses the input_button.room_aware_tv_on button that you created. The node red flow detects that, and use that as a trigger.

Here’s a picture of the front end of my flow:

and here’s is what the “Room Aware” events:state node looks like:

and here is what the “button?” switch node looks like:

and here is what the “which Alexa?” switch node looks like:

Thanks for that! I’m making headway, but it seems very flakey. :frowning:

I notice on the HA version there is a

  - service: notify.alexa_media_last_called
    data:
      message: | 
        Lorem ipsum dolor sit amet.
      data:
        type: tts

but that’s not present in the NR flow. Is it necessary, or just an announcement?

I have multiple accounts, so used the Examples: Sensors · custom-components/alexa_media_player Wiki · GitHub legacy sensor, the 2nd template sensor, but it just doesn’t work; not even sometimes like the current one.

I went a different route. I used the individual emulated light, as the trigger for each flow, so there’s no need for routines or input helpers, and you can pass percentages, eg. set lights to 30%

[{"id":"8116afd9f6a8b5a2","type":"subflow","name":"Last Alexa Update","info":"","category":"","in":[{"x":60,"y":80,"wires":[{"id":"d04bccee3a13c251"}]}],"out":[{"x":990,"y":80,"wires":[{"id":"f64e0ac29a8ea48b","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","inputLabels":["Trigger"],"outputLabels":["Last Alexa Device"],"status":{"x":920,"y":140,"wires":[{"id":"f64e0ac29a8ea48b","port":0}]}},{"id":"f64e0ac29a8ea48b","type":"api-current-state","z":"8116afd9f6a8b5a2","name":"Last","server":"","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.last_alexa","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":790,"y":80,"wires":[[]]},{"id":"d04bccee3a13c251","type":"api-call-service","z":"8116afd9f6a8b5a2","name":"Update","server":"","version":5,"debugenabled":true,"domain":"alexa_media","service":"update_last_called","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":200,"y":80,"wires":[["b62733f0cd2b5907"]]},{"id":"b62733f0cd2b5907","type":"delay","z":"8116afd9f6a8b5a2","name":"","pauseType":"delay","timeout":"750","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":350,"y":80,"wires":[["b95a3fa218952ff4"]]},{"id":"b95a3fa218952ff4","type":"api-call-service","z":"8116afd9f6a8b5a2","name":"Update","server":"","version":5,"debugenabled":false,"domain":"homeassistant","service":"update_entity","areaId":[],"deviceId":[],"entityId":["sensor.last_alexa"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":500,"y":80,"wires":[["e6cdb2622ecbcf55"]]},{"id":"e6cdb2622ecbcf55","type":"delay","z":"8116afd9f6a8b5a2","name":"","pauseType":"delay","timeout":"750","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":650,"y":80,"wires":[["f64e0ac29a8ea48b"]]},{"id":"158e21b50cb73330","type":"subflow:8116afd9f6a8b5a2","z":"682714e314f61424","name":"","x":370,"y":1340,"wires":[["640c4af2d2df7f93","58fa7e510778bc43"]]},{"id":"640c4af2d2df7f93","type":"switch","z":"682714e314f61424","name":"Back Deck","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"media_player.microwave","vt":"str"},{"t":"eq","v":"media_player.back_deck","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":730,"y":1240,"wires":[["b00f7e360b965a2f"],["b00f7e360b965a2f"]]},{"id":"c68ace7de4f0d92d","type":"trigger","z":"682714e314f61424","name":"On","op1":"","op2":"on","op1type":"nul","op2type":"str","duration":"1","extend":false,"units":"ms","reset":"","bytopic":"all","outputs":1,"x":1030,"y":1320,"wires":[["424027315a35fe63"]]},{"id":"424027315a35fe63","type":"mqtt out","z":"682714e314f61424","name":"","topic":"Upstairs/BackDeck/Everything","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"","x":1250,"y":1260,"wires":[]},{"id":"b00f7e360b965a2f","type":"switch","z":"682714e314f61424","name":"Off / On","property":"on","propertyType":"msg","rules":[{"t":"cont","v":"false","vt":"str"},{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":880,"y":1240,"wires":[["2ea64c4e4a59294a"],["c68ace7de4f0d92d"]]},{"id":"2ea64c4e4a59294a","type":"trigger","z":"682714e314f61424","name":"off","op1":"","op2":"off","op1type":"nul","op2type":"str","duration":"1","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1030,"y":1200,"wires":[["424027315a35fe63"]]},{"id":"58fa7e510778bc43","type":"switch","z":"682714e314f61424","name":"Office","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"media_player.intronics","vt":"str"},{"t":"eq","v":"media_player.workshop","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":710,"y":1460,"wires":[["1e0487d832814396"],["1e0487d832814396"]]},{"id":"95d272f468ff2f5e","type":"trigger","z":"682714e314f61424","name":"On","op1":"","op2":"on","op1type":"nul","op2type":"str","duration":"1","extend":false,"units":"ms","reset":"","bytopic":"all","outputs":1,"x":1030,"y":1540,"wires":[["e8e721199b6e7791"]]},{"id":"e8e721199b6e7791","type":"mqtt out","z":"682714e314f61424","name":"","topic":"Office/Everything","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"","x":1210,"y":1480,"wires":[]},{"id":"1e0487d832814396","type":"switch","z":"682714e314f61424","name":"Off / On","property":"on","propertyType":"msg","rules":[{"t":"cont","v":"false","vt":"str"},{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":880,"y":1460,"wires":[["3add2691f43945c6"],["95d272f468ff2f5e"]]},{"id":"3add2691f43945c6","type":"trigger","z":"682714e314f61424","name":"off","op1":"","op2":"off","op1type":"nul","op2type":"str","duration":"1","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1030,"y":1420,"wires":[["e8e721199b6e7791"]]},{"id":"be05cbe31e8ad604","type":"amazon-echo-device","z":"682714e314f61424","name":"Everything","topic":"","x":150,"y":1340,"wires":[["158e21b50cb73330"]]}]


[{"id":"8116afd9f6a8b5a2","type":"subflow","name":"Last Alexa Update","info":"","category":"","in":[{"x":60,"y":80,"wires":[{"id":"d04bccee3a13c251"}]}],"out":[{"x":990,"y":80,"wires":[{"id":"f64e0ac29a8ea48b","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","inputLabels":["Trigger"],"outputLabels":["Last Alexa Device"],"status":{"x":920,"y":140,"wires":[{"id":"f64e0ac29a8ea48b","port":0}]}},{"id":"f64e0ac29a8ea48b","type":"api-current-state","z":"8116afd9f6a8b5a2","name":"Last","server":"","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.last_alexa","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":790,"y":80,"wires":[[]]},{"id":"d04bccee3a13c251","type":"api-call-service","z":"8116afd9f6a8b5a2","name":"Update","server":"","version":5,"debugenabled":true,"domain":"alexa_media","service":"update_last_called","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":200,"y":80,"wires":[["b62733f0cd2b5907"]]},{"id":"b62733f0cd2b5907","type":"delay","z":"8116afd9f6a8b5a2","name":"","pauseType":"delay","timeout":"750","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":350,"y":80,"wires":[["b95a3fa218952ff4"]]},{"id":"b95a3fa218952ff4","type":"api-call-service","z":"8116afd9f6a8b5a2","name":"Update","server":"","version":5,"debugenabled":false,"domain":"homeassistant","service":"update_entity","areaId":[],"deviceId":[],"entityId":["sensor.last_alexa"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":500,"y":80,"wires":[["e6cdb2622ecbcf55"]]},{"id":"e6cdb2622ecbcf55","type":"delay","z":"8116afd9f6a8b5a2","name":"","pauseType":"delay","timeout":"750","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":650,"y":80,"wires":[["f64e0ac29a8ea48b"]]},{"id":"776d982283c2ed89","type":"subflow:8116afd9f6a8b5a2","z":"682714e314f61424","name":"","x":450,"y":420,"wires":[["448b0388342ff95c","568e09f093c723a0"]]},{"id":"448b0388342ff95c","type":"switch","z":"682714e314f61424","name":"Rumpus","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"media_player.rumpus_room","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":680,"y":160,"wires":[["84bbd0044bcbf7d2"]]},{"id":"6a56a7563c477441","type":"function","z":"682714e314f61424","name":"Brightness Object","func":"if (msg.payload === \"off\") msg.payload = {\n    \"service\": \"turn_off\"\n};\nelse if (msg.colormode === \"hs\")\n    msg.payload = {\n        \"service\": \"turn_on\",\n        data: {\n             \"brightness\": msg.bri\n        }\n    };\nelse\n    msg.payload = {\n        \"service\": \"turn_on\",\n        data: {\n             \"brightness\": msg.bri\n        }\n    };\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1230,"y":720,"wires":[["bc120872b22e0ac7"]]},{"id":"bc120872b22e0ac7","type":"api-call-service","z":"682714e314f61424","name":"","server":"","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.back_deck_lights"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1430,"y":720,"wires":[[]]},{"id":"568e09f093c723a0","type":"switch","z":"682714e314f61424","name":"Back Deck","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"media_player.microwave","vt":"str"},{"t":"eq","v":"media_player.back_deck","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":660,"wires":[["88097efb8e2f486f"],["88097efb8e2f486f"]]},{"id":"84bbd0044bcbf7d2","type":"switch","z":"682714e314f61424","name":"Off / On","property":"on","propertyType":"msg","rules":[{"t":"cont","v":"false","vt":"str"},{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1020,"y":160,"wires":[["41c4db797f51572c"],["7e8824b9282d1ca1"]]},{"id":"41c4db797f51572c","type":"api-call-service","z":"682714e314f61424","name":"","server":"","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.rumpus_lights_level_2"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1190,"y":100,"wires":[[]]},{"id":"7e8824b9282d1ca1","type":"function","z":"682714e314f61424","name":"Brightness Object","func":"if (msg.payload === \"off\") msg.payload = {\n    \"service\": \"turn_off\"\n};\nelse if (msg.colormode === \"hs\")\n    msg.payload = {\n        \"service\": \"turn_on\",\n        data: {\n             \"brightness\": msg.bri\n        }\n    };\nelse\n    msg.payload = {\n        \"service\": \"turn_on\",\n        data: {\n             \"brightness\": msg.bri\n        }\n    };\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1210,"y":200,"wires":[["f662d1d86a82c253"]]},{"id":"88097efb8e2f486f","type":"switch","z":"682714e314f61424","name":"Off / On","property":"on","propertyType":"msg","rules":[{"t":"cont","v":"false","vt":"str"},{"t":"cont","v":"true","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1040,"y":660,"wires":[["eaacf1173f4cfc27"],["6a56a7563c477441"]]},{"id":"eaacf1173f4cfc27","type":"api-call-service","z":"682714e314f61424","name":"","server":"","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.back_deck_lights"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":600,"wires":[[]]},{"id":"f662d1d86a82c253","type":"api-call-service","z":"682714e314f61424","name":"","server":"","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.rumpus_lights_level_2"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1410,"y":200,"wires":[[]]},{"id":"119f530e82f06900","type":"amazon-echo-device","z":"682714e314f61424","name":"Lights","topic":"","x":290,"y":420,"wires":[["776d982283c2ed89"]]}]




If there any disadvantage to this method that could be causing my flakiness when it comes to updating the last Alexa?

I believe it’s just an announcement to show that the last Alexa sensor was properly updated.

I’ve never been able to use that Amazon Echo Hub node - keep getting port 80 errors. But if it’s working for you, that’s great.

Ah, I see. As I mentioned Approaches to room aware voice commands for Alexa with Node-Red - #12 by quadhammer this Node-RED Smart Home Control is a really good alternative for emulating devices, if you want the convenience of everything in Node Red.

@javierdeluis thank you for this excellent writeup, and thanks @sdholden28 and @quadhammer for your contributions to the discussion as well!

Tired of waiting for a fix to Apple Strudel, I implemented this technique over the weekend for a bunch of stuff. For example, here’s a snippet of the lighting scenes I’m triggering contextually:

And here’s the internals of the “Room Router v2” subflow, which is based on the NR code you (and @sdholden28) kindly shared–thanks for that!

And it all worked flawlessly :slight_smile:

…until Tuesday afternoon :frowning:

Unfortunately, my “sensor.last_alexa” has been stuck on “unavailable” for roughly 36 hours, so context is once again broken in my house. I’ve tried restarting HA, rebooting my HA NUC, reloading the Alexa Media Player integration, but no luck. I even tried creating the alternate “legacy last called sensor” described in the link in your step 1, but still no luck (that sensor also invariably reports as “unavailable”).

Any recommendations for getting the sensor to update? Is anyone else experiencing this?

1 Like