3 or more state virtual "button"?


(Jarrett Campbell) #1

I have found myself using virtual buttons to monitor and report states for simple applications. For example, “has the mail been delivered today.” The buttons are triggered by rules in CoRE based on acceleration sensors, contact sensors, etc. I think this is a pretty common practice in this community.

I have a few applications where a two-state on/off virtual button is not good enough. I’m looking for a way to do 3-or-more state buttons easily. Here’s an example application.

Our dog eats twice a day, once in the morning, once at night. I’d like to monitor whether or not my daughter has fed the dog. If she hasn’t fed her by 8:30am, send a text. If she hasn’t fed her a second time by 8;30pm, send another text. This is easy enough to do with CoRE but I’d also like a visible state monitor that I can see to know what the state is. This is straightforward to implement with 2, two-state buttons, one for breakfast and one for dinner. But what I really want is a 3-state solution which can be set to “Hungry”, “Breakfast”, and “Dinner” before resetting to “Hungry” at midnight.

I’m curious if anyone has a device handler that implements this kind of multi-state switch as a virtual button or other solution I should consider.

Thanks in advance.

Multi-State Virtual Switch
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

The closest possibility that fits existing SmartThings Capability is setLevel (ie, Dimmer).

Other Capabilities with numeric Attributes could be considered (Temperature,…).

A Button Controller has become de facto a “multi button Thing”, but it still has no Commands.


Hmm, let me rethink this post lol.


A virtual button is still binary.

The virtual garage door has five display states: open, opening, closing, closed, and unknown, and you can set them with a smart app. You can also change the labels.

However, it can’t be toggled manually, so I don’t know if it meets your requirements.

Most people use a virtual thermostat, I think, or a virtual dimmer as @tgauchat mentioned, as they work in a similar way. You have to assign different ranges to equate to different values, but then you have something that you can change manually if you like.


I had to edit my post because I was going suggest that if the OP was using SmartTiles, he can load a static image that rotates based on hunger status but I realized that what I might be suggesting is not supported in the current SmartTiles version.

(Robin) #7

This question intrigued me… I can think of many uses for a simple indicator tile to convey multiple states!!

I decided to do a test based on your use case.

Using the garage door attribute reccomended by @JDRoberts I have produced a device handler that has 4 states:

  • Hungry
  • Not Hungry
  • Breakfast
  • Dinner

(The not hungry button is just off the screen, you need to scroll down to see it, so not shown in the image above)

I have built in custom commands to match the 4 states that can be seen as options in CoRE when setting up your actions.

One thing that cannot be avoided is that CoRE cannot see the descriptive states, so you have to use a workaround when defining the IF’s.

Rather than 'IF hungry" you have to enter “IF closed”

Translations as follows:

  • Hungry - closed
  • Not Hungry - open
  • Breakfast - opening
  • Dinner - closing

Here’s the code:

Hope this helps?? Let me know how you get on!!

Adding third state to switch
Device Tile that can change text?
Who took The Car?
Time of Use - Possible to create something like "Sunrise and Sunset"?
(Robin) #8


Thanks for the garage door idea btw… set me off in the right direction!

You mentioned:

In the default ‘simulated garage door’ handler, pressing, for example, the ‘close’ button would display the text ‘closing’, wait 6 seconds and then change text to ‘closed’, you could not select or hold it on ‘closing’ Ditto for open.

This was easy to overcome by adapting the commands for open / close. I removed the 6 second timer and made them go straight to open / close. I then added two new buttons for opening and closing.

Not sure if the ‘unknown’ state is accessible for manual selection… I’ll leave that one for a rainy day, but maybe a route to achieve 5 states?

I’d like to refine this handler with options to change the labels / images / colours via the device preferences page. But to be honest I’m not sure if it’s possible to tweak the tiles based on preferences? Another rainy day lol!

(Robin) #9


Did you ever get to try this?

Wondering if it works for you?

(Jarrett Campbell) #10

@RobinWinbourne not yet. Had some unexpected travel pop up and suck my week away. Hoping to play with it some this weekend. Will report back when I do. Thanks!

(Jarrett Campbell) #11

@RobinWinbourne I’ve got this working now. Thanks for your help. I’ve got several other applications I plan to re-purpose your device handler for. Thank you!

The only thing that I haven’t solved yet is that SmartTiles doesn’t seem to have support for the Door Control or Garage Door Control capabilities so I can’t display this in SmartTiles dashboard. Hopefully this will be solved in ActionTiles.


Tagging @tgauchat

(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #13

Yup… ActionTiles has added Garage Door Tiles.

(Glen King) #14

Ok, I’m looking at this and imagining.
I’m imagining the Favorites section of the mobile app Dashboard.

I’m imagining the Ecobee sensor icons showing Temperature… unless there is motion, at which point they switch to showing Motion! They switch back to showing temperature if either of the following occur:
a) temperature changes
b) motion ceases

Is this doable?


Just stumbled on this. I like it.

(Robin) #16

Doubt you need the garage door attribute for that… without having Ecobee or looking at the DTH, I assume the temperature tile is probably just a value tile… so you can make it say anything you like using sendEvent("name":"tileName", "value":"Whatever you like")