You can’t do and in rule triggers. What you are asking for is two events to happen at the exact same moment.
You can’t do that either, you are asking if some condition is true AND some instantaneous event is happening, just at the moment that you are asking.
But I can see what you are trying to do, so let’s rearrange it
rule "Lampen aan als er iemand thuis is en de zon is onder"
when
Channel "astro:sun:local:set#event" triggered START or
Item Iemand_Thuis changed to ON
then
So, this will run the rule at sunset (which occurs once each day)
and it will also run the rule whenever Iemand_Thuis
changes to ON (I’m guessing this is your ‘presence’ indication - and that this rule doesn’t care when it goes OFF)
This gets the rule to run at the times you are interested - when it’s sunset, when someone comes home.
But that’s not enough on its own, we don’t want to turn lights on at sunset unless there is someone home. We can tell this by looking at Iemand_Thuis (I think?)
Also, we don’t want to turn on lights when someone comes home unless it is dark. Ah, now there’s a problem - how do we tell if it is dark?
Let’s make a new Item to show if it is dark outside or not
Switch Daylight "it is light outside"
We could just turn that on or off using rules triggered by sunset and sunrise events.
But, complication. If we reboot openHAB or reset Items by editing, this Item wouldn’t get set until the next sunrise/sunset event.
Let’s take a simple version of Rick’s Time of Day Design Pattern just for the daylight part.
items
Switch Daylight "it is light outside"
DateTime Sunrise_Time "Sunrise [%1$tH:%1$tM]" { channel="astro:sun:local:rise#start" }
DateTime Sunset_Time "Sunset [%1$tH:%1$tM]" { channel="astro:sun:local:set#end" }
and some rules
rule "Calculate daylight state anytime"
when
System started or // run at system start
Item Sunrise_Time updated or // run when Astro updates at midnight
Item Sunset_Time updated
then
// make sure both are valid
if (Sunrise_Time.state != NULL && Sunset_Time.state != NULL) {
val day_start = new DateTime(Sunrise_Time.state.toString) // convert to joda time
val night_start = new DateTime(Sunset_Time.state.toString)
if (now.isAfter(day_start) && now.isBefore(night_start) {
Daylight.postUpdate(ON)
} else {
Daylight.postUpdate(OFF)
}
}
end
rule "sunrise"
when
Channel 'astro:sun:local:rise#event' triggered START
then
Daylight.postUpdate(ON)
end
rule "sunset"
when
Channel 'astro:sun:local:set#event' triggered END
then
Daylight.postUpdate(OFF)
end
That seems a lot of work, but we now have a day/night switch you can use in many rules.
So, back to your original requirement.
Trigger a rule as it becomes dark OR when someone comes home
Then let’s make sure it is dark before turning on lights (you may have come in daylight)
AND
let’s make sure someone is at home (sunset may happen when no-one is at home)
rule "Lampen aan als er iemand thuis is en de zon is onder"
when
Item Daylight changed to OFF or
Item Iemand_Thuis changed to ON
then
if (Daylight.state == OFF && Iemand_Thuis.state == ON) {
// turn your lights on
}
end