3 Mode switch not mapping correctly

I’ve got a 3 mode switch in my sitemap that I want to use to control my garden watering system. I want there to be a manual and automatic mode (On, Off, Auto) so the switch has 3 mappings. However, in my rules, I am having problems reading the state of the switch. Here’s what I’ve got in my files. Any suggestions?

.sitemap

Switch item=gardenControlProxy mappings=[auto=Auto,on=On,off=Off]

.items

Switch gardenControlProxy "Watering Mode" <garden>
Switch gardenControlBound {mqtt=">[mosquitto:/home/garden/wateringMode:command:ON:1],>[mosquitto:/home/garden/wateringMode:command:OFF:0]"}

.rules

rule "Garden mode"
when
    Item gardenControlProxy received command
then
 if(gardenControlProxy.state.toString().equals("off")) {
     gardenControlBound.sendCommand(OFF)
     gardenTimer = false
}
else if (gardenControlProxy.toString().equals("on")) {
	gardenControlBound.sendCommand(ON)
	gardenTimer = false
}
else {
	gardenControlBound.sendCommand(OFF)
	gardenTimer = true
}
end

gardenControlProxy needs to be a String.

Switch can only be ON or OFF. You cannot assign “auto” to a Switch.

1 Like

Yep, that did the trick!