Send announcements to only certain Alexa devices based on presence/motion

I have this working flawlessly in Smartthings using Webcore with the help of some amazing people in the ST community and I’d like to figure out how to do the same thing in HA since some of my new contact and PIR sensors are RF and only work in HA. It would also be useful for some Tasmota devices (also only work in HA) for laundry notifications.

Basically when an event such as a window or door opens/closes it triggers a TTS announcement to any Alexa device in a room that is occupied based on motion or other criteria (TV or particular light is on) in that room but the speakers in unoccupied rooms remain quiet.

I have the Alexa media player configured and ready to go but I am not that comfortable with node red yet, so if this is even possible, I wouldn’t know where to even start to get this to work since it’s nothing like what I’m already familiar with using Webcore in ST.

Anyone have an example node red layout, if you have this working, that I can go off of to get started with this?

With appdaemon it would probably not be so difficult to implement. I have a case where notifications are buffered and only played when a motion detector which is mapped to a speaker detects motion and it works well.

1 Like

First time I’ve heard of appdeamon. Just installed it, will mess with it later. Is it an alternative to node red?

Not directly an alternative as it has no gui. it would be good if you have basic programming skills.

Unfortunately I’m not much of a programmer outside of basic Webcore pistons within Smartthings.

Have you considered using something like in the examples for the the Alexa media player plugin? https://github.com/keatontaylor/alexa_media_player/wiki/Automation-examples

I use both the Washing Machine and the “Person Home” examples and they work consistently for me. They are pretty straight forward copy and paste. Here are 3 examples that I use.

- id: notify_washing_machine_finished
  alias: Send Notification - Washing machine finshed
  initial_state: 'on'
  trigger:
    - platform: mqtt
      topic: home/laundry/esp-washer/state
      payload: Finished
  action:
    - service: notify.alexa_media
      data:
        target:
          - media_player.main_show
        data:
          type: announce
        message: 'Hey everyone, the laundry appears to be done.'
- id: alert_person1_is_home
  alias: "Alert - Angelo is arriving"
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: device_tracker.axon7
    to: Home
  action:
    - service: notify.alexa_media
      data:
        target:
          - media_player.main_show
        data:
          type: announce
        message: 'Hear ye, hear ye, the one, the only, the man who needs no introduction, the man with the plan, Angelo, yes I said Angelo, is now arriving.'

- id: alert_person1_is_almost_home
  alias: "Alert - Angelo is almost home"
  initial_state: 'on'
  trigger:
    platform: numeric_state
    entity_id: sensor.angelo_current_location_to_home
    below: 15
  condition:
    - condition: state
      entity_id: 'device_tracker.axon7'
      state: 'away'
  action:
    - service: notify.alexa_media
      data:
        target:
          - media_player.main_show
        data:
          type: announce
        message: 'Hey everyone, Angelo is less than 15 minutes away.'
1 Like

Thanks for the reply.

I know it’s possible to send announcements to Alexa devices, but my question was if it’s possible to send the announcement to only the Alexa devices in rooms that are occupied based on motion.

In your example it looks like you’re only sending announcements to one device. Sorry I know I did a bad job explaining this in the original post :slightly_frowning_face:

Here ya go have fun. You’ll need to change all of the entities and servers of course but this has worked flawless for a long time now.
there is a lot there that you may not need but the part that will do what you want is where the Bluetooth tracker triggers home and the living room alexa announces welcome home after waiting 1 minute for the door to open. There should be plenty in this flow that you can use.

[{"id":"ce4e67e6.c38ac8","type":"within-time-switch","z":"4a44e1d9.4941d","name":"Shuts Down Flow 10pm to 8am","positionConfig":"cf4bfd8.c0a73","startTime":"22:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"08:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltMultiplier":60,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltMultiplier":60,"tsCompare":"0","lastMsgOnStartOut":false,"lastMsgOnEndOut":false,"x":310,"y":160,"wires":[[],["669601b4.1c976"]]},{"id":"d48cb0d6.5108e","type":"api-call-service","z":"4a44e1d9.4941d","name":"Living Room Lights","server":"8883c5ea.5f6948","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.living_room\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1310,"y":240,"wires":[[]]},{"id":"e4fbcc83.69ddf","type":"api-call-service","z":"4a44e1d9.4941d","name":"Kitchen Lights","server":"8883c5ea.5f6948","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.kitchen\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1300,"y":300,"wires":[[]]},{"id":"39b06e14.546412","type":"comment","z":"4a44e1d9.4941d","name":"\"Home\"","info":"","x":1310,"y":120,"wires":[]},{"id":"1babe98e.a49f76","type":"HWS command","z":"4a44e1d9.4941d","name":"Living Room TV","server":"48a4b838.e51c28","activity":"56739111","command":"device:56739111:PowerOn","hold":"","repeat":"2","delay":"500","x":1300,"y":360,"wires":[[]]},{"id":"a4fc210e.2a731","type":"api-call-service","z":"4a44e1d9.4941d","name":"You Tube","server":"8883c5ea.5f6948","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"switch.youtube\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1400,"y":420,"wires":[[]]},{"id":"669601b4.1c976","type":"switch","z":"4a44e1d9.4941d","name":"Mike or Shelby?","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"device_tracker.mikebt","vt":"str"},{"t":"eq","v":"device_tracker.mikeihere","vt":"str"},{"t":"cont","v":"device_tracker.shelbybt","vt":"str"},{"t":"cont","v":"device_tracker.shelbytile","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":200,"y":460,"wires":[["4054cf7a.50cb5"],["4054cf7a.50cb5"],["c1c81130.f9fe3"],["c1c81130.f9fe3"]]},{"id":"ddfb843f.458fc8","type":"delay","z":"4a44e1d9.4941d","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1280,"y":420,"wires":[["a4fc210e.2a731"]]},{"id":"d607f8da.fe39a8","type":"api-call-service","z":"4a44e1d9.4941d","name":"Bedroom Lights","server":"8883c5ea.5f6948","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"switch.master_bedroom\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1320,"y":760,"wires":[[]]},{"id":"652668de.4efd78","type":"ha-wait-until","z":"4a44e1d9.4941d","name":"Wait Until Door Opens","server":"8883c5ea.5f6948","outputs":2,"entityId":"binary_sensor.frontdoor_open_close","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"1","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":false,"blockInputOverrides":true,"x":780,"y":500,"wires":[["9c8fdd0f.23f79"],[]]},{"id":"4054cf7a.50cb5","type":"switch","z":"4a44e1d9.4941d","name":"Where is Mike ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"},{"t":"eq","v":"not_home","vt":"str"},{"t":"eq","v":"Repair","vt":"str"},{"t":"eq","v":"Acc Shop","vt":"str"},{"t":"eq","v":"Parking Lot","vt":"str"},{"t":"eq","v":"Front Yard","vt":"str"},{"t":"eq","v":"Back Yard","vt":"str"},{"t":"eq","v":"Behind Shops","vt":"str"},{"t":"eq","v":"Impound Yard","vt":"str"},{"t":"eq","v":"West Parking","vt":"str"},{"t":"eq","v":"Trash Pile","vt":"str"}],"checkall":"true","repair":false,"outputs":11,"x":460,"y":380,"wires":[["18d77f78.c18d91","c433a1e9.29f39","e72f4d74.837dd"],[],[],[],[],[],[],[],[],[],[]]},{"id":"ecca9dc4.7efb2","type":"api-call-service","z":"4a44e1d9.4941d","name":"Living Room Lights","server":"8883c5ea.5f6948","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.living_room\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1330,"y":640,"wires":[[]]},{"id":"574d17f8.4ed958","type":"api-call-service","z":"4a44e1d9.4941d","name":"Kitchen Lights","server":"8883c5ea.5f6948","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.kitchen\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1320,"y":700,"wires":[[]]},{"id":"6709bdb9.b5caf4","type":"comment","z":"4a44e1d9.4941d","name":"\"Home\"","info":"","x":1310,"y":540,"wires":[]},{"id":"c433a1e9.29f39","type":"ha-wait-until","z":"4a44e1d9.4941d","name":"Wait untill Door Closes","server":"8883c5ea.5f6948","outputs":2,"entityId":"binary_sensor.frontdoor_open_close","property":"state","comparator":"is_not","value":"off","valueType":"str","timeout":"1","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":false,"blockInputOverrides":true,"x":780,"y":300,"wires":[["beee44c4.56fa08"],[]]},{"id":"18d77f78.c18d91","type":"ha-wait-until","z":"4a44e1d9.4941d","name":"Wait untill Door Opens","server":"8883c5ea.5f6948","outputs":2,"entityId":"binary_sensor.frontdoor_open_close","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"1","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":false,"blockInputOverrides":true,"x":780,"y":240,"wires":[["beee44c4.56fa08"],[]]},{"id":"beee44c4.56fa08","type":"throttle","z":"4a44e1d9.4941d","name":"Allows 1 message in 1 min","throttleType":"time","timeLimit":"60","timeLimitType":"seconds","countLimit":"1","blockSize":0,"locked":false,"x":1040,"y":260,"wires":[["d48cb0d6.5108e","e4fbcc83.69ddf","1babe98e.a49f76","ddfb843f.458fc8","d9fc197e.2b5918","e8e617fb.60a848"]]},{"id":"e0b4c68d.3aa748","type":"server-state-changed","z":"4a44e1d9.4941d","name":"Mike","server":"8883c5ea.5f6948","version":1,"entityidfilter":"device_tracker.mikebt","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":70,"y":60,"wires":[["ce4e67e6.c38ac8"]]},{"id":"75f78b3.044c574","type":"server-state-changed","z":"4a44e1d9.4941d","name":"Shelby","server":"8883c5ea.5f6948","version":1,"entityidfilter":"device_tracker.shelbybt","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":70,"y":220,"wires":[["ce4e67e6.c38ac8"]]},{"id":"1cb0ebf7.999b84","type":"ha-wait-until","z":"4a44e1d9.4941d","name":"Wait untill Door Closes","server":"8883c5ea.5f6948","outputs":2,"entityId":"binary_sensor.frontdoor_open_close","property":"state","comparator":"is_not","value":"off","valueType":"str","timeout":"1","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":false,"blockInputOverrides":true,"x":780,"y":560,"wires":[["9c8fdd0f.23f79"],[]]},{"id":"9c8fdd0f.23f79","type":"throttle","z":"4a44e1d9.4941d","name":"Allows 1 message in 1 min","throttleType":"time","timeLimit":"60","timeLimitType":"seconds","countLimit":"1","blockSize":0,"locked":false,"x":1040,"y":540,"wires":[["ecca9dc4.7efb2","574d17f8.4ed958","d607f8da.fe39a8","7b7e69f6.9727d8","65cd634e.2e72cc"]]},{"id":"c1c81130.f9fe3","type":"switch","z":"4a44e1d9.4941d","name":"Where is Shelby ?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"home","vt":"str"},{"t":"eq","v":"not_home","vt":"str"},{"t":"eq","v":"Repair","vt":"str"},{"t":"eq","v":"Acc Shop","vt":"str"},{"t":"eq","v":"Parking Lot","vt":"str"},{"t":"eq","v":"Front Yard","vt":"str"},{"t":"eq","v":"Back Yard","vt":"str"},{"t":"eq","v":"Behind Shops","vt":"str"},{"t":"eq","v":"Impound Yard","vt":"str"},{"t":"eq","v":"West Parking","vt":"str"},{"t":"eq","v":"Trash Pile","vt":"str"}],"checkall":"true","repair":false,"outputs":11,"x":470,"y":580,"wires":[["652668de.4efd78","1cb0ebf7.999b84","7d47fae2.60fd54"],[],[],[],[],[],[],[],[],[],[]]},{"id":"e72f4d74.837dd","type":"api-call-service","z":"4a44e1d9.4941d","name":"Unlock Front Door","server":"8883c5ea.5f6948","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.front_door_lock\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":770,"y":180,"wires":[[]]},{"id":"b81a9352.d8851","type":"inject","z":"4a44e1d9.4941d","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":100,"wires":[[]]},{"id":"d9fc197e.2b5918","type":"api-call-service","z":"4a44e1d9.4941d","name":"Alexa Speak Welcome Home","server":"8883c5ea.5f6948","service_domain":"notify","service":"alexa_media","data":"{\"message\":\"Welcome Home\",\"title\":\"welcome home\",\"data\":{\"type\":\"tts\",\"method\":\"all\"},\"target\":[\"media_player.front_room\"]}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1340,"y":180,"wires":[[]]},{"id":"7b7e69f6.9727d8","type":"api-call-service","z":"4a44e1d9.4941d","name":"Alexa Speak Welcome Home","server":"8883c5ea.5f6948","service_domain":"notify","service":"alexa_media","data":"{\"message\":\"Welcome Home\",\"title\":\"welcome home\",\"data\":{\"type\":\"tts\",\"method\":\"all\"},\"target\":[\"media_player.front_room\"]}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1360,"y":580,"wires":[[]]},{"id":"f8675ce4.83f1d","type":"inject","z":"4a44e1d9.4941d","name":"","topic":"","payload":"home","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":60,"wires":[[]]},{"id":"7d47fae2.60fd54","type":"api-call-service","z":"4a44e1d9.4941d","name":"Unlock Front Door","server":"8883c5ea.5f6948","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.front_door_lock\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":770,"y":440,"wires":[[]]},{"id":"e8e617fb.60a848","type":"api-call-service","z":"4a44e1d9.4941d","name":"Ceiling Fan -- Medium","server":"8883c5ea.5f6948","service_domain":"fan","service":"set_speed","data":"{\"entity_id\":\"fan.living_room\",\"speed\":\"medium\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1320,"y":480,"wires":[[]]},{"id":"65cd634e.2e72cc","type":"api-call-service","z":"4a44e1d9.4941d","name":"Ceiling Fan -- Medium","server":"8883c5ea.5f6948","service_domain":"fan","service":"set_speed","data":"{\"entity_id\":\"fan.living_room\",\"speed\":\"medium\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1340,"y":820,"wires":[[]]},{"id":"ecaf6be6.34a538","type":"server-state-changed","z":"4a44e1d9.4941d","name":"Shelby Tile","server":"8883c5ea.5f6948","version":1,"entityidfilter":"device_tracker.shelbytile","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":60,"y":280,"wires":[["ce4e67e6.c38ac8"]]},{"id":"ce16a130.a7208","type":"server-state-changed","z":"4a44e1d9.4941d","name":"Mike iHere","server":"8883c5ea.5f6948","version":1,"entityidfilter":"device_tracker.mikeihere","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":60,"y":120,"wires":[["ce4e67e6.c38ac8"]]},{"id":"cf4bfd8.c0a73","type":"position-config","z":"","name":"Pauls Valley","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12"},{"id":"8883c5ea.5f6948","type":"server","z":"","name":"Home Assistant Main","legacy":false,"hassio":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true},{"id":"48a4b838.e51c28","type":"harmonyws-server","z":"","name":"Living Room Hub","ip":"192.168.1.4"}]

Heres another one you’ll probably like . it does local contextual controls .
Like in the alexa app when you say turn off the lights and the lights go off in the room that you say it in. except this is all local and does door locks , lights, or anything that you can control.

[{"id":"9026737c.f80b3","type":"alexa-local","z":"a2b15e8b.e2456","devicename":"Br lmp","inputtrigger":true,"x":150,"y":1560,"wires":[["927904e.473f7f8","160a3941.f25ff7"]]},{"id":"bfa9c757.3e9c78","type":"alexa-local","z":"a2b15e8b.e2456","devicename":"chr lmp","inputtrigger":true,"x":140,"y":1640,"wires":[["9dda15d7.c66768","160a3941.f25ff7"]]},{"id":"927904e.473f7f8","type":"api-current-state","z":"a2b15e8b.e2456","name":"Last Alexa is\" Bedroom \"","server":"c5c66771.d1eb38","version":1,"outputs":2,"halt_if":"media_player.master_bedroom","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.last_alexa","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":330,"y":1520,"wires":[["160a3941.f25ff7"],[]]},{"id":"160a3941.f25ff7","type":"switch","z":"a2b15e8b.e2456","name":"Echo, Dot Entity Id","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"media_player.master_bedroom","vt":"str","case":false},{"t":"regex","v":"media_player.front_room","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":2,"x":570,"y":1600,"wires":[["1b924ec1.a882b1"],["4526517b.0c798"]]},{"id":"6dfa40e6.41d2b","type":"api-call-service","z":"a2b15e8b.e2456","name":"Shelbys Chair Lamp-- \" Off \"","server":"c5c66771.d1eb38","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.shelbys_chair_lamp\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":960,"y":1640,"wires":[[]]},{"id":"1b924ec1.a882b1","type":"switch","z":"a2b15e8b.e2456","name":"on / off ","property":"bri","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"gte","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":770,"y":1560,"wires":[["cf99d123.f456c"],["37973388.0d3bdc"]]},{"id":"9dda15d7.c66768","type":"api-current-state","z":"a2b15e8b.e2456","name":"Last Alexa is\" Living Room\"","server":"c5c66771.d1eb38","version":1,"outputs":2,"halt_if":"media_player.front_room","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.last_alexa","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":340,"y":1680,"wires":[["160a3941.f25ff7"],[]]},{"id":"69ef35df.e46c5c","type":"api-call-service","z":"a2b15e8b.e2456","name":"Shelbys Chair Lamp-- \" On \"","server":"c5c66771.d1eb38","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.shelbys_chair_lamp\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":960,"y":1700,"wires":[[]]},{"id":"37973388.0d3bdc","type":"api-call-service","z":"a2b15e8b.e2456","name":"Shelbys Bedside Lamp-- \" On\"","server":"c5c66771.d1eb38","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.shelbys_bedside_lamp\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":970,"y":1580,"wires":[[]]},{"id":"cf99d123.f456c","type":"api-call-service","z":"a2b15e8b.e2456","name":"Shelbys Bedside Lamp-- \" Off \"","server":"c5c66771.d1eb38","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.shelbys_bedside_lamp\"}","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":970,"y":1520,"wires":[[]]},{"id":"4526517b.0c798","type":"switch","z":"a2b15e8b.e2456","name":"on / off ","property":"bri","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"gte","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":770,"y":1660,"wires":[["6dfa40e6.41d2b"],["69ef35df.e46c5c"]]},{"id":"218bbd57.4764c2","type":"comment","z":"a2b15e8b.e2456","name":"Control Lamps, Locks, Etc... Based on Last Alexa Spoken to LOCAL NO CLOUD","info":"Request is called from echo \"alexa turn off the lamp\"\nAlexa local node fires into the Last Alexa Call Service Node\nWhere the echo spoken to is determined and sent out to the\n\"echo entity id\"  switch node\nAlexa local node also fires into the \"echo entity id\"  switch node\nwith the msg.bri value (100 for on and 0 for off, no dimming yet)\nOnly the echo entity id spoken to passes the msg.bri value \nout to the on / off switch node where 0 for off or 100 for on  \nis sent to the lamp on or lamp off call service node respectivly.\n\nThis allows you to say Alexa turn off the lamp to the living room echo \nand only the lamp in the living room turn on. But say the same command \nfrom the bedroom and only the lamp in the bedroom will turn on.\nWorks similar to useing the context aware groups in the alexa app \nand saying turn on or off the lights, except no cloud processing so much \nfaster responce and can be applied to \nlocks, lights, lamps, doors anything really.\n\nEnjoy!\n\n","x":620,"y":1440,"wires":[]},{"id":"c5c66771.d1eb38","type":"server","z":"","name":"Posting Server","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

Ah my bad. That actually makes more sense and now that I think about it, I want to do the same thing lol. Just throwing out some ideas…

Create a sensor for each Alexa device using a value template that sets the sensor to on (or 1 vs 0) based on based on the state of a presence entity or light in a specific room being on (or even maybe the state of Alexa device…like those playing music) and then change the automations’ targets to a template based on the sensors that are marked as on.

I was thinking maybe a “group” could also be used for this…the presence sensor and the Alexa device in the same group…refer to the Alexa device in that group? I haven’t played with groups so not sure if that is possible.

I am sure I over simplified something (or missed the feasibility completely), but either way I am going to try these out.

I use a python_script I wrote for this:

“active_entity” can be anything that will have an “on” state. So this can be a motion sensor, or a presence sensor, or a binary_template sensor that includes several conditions.

2 Likes

This is exactly what I’m looking for! Thank you!!

Also, this might be a silly question but how do I implement this?

In configuration.yaml you need:

python_script

Then you make a directory called python_scripts and you drop the above code in there named whatever you want (I name mine notify_alexa.py).

Then, when you want to send a notification your automation looks like this:

- alias: my automation
  trigger:
    whatever
  action:
    - service: python_script.notify_alexa
      data:
        message: "The thing you want Alexa to say"
1 Like

Amazing! Love this community :pray:

Can you have more than one active entity and, if so, can you separate them with just a comma or does it need to be on a new line?

This was quick and dirty for my needs, so, as written, it only supports one active entity.

The idea is that, for more complicated needs, you’ll make a binary_sensor.template that handles all those needs and use that as the active entity. This follows the common Home Assistant vibe of making a bunch of small pieces that work together instead of a big piece that does all the things in a specific way.

So… to set this up… say you only want your living room announcements to happen if the living room is occupied AND daniel is home…

Then you do this…

notify_alexa.py

devices = [
    {
        "device_entity": "media_player.living_echo",
        "active_entity": "binary_sensor.living_notifications",
    }
]

configuration.yaml

binary_sensor:
  - platform: template
    sensors:
      living_notifications:
        value_template: >-
          {{ is_state('binary_sensor.living_occupied','on') and is_state('device_tracker.daniel', 'home') }}
1 Like

Thanks to your help my very first Python script was a success :raised_hands:

Everything is working just as expected. Very cool!

Thanks once again :grinning: :partying_face:

1 Like