Hi All,
I use following simple codes to turn on/off lights periodically
rule "Periodically check auto lights"
when
Time cron "0 */10 * ? * *"
then
// If nobody is home and dark outside
if (AlleAusserHaus.state == ON && now.isAfter((Sunset_Time.state as DateTimeType).zonedDateTime.toInstant().toEpochMilli) ||
now.isBefore((Sunrise_Time.state as DateTimeType).zonedDateTime.toInstant().toEpochMilli)){
logInfo("LightsAuto", "Auto Light Check")
gEG_Licht.members.forEach[lamp|
lamp.sendCommand( lamp.historicState(now.minusDays(7),"rrd4j").state.toString )
logInfo("myrule","historic state {}",lamp.historicState(now.minusDays(7),"rrd4j").state)
]
}
end
Unfortunately, the lights swtiches even if we are at home or not:
2018-11-06 00:30:00.051 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 00:40:00.055 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 00:50:00.058 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 01:00:00.049 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 01:10:00.044 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 01:20:00.066 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 01:30:00.071 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 01:40:00.046 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 01:50:00.053 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 02:00:00.085 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 02:10:00.057 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 02:20:00.079 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 02:30:00.051 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 02:40:00.048 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 02:50:00.046 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 03:00:00.060 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 03:10:00.057 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 03:20:00.068 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 03:30:00.057 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 03:40:00.049 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 03:50:00.054 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 04:00:00.061 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 04:10:00.100 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 04:20:00.055 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 04:30:00.064 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 04:40:00.273 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 04:50:00.050 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 05:00:00.064 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 05:10:00.050 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 05:20:00.046 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 05:30:00.080 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 05:40:00.060 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 05:50:00.050 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 06:00:00.081 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 06:10:00.069 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 06:20:00.052 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 06:30:00.047 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 06:40:00.079 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 06:50:00.050 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 07:00:00.078 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-06 07:10:00.065 [INFO ] [se.smarthome.model.script.LightsAuto] - Auto Light Check
2018-11-05 07:55:13.801 [vent.ItemStateChangedEvent] - AlleAusserHaus changed from OFF to ON
2018-11-05 08:02:13.281 [vent.ItemStateChangedEvent] - AlleAusserHaus changed from ON to OFF
2018-11-06 08:08:15.110 [vent.ItemStateChangedEvent] - AlleAusserHaus changed from OFF to ON
2018-11-06 13:13:38.941 [vent.ItemStateChangedEvent] - AlleAusserHaus changed from ON to OFF
Does someone have an idea, what is wrong in the code?
I would expect, that the lights only switch at the moment the variable
AlleAusserHaus
is equal to
ON
.
Thanks for your help in advance.
Dom