The rule below fails to save. I looked at Rlkoshaks design pattern for some inspiration. I see he is using or but i can’t find any examples like if the item changes announce it but only between midnight and 6. Please help! Much appreciated. Below is what I have tried under the french door
rule "Basement door"
when
Item Basement_door_DoorSensor changed from CLOSED to OPEN
then
{
Kitchen_Speak.sendCommand("Basement door has been opened")
JayBedroom_Speak.sendCommand("Basement door has been opened")
}
end
rule "French door"
when
Item FrenchDoor_DoorSensor changed from CLOSED to OPEN && Time cron 0 0 0-6 ? * * *
then
{
Kitchen_Speak.sendCommand("Kitchen French door has been opened")
JayBedroom_Speak.sendCommand("French door has been opened")
}
end
Issue of the topic: please be detailed explaining your issue
Please post configurations (if applicable):
Items configuration related to the issue
Sitemap configuration related to the issue
Rules code related to the issue
Services configuration related to the issue
If logs where generated please post these here using code fences:
Rules are triggered by events. No two events occur at the same time so and makes no sense. Between the hours of midnight and 6am is a state, not an event.
So you can’t do this with the rule triggers.
But you can have an if statement as the first line of the rule and exit if it isn’t the right state. Using the timer if day do
What you have wouldn’t work. Timecron generates an event itself. What you need is a condition check for the hour of the day. Use the now variable to do so. Something like this:
val hourOfDay = now.getHourOfDays()
if ( hourOfDay > 0 && hourOfDay < 6 ) {
...
}
As @rlkoshak and @yfaway mentionned it won’t work
The triggers in rules can only be “or” because 2 events will NEVER happen at the same time
rule "French door"
when
Item FrenchDoor_DoorSensor changed from CLOSED to OPEN
then
if (now.getHourOfHay <= 6) { // Between 12:00 and 6:59:59am
Kitchen_Speak.sendCommand("Kitchen French door has been opened")
JayBedroom_Speak.sendCommand("French door has been opened")
}
end
But I recommend that you implement something like this: