[Release] Virtual Alexa Switch/Button

Thank you for those explanations.

That sounds like a good case for the switch instead of the button. Remember that the whole point of the button is that it’s like a doorbell, it turns itself off again immediately. So if you use a momentary button at 11 PM at night, it will be off again by 11:01 PM. So it wouldn’t affect your morning routine that runs at, say, 7 AM.

If you want to turn on the virtual device at 11 PM and have that virtual device still be on at 7 AM, then it needs to be a switch not a button. :sunglasses:

1 Like

Just remember that you need to do something to turn the switch off again. It might be consciously by voice, it might be in automation based on something else happening. But at some point you have to turn it off so it will be available to turn on again the next time. exactly what you will do will depend on the details of the use case.

For example, you could turn that switch off at 7:15 every morning and then it would be ready to use again that night. It’s up to you. :sunglasses:

In the Classic app I was able to turn on the Alexa switch when the STHM was triggered. I recently moved to the new app and can’t select it (Set response -> Turn on lights). I could create a standard simulated switch and use Smart Lighting to mirror the 2 switches, but that just adds another layer of complexity.

Just for clarity…

The Classic app had SHM.

The new v3 app has STHM.

Similar purposes, but different code and somewhat different features.

Do your Alexa virtual switches work but sometimes they don’t. I have one that’s in a Alexa routine for my Lockly lock so when the lock is unlocked the status is then acknowledged and my STHM is disarmed automatically. It works but sometimes the switch doesn’t see the lock and unlock. Thoughts?

That’s been going on for months since they released the new skill. :disappointed_relieved: It’s mostly fixed, but not completely, so it is still happening sometimes for some people. Discussion in the following thread:

New SmartThings Alexa skill (2020)

I figured it was that. Hopefully they fix this skill soon.

1 Like

All of my Simulated Alexa Switch just stoped working. Anybody else with problem?

I just saw a report on a huge amazon AWS outage. My switch half works. Hopefully they’ll be back up soon.

1 Like

Alexa is having problems along with AWS


I am having a recent problem with my Simulated Alexa Switches.
I am using ST app automations to turn of the switch after one or two hours. They have been working for a long time but now one doesn’t work. The automation does not turn off the switch after the elapsed time. (Alexa actions do work)

I noticed that the tile for some of my switches show “closed” and others show “off”

The Sleep One switch automation works and when you click the device tile,
it shows “Contact sensor - CLOSED”

Sleep Two automation fails and it does NOT show “Contact sensor” - only the word “Off”

Here is what the ST automations look like…

Not sure why the difference or how to resolve the problem.

Any help would be appreciated!!

It seems that the automation is the problem. When I shorten the time to 10 seconds, it works.
I set up a new switch and it doesn’t show as “Contact” either…

Is this code still working to create a virtual switch?

Here is the code I am attempting to use to create a new SmartApp from code on api.smartthings.com.

When I click “Create”, I get an error and cannot continue. Here is the error I am getting:
No signature of method: script_app_metadata_3b4f3cfe_ab7c_4b19_9cc2_b96287671c1e.metadata() is applicable for argument types: (script_app_metadata_3b4f3cfe_ab7c_4b19_9cc2_b96287671c1e$_run_closure1) values: [script_app_metadata_3b4f3cfe_ab7c_4b19_9cc2_b96287671c1e$_run_closure1@57ef41e5] Possible solutions: getMetadata(), getState(), setState(java.lang.Object), metaClass(groovy.lang.Closure)


That code is for a DTH, device type handler, which you would paste into the “my device handler” section of the IDE.

By chance did you paste it in as a smartapp? That would generate that error.

If you are unfamiliar with custom code, the following FAQ will explain the terms and concepts. (The topic title is clickable link.)

Thanks for the fast reply! That did it, thank you! I didn’t understand the device handler but now I do! I see I am defining this custom device type. I was then able to make a new device type “Simulated Alexa Switch” (which was at the bottom of the list of device types) and it all worked like a charm! I can now use my SmartThings button to turn off my Alexa smart plug through a virtual sensor switch and Alexa routine.

Woo hoo!

1 Like

I am having a similar problem with automations with hue lighr (not a simulated switch) I have a a couple automations that turn on my hues to a color and then turn off.
They all do not turn off.

It is a known issue with automations -


Thank you for this great idea and for so elegantly executing it. I got this to work perfectly and integrated into my HousePanel dashboard as shown here:

image image

This was much needed since I dumped WebCore after migrating to the New App.

Hi wonder if you can help.

I have been using this code in device handler to create a virtual sensor for Aexa

Unfortunately I get the following error.

Are you able to advise on how I fix this