Sleeping/Awake status (switch, not presence)

I am looking to create and use 2 virtual switches for mode setting and routines based on myself and my wife’s current state: sleeping vs. awake

We use mobile presence as well, but this will add an extra layer of control in automations.
I used a generic switch DTH and modified it to use a 6x4 tile.

What I can’t figure out is why in the tile it adds a link to “a device” in this case itself (replicating device name). I’d like to get rid of this. How can I accomplish this?
Also, if I attempto to modify settings, or just open settings and “done” out of them, I get an error…

Can anyone help? I’d like to understand how to do this, and what I did wrong. BTW, if not obvious, I’m a complete Noob when it comes to code.


  • 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:
  • 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.
  • On/Off Button Tile
  • Author: cozdabuch
  • Date: 2013-05-01
    metadata {
    definition (name: “Sleeping/Awake Status”, namespace: “smartthings”, author: “SmartThings”) {
    capability “Actuator”
    capability “Switch”
    capability “Sensor”

// simulator metadata
simulator {

// UI tile definitions
tiles (scale: 2){
standardTile(name:“switch”, type: “generic”, width: 6, height: 4, canChangeIcon: true) {
state “off”, label: ‘AWAKE’, action: “switch.on”, icon: “st.Health & Wellness.health12”, backgroundColor: “#d6d6d6”, nextState: “on”
state “on”, label: ‘SLEEPING’, action: “”, icon: “st.Bedroom.bedroom2”, backgroundColor: “#aa797c”, nextState: “off”
main “switch”
details “switch”

def parse(String description) {

def on() {
sendEvent(name: “switch”, value: “on”)

def off() {
sendEvent(name: “switch”, value: “off”)


To solve the tileName bug, I changed the line:

standardTile(name:“switch”, type: “generic”, width: 6, height: 4, canChangeIcon: true) {


standardTile(“switch”, “device.switch”, decoration: “flat”, width: 6, height: 4, canChangeIcon: true) {

I’m not really sure what was causing that or how to really explain it. However, sometimes you have to mess around with different code to get things right.

I think what you did was use some MultiAttributeTitle code to create a StandardTile. MultiAttribute Tiles allow you to represent 2 (or more) capabilities in the same tile. Such as how Power outlets can both toggle the power and show current usage. For this code, you just want to show and control the on/off. As for the first bug f how it is displayed, I’m not sure, It’s working on my Android. Hopefully, this helped out.

Do you got this custom sleep/awake DTH running? Love to replicate it in my setup, but the code above only renders errors. Do you have a Github?

In a manner of speaking. We added this capibilitiybto the webCoRE presence sensor. For this very purpose.

1 Like