Intelligent Echo Device Location change piston


I have created a capability to allow pistons that use “Echo Speaks” to speak to a dynamically selected Echo device. This is achieved with a Piston that I have written called “Location”. I am posting this piston verbatim because the non-randomized version is needed to see what is going on. Basically, I have created 1) A virtual switch for every Echo Device that I have named things like Location_Office, 2) I have a Virtual button called “Location” that calls the piston when it is pushed, 3) I have one Alexa Routine for each Echo device. Each of these routines presses the Location button to call the piston and then presses the virtual switch for that Location .eg Location_Office. The piston sets a GLOBAL Webcore variable named @Echo_Location. Then, any other Piston that I have written uses @Echo_Location for its “Speak” commands. Actual usage is like this: “Alexa, Location Office”, Alexa responds, "Location is now set to Echo Office Dot. Then all of my Echo speaks commands that use @Echo_Location speak to Echo Office Dot until I give another location command.

Here is an actual example of my use of my “Location” piston example above.


I’m thinking there’s gotta be a way to use existing Alexa capabilities to determine presence. If you say “Alexa, what time is it” the nearest one responds 99% of the time. So it knows, based on proximate audio levels, what room has the loudest activity… and is therefore likely the occupied room.

The question is: how do we leverage that to set a variable, and thereby ‘speak’ to that echo device?


How could you do that if you are issuing the speak command from Alexa and you haven’t said anything to Alexa? Isn’t the whole point of ES that you don’t have to speak to Alexa to get your notifications?


I love how a SmartHome concept can be used in sooo many different ways…

Your piston reminds me of my “Body Temperature” setup… I tell Alexa 1 of 5 phrases:

  • Alexa, I’m hot
  • Alexa, I’m warm
  • Alexa, I’m just right
  • Alexa, I’m cool
  • Alexa, I’m cold

…and she flips a SimSwitch, webCoRE takes over, does a bunch of stuff, and then sets a global variable to a number 1-5. … Many of my pistons will act differently depending on what my @bodyTemp is currently set at.

It is cool to see our logic and concepts used in such different ways… :+1:

Thanks for sharing!!


Perhaps I need to communicate this more clearly.

Folks are trying to have Alexa know which room you are in, so that when Echo Speaks you do not need to script it to speak to particular Echo devices OR to every Echo in the house. vmsman has developed a tool to accomplish that, and done a good job of it.

But personally, I would find it cumbersome to say “Alexa, location west bedroom” and then when I go to work in the office five minutes later have to remember to tell it “Alexa, location office”. And then if I take a bathroom break, “Alexa location bathroom” etc.

So then. What if Alexa itself could do that ‘location’ for us?

The fact is that it already does. It’s always listening. And if you have more than one, and you say “Alexa what time is it”, the Echo device closest to you will be the one that responds.

How does this happen?

Answer is that Alexa knows which Echo device is closest to you when you speak.
And it ALWAYS knows that, because it’s always listening! And it has to make the decision as to which Echo device will respond to you, and it does so based on audio proximity.

Therefore: it would not be a large conceptual leap to find a way to leverage that proximity capability even when you are not asking it anything.

The big issue, as I mentioned earlier, would be privacy. Because then it would not only always be listening for its wake word, but also listening in enough general detail to always be calculating proximity.

So if it knew just based on noise proximity, for example, that the office and the kitchen were the occupied rooms and EchoSpeaks were about to tell you that it’s time to put out the garbage, it could direct that statement to those two Echo devices.

I hope that clarifies the idea.


@Glen_King, what you are saying is what we have always hoped for. Just to clarify more for the others… now that we have Echo_Speaks that we can call within Webcore we have the ability to create notifications. Push Notifications involve having Alexa speak based upon an event and not based upon our initiating conversation (Yes, I know about routines triggered on sensors). The key point is that we have no way to link into EVERYTHING that Alexa says and then just be able to parse input. Also, as Glen points out, it is cumbersome to tell Alexa where we want our next piston output to go. Right now most folks do not have a sufficient concentration of sensors to tell where (near which Echo) someone is when they utter a command. My true dream is a motion sensor that can cover a room and provide a spatial scanning and shape recognition to know not only that the room is occupied, but that Scott is in the room. Let’s face it, occupancy sensors require that you carry something with you (or have the proverbial evil electronic implant). Echo Speaks by itself was typically hard-coded to one Echo device. Until a really good technology or infinitely cool “trick” comes out, my “LOCATION” piston is not a bad hack and a hack is what it is.


@WCmore, we are both in strong agreement here. Webcore pistons provide a highly granular level of control over all SmartThings devices and attributes. To tell Alexa “I’m hot” and have her adjust the thermostat is great. One step further is to have Alexa respond that she has adjusted the thermostat to 2 degrees cooler and now the thermostat is set to 72F and that the inside temperature is currently 76F. You might even follow up by having Alexa announce when the house has reached 72F as a reminder. My LOCATION piston gives you a way to decide where that output ought to go. However, as @Glen_King mentioned, we need a much better and more automated method to judge occupancy. We all would prefer that follow-up message where Alexa would tell us it is 72F now, to follow us to the Echo device that we are nearest when the event occurs. Some people argue that the only way to achieve this is to have an Alexa enabled Robot, such as the new Sony device follow us room to room as a true assistant. I think that is creepy and I prefer that my smart speakers are subtlely placed in each room. I have nine echo enabled devices in my home and I can walk around anywhere issuing commands seamlessly.


Nope, doesn’t clear up anything for me. If you haven’t spoken to Alexa (or spoken at all) how will she know where you are? How will she know if thrre is more than 1 person home? What you are saying makes zero sense at all.


Ryan: vmsman gets what I’m saying, so obviously it makes some sense.

That said, the questions you ask have some validity. In reply, let me ask a few:

  1. Does your front door make noise when you enter your home? Or is it completely silent?
  2. Do you ever play music, or watch tv? Do you do those silently?
  3. When you are in your kitchen, are you completely silent as you go about the process of preparing meals?

All I’m saying is that a mic that is “always on” registers differences in ambient level if there is activity near it. Talking to other people, talking on the phone, banging pots and pans, watching tv, all generate ambient noise.

That ambient noise can perhaps be used to determine whether, by comparison to other ‘quiet’ times, people are likely in the room.


My SmartHome has been doing this for over a year, but I did not want to clutter your thread with details of my piston. I just wanted to acknowledge your contribution.

In reference to microphones being always on:

I think a good direction to take would be to use Beacons with “Bluetooth Low Energy” to determine what room you are in. It could be piped back to webCoRE and a global variable. The rest follows the same logic as above, but does not require your voice to change rooms.


I’m not a fan of this sort of thing. You have to carry your phone or some other tracker around all the time. Might as well go with plain old motion sensors. I acknowledge upfront that you would not then be able to get personalized content… is it inevitable that, in order to truly leverage this technology, we all end up getting ‘chipped’? lol


Many people keep their phone in the same room as them, so it’s not too far a stretch. Plus you can always fall back on the original post by saying, “Alexa, Location Office” to update the global variable.

*shivers* at the thought


I do not carry my phone at all if I can help it lol
And I now use Alexa as my phone with my landline. So whatever room I’m in I can say “Alexa call dad” and I can speak to him on his home phone via Alexa. Or “Alexa call wife cell” and it will reach her on her cellphone.


I understand. I am the same way…

If you did not want to use your voice to update the global, you could always use a simple button (or sensor) hidden in certain rooms that sent the request to webCoRE to adjust the global variable. (for example, when your La-Z-Boy chair reclines, set global to living room) Also, some room shifts could be automated if you live a predictable lifestyle. (IE: every day at 11pm change global to bedroom)

Personally, I think a combination of the methods above would be best. (voice, button, motion, contact sensor, time, Bluetooth Low Energy, etc) Any/all of them can reset the global variable, which means you would not be forced to use your voice very often.


Only if you have a feed from all the mics all the time, which you don’t with Alexa or Google Assistant. The mic might be on all the time but it doesn’t upload everything you say to the cloud and process it. That would take unimaginable computing power. That’s why there’s a “wake-word” that you have to say to wake the speaker up. Yes, if you had the ability to had the echo so that you could have a live feed 24/7 of the mic and then you developed a system to interpret the noises picked up by that speaker to be something real and not a clock or a furnace or a/c kicking on or any number of 100 other things that might make noise in your home, then yes that would work. But I would think that if you’re going to have pie in the sky dreams, why not use something more realistic like microwave sensors. Something that actually works that doesn’t require motion or a miracle to detect people.

Also, I would like to point out that this thread is under the heading of Example Pistons. What you are talking about, which was 100% not clear, is a “fun thing to have” idea. Nowhere near anything that works or you could possibly set up today. You should have been clearer if that’s the perspective you were coming at.


I will look into adding a follow-me feature into the future v2.2 release.


Future 2.2 release of what? And what exactly are you going to add? The ability to use the mic on your Echo to determine if a room is occupied? How exactly are you going to incorporate that into anything when it’s not a “thing” yet?


Given that Echo/Alexa indeed does not (yet?) provide programmers the ability to utilize audio level to determine presence, for now other means are required. As I would prefer this to be automated, I’ve been thinking on this a bit.

How do we determine presence in a Room?
If we have enough HA devices and know the people around us, perhaps we can use the status of those devices.

Here’s an example. If my wife is in the bedroom after dinner, a particular dimming outlet is almost always ON. Additionally, the tv in that room is almost always on. And if it’s after 10pm and those devices have been turned off, it means she’s asleep… but still in that room.

Likewise, if there’s motion in the kitchen/dining room area around 6:30-7pm odds are she’s there. And in two months when the kitchen has been redone and smart switches and outlets and Hue lights are there, I could use their on/off status to say she is likely there. Or I could simply acknowledge that she cooks 70% of the suppers, and so she’s likely to be there during that time span.

And so any EchoSpeaks messages that are for her should be directed to those areas under those conditions.

Here’s another: in our home office we have a new PC. I’d love to find a way to set it up such that whichever of us is logged on to that machine and using it at that moment, ST could recognize it and register myself or her as present in that room. Likewise I keep my business suits in the closet in that office and get dressed for work there, so any Speaks messages designed for me should play there between 6:30-7a in the morning on weekdays.


Interesting discussion. The focus of interest is in any given home do you want automated devices or automation. I’ve found some things make sense to automate. For example, if I have either garage door open, the Echo device in the family room announces every five minutes which door has been left open and for how long. Generally, I don’t want the garage left open unattended. Also, I have a tilt sensor on each garage door and when the doors are successfully closed I receive a spoken confirmation in the family room. I voice command my garage doors and I want to know they have closed. Another example is my wife and I tend to go in and out of the kitchen in the evenings for a few minutes here and there always carrying something and so it is not convenient to turn on a light and nor do we require full lighting that would be needed to cook. So, we have a Phillips Hue strip light on top of the cabinets we call “Kitchen mood”. The kitchen has an EZMultiPLI that detects motion when someone enters the kitchen after sunset and before sunrise and turns the “Kitchen Mood” on and leaves it on until the room is unoccupied for 5 minutes and then turns it off. Another example is the EZMultiPLI also has an LED light. There is a piston that causes that LED to turn RED when the Smart Home Monitor is in the armed mode and GREEN when the Smart Home Monitor is in the disarmed mode. That same piston also controls a color Hue light bulb in the ceiling of the garage similarly. A final example is in our bedroom there is a Sonos Sound bar connected to our bedroom TV, two Sonos Play 1 speakers acting as surrounds and a Sonos Play SUB. This system is used for both TV sound and music. After the TV has been watched, the volume level is typically much higher if you happen to switch over to music. This is a basic level mismatch between the two sources and Sonos and/or Vizio have no easy fix. So, there is an automation that adjusts the Sonos volume down after the TV has been played. You can see from these examples that these automations make sense. I’ve never felt like automation makes sense for things like the internet controlled crock pot or the ceiling fan that comes on when the room temperature reaches a certain level. The reason is that I revel in the fact that I have added smart switches to control almost all lights in the house, music and video selection. Having played with things like turning certain lights on when I turn the TV on or turning the ceiling fan on at a certain temperature have not been useful personally. I really love controlling those devices via voice, but having them happen automatically is a stretch to say they make things better. Another example of useful automation is I have both my washer and dryer plugged into smart wall plugs that are of the energy monitoring type. My washer and dryer are very basic models with no smarts at all. The washer and dryer are in a closed utility room and I can’t hear when they finish. I have a piston that announces in the living area when the washer has completed and when the dryer has completely which works simply by monitoring when they stop drawing watts. I have very few lights not automated in the house. The light in the laundry room is not automated because whenever I go in there the switch is in a very handy position even if I am carrying a basket of clothes. The light in the hallway is not automated because I rarely use it and also because I do not automate my lights in closets. My thought is that unoccupied areas don’t add a lot of automation value for me personally. I have three motion detectors in the house and I use them almost entirely for Smart Home Monitor. Even if I had a reliable and personally identifiable means of determining room occupancy, I am not sure that granularity would add a lot of value to my level of automation. I would be very interested in hearing more input on what @Glen_King and I have discussed.


Ok, one item taken care of. I’m using EventGhost on my PC to determine whether someone is logged on. It can’t determine WHO is logged on, but it can determine whether someone is logged on or whether it has timed out or user sessions have locked.

And from there, I can generally determine presence in my office.

I have it doing a python command string to a Webcore endpoint.

EDIT: turns out you CAN access who is logged on. It’s called a payload. I just have to script it.