Custom actions not triggered by Standard tile


(PPO16) #1

Hi there,

I checked various posts on the forum/ST documentation (…) but didn’t find if/how it’s possible to have a tile to call an action when I click on it. I am porting a Honeywell air purifier and I want a tile to switch between the fan speed. The tile circles the states as expected, but the actions methods are never called (no log.debug visible in the ST logs).

Here is my code, hopefully my mistake is so basic that someone sees it:

metadata {
definition (name: "Honeywell_HFP205B", namespace: "philippeportesppo", author: "Philippe PORTES") 
    attribute "fan_speed", "string"
preferences {
        section {
            input "internal_ip", "text", title: "Internal IP", required: true
            input "internal_port", "text", title: "Internal Port (12345)", required: true
tiles(scale: 2) {
standardTile("fan", "", width: 2, height: 2) {
    state "fan_off", label:'Off', action:"fan_germ", nextState:"fan_germ"
    state "fan_germ", label:'Germ', action:"fan_general", nextState:"fan_general"
    state "fan_general", label:'General Clean', action:"fan_allergen", nextState: "fan_allergen"
    state "fan_allergen", label:'Allergen', action:"fan_turbo", nextState: "fan_turbo"
    state "fan_turbo", label:'Turbo', action:"fan_off", nextState: "fan_off"


def fan_germ()
	log.debug fan_speed

def fan_general()
	log.debug fan_speed

def fan_allergen()
	log.debug fan_speed

def fan_turbo()
	log.debug fan_speed

def fan_off()
	log.debug fan_speed


( co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

I’ve coded a couple of DTHs in my life, and I find that SmartThings is incredibly hard to debug. Code will fail and then suddenly work if cut and pasted into a new IDE window.


  1. Start super, super, super simple. Ideally, start with a template of simple code like Virtual Switch.

  2. For your code above, I don’t know if this makes a difference, but I put all my state items into ().


	tiles {
		standardTile("screenTile", "device.screen", width: 2, height: 2, canChangeIcon: true, canChangeBackground: false) {
			state("on",  label:'down (${name})', action:"screenOff", icon:"st.doors.garage.garage-closed", backgroundColor:"#79b821", nextState:"raising")
			state("off", label:'up (${name})', action:"screenOn",  icon:"st.doors.garage.garage-open",   backgroundColor:"#0000ff", nextState:"lowering")
            state("lowering", label:'${name}', action: "screenOff", icon:"st.doors.garage.garage-closing", backgroundColor:"#7fff00")
			state("raising",  label:'${name}', action: "screenOn" , icon:"st.doors.garage.garage-opening", backgroundColor:"#37fdfc")
            state("stopped",  label:'${name}', icon:"st.doors.garage.garage-opening", backgroundColor:"#888888")
            state("enabled",  label:'${name}', action: "screenOn" , icon:"st.doors.garage.garage-closing",  backgroundColor:"#555555", nextState:"lowering")

(PPO16) #3

Thanks a lot for your answer.

I tried just now the parenthesis, and even add icons etc… to look really close to your snippet but still no log.

tiles {
standardTile("fan", "", width: 2, height: 2, canChangeIcon: true, canChangeBackground: false) {
    state ("fan_off", label:'Off', action:"fan_germ", icon:"st.doors.garage.garage-closed", backgroundColor:"#79b821", nextState:"fan_germ")
    state ("fan_germ", label:'Germ', action:"fan_general",  icon:"st.doors.garage.garage-closed", backgroundColor:"#79b821",nextState:"fan_general")
    state ("fan_general", label:'General Clean', action:"fan_allergen", icon:"st.doors.garage.garage-closed", backgroundColor:"#79b821", nextState: "fan_allergen")
    state ("fan_allergen", label:'Allergen', action:"fan_turbo", icon:"st.doors.garage.garage-closed", backgroundColor:"#79b821", nextState: "fan_turbo")
    state ("fan_turbo", label:'Turbo', action:"fan_off",  icon:"st.doors.garage.garage-closed", backgroundColor:"#79b821",nextState: "fan_off")


When you say to take example on Virtual Switch, are you referring to “Dimmer Switch” code?

I wanted to avoid the switch capabilities as my low understanding of ST capabilities is that I have to stick to the actions (on/off) referred in the code as action:“”.
I would love to have capabilities “fan.turbo” etc… to match the different speed of the purifier I am porting but I don’t believe creating capabilities “fan” works, at least, I didn’t manage so far and the forum list many request to add customized capabilities. Can we create customized capabilities?

Did you create any capability for yours? As I see you just named the action “screenOn”, I suspect you did not.

( co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #4

Though the Docs once implied this would be possible, it is not.

Instead, you should tag your DTH with the generic: capability "Actuator" (i.e., any device that accepts Commands), and perhaps capability "Sensor" (i.e., any device that has a published Attribute), and then list the additional custom ad hoc commands you wish to announce and support:


metadata {
	definition (name: "Projector Screen Shield", namespace: "CosmicPuppy", author: "Terry Gauchat") {
		capability "Actuator"
		capability "Switch"
		capability "Sensor"
        command "enable"
        command "disable"
        attribute "override", "enum", ["stopping", "stopped", "enabled", "disabled"]
        command "screenOn"
        command "screenOff"
        attribute "screen", "enum", ["on", "off"]
        command "projecOn"
        command "projecOff"
        attribute "projectorSignal", "enum", ["on", "off"]

( co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #5

I mean search the SmartThings Public GitHub and find the simplest possible DTHs and make sure you can get them to work in the simulator or with a simple physical switch.

Here is one example, though it is not the simplest example, it may be useful because it demonstrates various Tile Types.

Then, incrementally, step-by-step, make changes to it until it breaks. Then go back and figure out what you did to break it.

(PPO16) #6

Thanks a lot, your previous post with having “actuator” capability made it. Now it calls the commands

Your explanation is way better than the ST guide.

Regarding the switch code, I indeed checked initially but I understood I had to stick to on()/off() commands. Maybe I missed something there.

Anyway, now it works fine! Thanks again