I want to set multiple thermostats fanmode to on.
Should this code work?
thermostats.fanOn()
Where thermostats
is a multiple preference item.
In the big switch, they do switches.On() (which is why I think it should work).
I want to set multiple thermostats fanmode to on.
Should this code work?
thermostats.fanOn()
Where thermostats
is a multiple preference item.
In the big switch, they do switches.On() (which is why I think it should work).
That should work. … …
I thought it had to be
thermostats*.fanOn()
I know that thermostats?.fanOn() avoids a null condition, but I’m not familiar with the asterisk, checking groovy resources now.
I think @obycode could be right, but then how does the big switch work?
I’ve used it without the asterisk in pretty much all of my apps, except for the possible null case with ?. Things like this work:
("on" in switches.currentSwitch)
switches.off()
dimmers.setLevel(level)
Then does this work?
subscribe(thermostats*, “thermostatFanMode.fanOn”, thermostatOnHandler)
Apologize for what may be basic questions. I’m a hack.
I don’t think so. I would use collect for that:
thermostats.collect {
subscribe(it, "thermostatFanMode.fanOn", thermostatOnHandler)
}
I’ve used successfully,
subscribe(motions, "motion.active", motionActiveHandler)
Try these variations. Then use the IDE to look at the app subscriptions. You will see separate subscriptions.
Oh yeah, you’re right. I’ve used that before too.
That’s the key, I always forget to look deeper in the IDE, I’ll have a look.
I think it depends. The Big Switch uses switches.On() because it has assigned the variable switches via the preferences section. It is not calling all switches a user has. Only those selected by the user during SmartApp installation.
section("Turn on or off all of these switches as well") {
input "switches", "capability.switch", multiple: true, required: false
}
Well yea, but you can only get devices from preferences. In the case of multiple:true
, you get a [list of devices]. Those can be handled this way when it makes sense. That is, do something to all of them.
I can confirm that:
subscribe(thermostats, "thermostatFanMode.fanOn", thermostatOnHandler)
works on multiple stats, and that I am getting them from preferences. Something else is going on in my code.
thanks all!