How to Trigger Alexa Routines with Anything From SmartThings

YouTube
YouTube
Twitter
Visit Us
Follow Me
Instagram
LINKEDIN
Share
Follow by Email

One of the hardest things to do right now is to trigger Amazon Alexa routines with any device or any condition from Samsung SmartThings. Right now, what you can do is attach Contact and Motion Sensors to Alexa and use those to trigger Alexa Routines, but what if you want to trigger with something like a Leak Sensor? What about temperature? Humidity? Lighting levels? What about a certain time of day, plus the presence of someone in your home?

These are the kinds of requests I get each and every day on Automate Your Life and as such, I went out and found a solution. Now, full credit to BJ Pierron who wrote this Device Handler code for a specialized device type that will allow you to do this.

You can use code for SmartThings to make your own Simulated Alexa Switch. The simulated Alexa Switch code for SmartThings is provided by ‘bjpierron’: https://raw.githubusercontent.com/bjpierron/SmartThings-Alexa/master/devicetypes/bjpierron/simulated-alexa-switch.src/simulated-alexa-switch.groovy

Automate Your Life is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com and other Amazon websites.

Simulated Alexa Switch by BJ Pierron

/**
 *  Copyright 2015 SmartThings
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
metadata {

    definition (name: "Simulated Alexa Switch", namespace: "bjpierron", author: "bjpierron") {
        capability "Switch"
        capability "Sensor"
        capability "Actuator"
        capability "Contact Sensor"	    		
    }
    
    simulator {
		status "open": "contact:open"
		status "closed": "contact:closed"
	}

    tiles {
        standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
            state "off", label: '${currentValue}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
            state "on", label: '${currentValue}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#00A0DC"
        }
        main "switch"
        details(["switch"])
    }
}

def parse(description) {
}

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

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

Now, to implement all of this! Watch our video below that will help you integrate Alexa and SmartThings in this new and exciting way.

https://youtu.be/BqJ3cHHcNyc

YouTube
YouTube
Twitter
Visit Us
Follow Me
Instagram
LINKEDIN
Share
Follow by Email

One thought on “How to Trigger Alexa Routines with Anything From SmartThings

  1. Thanks for the useful video. Sending states between Alexa and Smart things was a problem that I recently tried solve myself.

    Its good to know that the solution that I came up with is the same as the experts recommendations.

    This is the version that I ended up creating.

    https://github.com/vinnyw/smartthings/blob/master/devicetypes/vinnyw/virtual-switch-alexa.src/virtual-switch-alexa.groovy

    I used this exercise to learn more about smartthings during quarantine. It works on Off/Open and On/Closed states to mimic the flow of power (I kept getting confused otherwise). It should display as a “switch” in both the new and the classic apps.

    I added a “reset” option to the settings, so that it can act like a poor mans momentary press button, and so I wouldn’t need the the additional step to clear the state once it had been activated.

Leave a Reply

Your email address will not be published. Required fields are marked *