How to Trigger Alexa Routines with Anything From SmartThings

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

2 thoughts on “How to Trigger Alexa Routines with Anything From SmartThings

Leave a Reply

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