I`ve installed a humidity sensor in my bathroom and want to differentiate if someone is bathing or taking a shower. having a shower results in a steep rise of humidity while a bath shows a more flat increase. the attached screenshot show shower and bath times…
to get a more accurate messurement I shorten the samples of the humidity sensor to 10sec intervall when movement is detected in the bathroom.
the challenging thing is that I need to differentiate between shower and bath as quick as possible as I want to start a towel heater while having a shower.
the rules I attached at the bottom have a high failure rate. sometimes the rule triggers for a bath when I just brush my teeth.
did anybody ever tried something similar or has some more mathematically approached rules for this use case?
rule "shower oder bathtube"
when
Item LED_Bad_hum changed
then
val Number Badhum_t1 = LED_Bad_hum.historicState(now.minusMinutes(2)).state as DecimalType
val Number Duschhum_t1 = LED_Bad_hum.historicState(now.minusSeconds(30)).state as DecimalType
val Number Badhum_t0 = LED_Bad_hum.state as DecimalType
val Number Baddiff = Badhum_t0 - Badhum_t1
val Number Duschdiff = Badhum_t0 - Duschhum_t1
if (Baddiff >= 10 && duschcounter == 0 && Badewanne.state == OFF) {
bathtube.postUpdate(ON)
badecounter = badecounter + 1
createTimer(now.plusMinutes(10), [ |
...do something
])
sendNotification("xxx", "someone takes a bath")
}
else if (Duschdiff >= 8) {
duschcounter = duschcounter + 1
Dusch_counter.sendCommand(duschcounter)
Dusche.sendCommand(ON)
sendNotification("xxx", "someone takes a shower")
if (LED_Bad_t.state <= 23 ) {
Bad_Radiator.sendCommand(ON)
createTimer(now.plusMinutes(5), [ |
Bad_Radiator.sendCommand(OFF)
])
}
}
end