I’m to create a rule that turns on a wall switch when the humidity reaches a threshold and the window is open. I was trying to use the AND function in Groups for it. Eventually I want to also add the condition that the door must be open as well when I leave the bathroom.
To start, I created a group with the humidity sensor as the only member. I have a rule that toggles the state of the group based on humidity.
rule "is the bathroom humid"
when
Item bathroomWeatherHumidity changed
then
if(bathroomWeatherHumidity.state >=71) {
Thread::sleep(100)
bthrmhumid.sendCommand(ON)
logInfo("bthrm_humid", "bthrm_humid sent command ON")
}
else {
Thread::sleep(100)
bthrmhumid.sendCommand(OFF)
logInfo("bthrm_humid", "bthrm_humid sent command OFF")
}
end
I created a similar rule for opening the window.
rule "bathroom window status"
when
Item bathroomWindowStatus changed
then
if(bathroomWindowStatus.state == OPEN) {
Thread::sleep(100)
gBathroomWindow.sendCommand(ON)
}
else {
Thread::sleep(100)
gBathroomWindow.sendCommand(OFF)
}
end
The Thread::sleep are there because I thought it might be that the series of changes is causing the problem. I then created 3 groups to use an AND function.
Group:Switch:OR(OFF,ON) bthrmhumid (gBathroomcooldown)
Group:Switch:AND(OFF, ON) gBathroomcooldown
Group:Switch:OR(OFF,ON) gBathroomWindow (gBathroomcooldown)
Items:
Number bathroomWeatherHumidity "humidity [ %.1f ]" <humidity> (humidity, gBathroom, bthrmhumid) {channel="mihome:sensor_weather_v1:158d00023cf40a:humidity" }
Contact bathroomWindowStatus "Open Status" <door> (door, gBathroom, gBathroomWindow) { channel="mihome:sensor_magnet:158d000276dc88:isOpen" }
Both of the groups, bhtrmhumidity and gBathroomWindow are both changing correctly. My problem is with gBathroomcooldown. When the value starts as null, I can change gBathroomcooldown with the humidity or window. But then subsequent changes in bthrmhumidity and gBathroomWindow aren’t changing gBathroomcooldown. Is there something I am overlooking in the way I’m using AND in the group function?