Alexa monitoring state of switch

Can alexa run a routine based on the state of a switch? So if swtch=on the alexa does something.... Or is it more like google in that sense in that you can expose the device to google but google doesn't trip anything based on the status?

It will be looking for the on event, but if you want to do something if it stays on it won't helpl you.

I can see the switch in the alexa app and alexa can control the switch but when I create a routine the switch doesn't show

Use Case. Created virtual switch (simple on/off) When Ecolink Firefighter goes off (regardless of smoke or c0) the virtual switch is turned to on, which then would turn on my stove hood (home connect directly connected to alexa) Ugh I hate getting the cloud involved...

Try creating the virtual switch as a switch that is also a contact sensor.

metadata {
	definition (name: "Virtual contact with Switch", namespace: "cw", author: "cwwilson08") {
		capability "Sensor"
		capability "Contact Sensor"
        capability "Switch"

def on() {
    sendEvent(name: "contact", value: "closed")
    sendEvent(name: "switch", value: "on")

def off() {
    sendEvent(name: "contact", value: "open")
    sendEvent(name: "switch", value: "off")

def installed() {

I'll give it a whirl and let you know...

The device works perfectly... Unfortunately when it starts the home connect app to engage the hood it asks for instructions. So I think the home connect skill would have to be re written but damned if that little bit of code you just threw out won't let me do a bunch of other stuff... :stuck_out_tongue: I think that I'm stuck for ifttt to engage the hood for now :frowning:

You may be able to do it with a Custom Command in an Alexa Routine, assuming what you want to do can be done with a single voice command. It is a relatively new feature to type out a voice command and have Alexa do that silently as if someone said it. It can be very powerful and may come in handy in this case.

1 Like

Where is that done at?

  1. New routine
  2. Add action
  3. Custom (at the top, it also might be at the bottom depending on your Alexa app version)
  4. Type your voice command

But obviously before you do all of this you need the exact phrasing for what you want it to do. Testing is possible but it can be annoying so having it correct the first time is always best.

1 Like

I will check it out and report back! Thanks!

Thank you! That works perfectly!!!! Any way to get it to not respond OK? The help from this community is amazing. Between you and @thebearmay I'm all set... It's kludgy for sure, but works... Perhaps one day someone will do a Home Connect integration... (the api is available)

Maybe try turning on "Brief Mode"

  1. Bottom right "More"
  2. Under Alexa Preferences, "Voice Responses"
  3. Enable Brief Mode
  4. Other options are good too, so you may want to enable those as well.
1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.