SmartThings Community

Rotating states virtual switch


#1

I have a dyson fan and three modes set up in harmony.
I would like to rotate them using core but first I need a switch that can rotate through states.
How do I create that?


#2

I wouldn’t think you would need a switch for this, you’ll just need a variable in core keep track of where you’re at in the sequence. But you’ll get the quickest answer by asking in the core peer Assistance thread, that’s where most of the core experts hang out. Just add your question to the end of the thread and someone will help you.

Another alternative would be to set up three virtual switches, one for each state, which is how we would’ve done this a couple of years ago, but I honestly think with Core you won’t need to do that. :sunglasses:


#3

Ah a bit of context here. I have a Google Home so creating an extra switch in “things” enables voice control :slight_smile: That’s why I’d like a virtual switch that could be exposed to Google.


(Robin) #4

If I understand you correctly, you want a simulated momentary switch to trigger a rotation between 3 modes?

In CoRE, use 3 separate actions in the ‘then’ section, each with a mode restriction:

IF
Simulated Momentary Switch changes to on
THEN

® mode is X
|> change mode to Y

® mode is Y
|> change mode to Z

® mode is Z
|> change mode to Y

You may also want a 4th action to catch when the mode is not already X, Y or Z:

® mode is A, B or C
|> change mode to Y

Or just place this in the first action:

® mode is A, B, C or X
|> change mode to Y


#5

I would like a three-stage switch which

  1. can report its status and be control directly in “things”
  2. be exposed to Home (“turn dyson to heat”)

then I could get core to read the switch status and fire off harmony events correspondingly.

I’ve dipped my toes into the handler thing but seems like “switch” is only binary?
Any device capability that is suitable for this? I used “actuator” as a placeholder here.
I couldn’t get the button to change the “dyson” attribute.
Please help.

metadata {
definition (name: “Dyson Link”, namespace: “xxx”, author: “xxx”) {
capability "Actuator"
capability “Sensor”

  attribute "dyson", "string"
  command "on"
  command "auto"
  command "cool"
  command "heat"

}

tiles(scale:2) {
standardTile(“button”, “device.actuator”, width: 6, height: 4, canChangeIcon: true) {
state “off”, label: “Off”, action: “actuator.auto”, icon: “st.Appliances.appliances11”, backgroundColor: “#ffffff”, nextState: "auto"
state “auto”, label: ‘Auto’, action: “actuator.cool”, icon: “st.Appliances.appliances11”, backgroundColor: “#00cc66”, nextState: "cool"
state “cool”, label: ‘Cool’, action: “actuator.heat”, icon: “st.Appliances.appliances11”, backgroundColor: “#00ccff”, nextState: "heat"
state “heat”, label: ‘Heat’, action: “actuator.off”, icon: “st.Appliances.appliances11”, backgroundColor: “#ff6699”, nextState: “off”
}
}
}

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

def auto() {
sendEvent(name: “dyson”, value: “auto”)
}

def cool() {
sendEvent(name: “dyson”, value: “cool”)
}

def heat() {
sendEvent(name: “dyson”, value: “heat”)
}


(Chris) #6

Personally I’d use CoRE to handle the smarts and actions, use GH/IFTTT for the voice component, and use virtual switches for the “things” control, instead of getting into custom DTH. That’s just me though.

You could probably even get away with skipping the virtual switches if you were willing to manually execute/simulate pistons when needing manual control.


#7

A switch is binary, yes.

What some people have done in a similar situation is to use a virtual dimmer and just assign values 1–33 to “A”, 34–66 to “B” and 67-100 to “C.” Such as for A device with low/medium/high but really you can use it for anything.

You might also look at what people have done with thermostats, which commonly have three three Thermostat modes (cool, heat, off). I know some people have created tiles, for example, which cycle between the three such as blue for cool, orange for heat, and white for off. There might be some more options there.