I’m following the “Proxy Item” approach fpr Manual Trigger Detection and it’s working well for me. The Rule that aces when the group receives a command is doing a lot of work, but I like having it all in one place.
I’m using the same script for dimmers and switches. I have cases where I need to know simply if the light was turned on or off (a change in dimmer setting being regarded as an “ON”). Is there a way to do this without this excessive logic?
var binaryState = ""
if (triggeringItem.type == "Dimmer"){
if (receivedCommand == ON){
binaryState = ON
} else if (receivedCommand == OFF){
binaryState = ON
} else {
if ((receivedCommand as Number).intValue > 0){
binaryState = ON
} else {
binaryState = OFF
}
}
} else {
binaryState = receivedCommand
}