i am trying to make a rule that reacts to a changed state of a device (if that speicific device gets offline) but only within a certain time window.
i would like to have the rule active nearly 24/7 except from 06:30 - 06:50 at every day.
I tried it like that:
rule "inform on power loss"
when
Item network_pingdevice_df634471_online changed from ON to OFF
then
//excluded time
if ((now.isAfter(now.withTimeAtStartOfDay.plusHours(6).plusMinutes(30)) && now.isBefore(now.withTimeAtStartOfDay.plusHours(6).plusMinutes(50)))!=1) {
//send message
logInfo("inform_on_power_loss", "send message to me")
sendBroadcastNotification("send message to me")
}
But it always send the message if the device changed from ON to OFF. My time exception does not work.
but isn’t anytime before 06:30 that is not 06:30 ? The same goes with after 06:50 ?
you mean like that? if (now.isBefore(now.withTimeAtStartOfDay.plusHours(6).plusMinutes(30)) || now.isAfter(now.withTimeAtStartOfDay.plusHours(6).plusMinutes(50))) {