Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (29 sloc) 883 Bytes
import org.openhab.core.library.types.DateTimeType
rule "Switch Schild on"
when
Item doorLock changed from CLOSED to OPEN or
Item memberCount changed from 0
then
// Only switch on immediately if it's already 30 min before sunset
if(now.isAfter((Sunset_Time.state as DateTimeType).calendar.timeInMillis)) {
sendCommand(Schild, ON)
}
end
rule "Switch Schild off"
when
Item memberCount changed to 0
then
logInfo("schild", "Schild is switched off, no ones there anymore")
sendCommand(Schild, OFF)
end
rule "Check for Sunset to switch schild on"
when
Time Sunset_Event received update ON
then
logInfo("schild", "Checking for open and sunset")
if((Schild.state == OFF || Schild.state == Uninitialized) &&
(memberCount.state > 0 || doorLock.state == OPEN)) {
sendCommand(Schild, ON)
logInfo("schild", "Schild is switched on, because it's now dark enough")
}
end
You can’t perform that action at this time.