Virtual model change not working

Wondering if someone can help me out or offer any insight. I’m trying to use an NFC sticker>SMS>IFTTT>Virtual switch on>mode change. This way when I go to bed at night I can simply place my phone on the NFC sticker and put my ST hub in “alarm” mode. I have it working to this point NFC sticker>SMS>IFTTT>Virtual switch on but for whatever reason I cannot get this switch to work with this smart app to change the mode. Any suggestions would be great.

I created a virtual on off switch with the following settings:

Sleep mode Device Sleep mode

Name Sleep mode
Label Sleep mode
Type Switch Capability
Device Network Id VirtualSleepMode
Hub Home
Last Activity At 3 Mar 2014 05:43:31
Date Created 3 Mar 2014 04:23:54
Last Updated 3 Mar 2014 05:28:41
Data No data found for device
Current States No states found
Events List Events

I then used the sample code to make this mode change when the switch was turned on. It is below:

preferences {
	section("Select Switch to monitor"){
		input "theSwitch", "capability.switch"

def installed() {
	log.debug "Installed with settings: ${settings}"

def updated(settings) {
	log.debug "Updated with settings: ${settings}"

def onHandler(evt) {
	log.debug "Received on from ${theSwitch}"
    if(location.mode != "Sleeping") {
    } else {
    	log.debug "Already Sleeping - ignoring"

def offHandler(evt) {
	log.debug "Received off from ${theSwitch}"

def initialize() {
	subscribe(theSwitch, "switch.On", onHandler)
    subscribe(theSwitch, "switch.Off", offHandler)
1 Like