Is there an easy way to return a smart apps selected device count without having to do a settings.switches.size()
on every type?
There isn’t
1 Like
Lol. Thanks Tim… I love it!
It doesn’t get more absolute than that
2 Likes
It’s a bit of a hack but you can get settings.size() and substract the non device settings from that.
thank patrick. I did notice it returned a value. just never thought to subtract the other values
Thanks to @pstuart his idea sparked this which seems to work great when called by the smart app preferences.
Just figured I would post this for anyone who might need it in the future:
//Returns the applications currently selected device count
private def selectedDevCount() {
def devList = []
settings.each { item ->
switch (item.key) {
//Add the settings labels you wish to exclude to the this array
case ["evtServerPath", "detailEvts", "enableEvtServer", "evtServerPort", "debugLogging", "evtServerUrl"]:
break
default:
for (rec in item.value) {
devList.add(rec.toString())
}
break
}
}
return devList.unique().size() ? devList.unique().size() : 0
}