But its not working out and I don’t really know why. Are these conditions too complexe for OH?
If I put the “Phone”-Conditions into an seperate IF-statement, it’s fine:
if ( Tageszeit.state == "NIGHT" || Tageszeit.state == "CIVIL_DAWN") {
if (Phone1_Online.state == OPEN || Phone2_Online.state == OPEN){
logInfo("Abenddämmerung", "Flurlicht angeschaltet!")
Flur_SmartPlug.sendCommand(ON)
}
}
But I personally don’t like to have IF-statements in another IF-statements.
Does someone got a different way to realize that or can someone tell me where i got my mistake in the first part.
Hi @ all,
thanks for the fast responses.
I got a really strange behavior with my system. This morning i did a reboot of the system and went on trying different stuff. And now, some magic happened, and my first code is working great!
rule "Flur-Nachtlicht Automatik AN"
when
Channel 'astro:sun:home:night#event' triggered START or
Item Phone1_Online changed to OPEN or
Item Phone2_Online changed to OPEN
then
if ( (Tageszeit.state == "NIGHT" || Tageszeit.state == "CIVIL_DAWN") &&
(Phone1_Online.state == OPEN || Phone2_Online.state == OPEN)){
logInfo("Abenddämmerung", "Flurlicht angeschaltet!")
Flur_SmartPlug.sendCommand(ON)
}
end
I don’t know what problem OH got, but will see if this will happen again in the future, maybe after the next reboot.
For completeness and as inspiration for other newbees, thats my rule to switch off the light when I’m leaving or night is over.
rule "Flur-Nachtlicht Automatik Aus"
when
Channel 'astro:sun:home:civilDawn#event' triggered END or
Item Phone1_Online changed to CLOSED or
Item Phone2_Online received command CLOSED
then
if ( Tageszeit.state == "NIGHT" || Tageszeit.state == "CIVIL_DAWN"){
if (Phone1_Online.state == CLOSED || Phone2_Online.state == CLOSED){
logInfo("Abwesenheit", "Flurlicht ausgeschaltet!")
Flur_SmartPlug.sendCommand(OFF)
}
}
if( Tageszeit.state != "NIGHT" || Tageszeit.state != "CIVIL_DAWN"){
Flur_SmartPlug.sendCommand(OFF)
logInfo("Morgendämmerung", "Flurlicht ausgeschaltet!")
}
end
// => I'm using the fritzboxtr064 Binding for presence recognition
@Udo_Hartmann, yeah I thought the same but it worked as designed in the manual of the Astro binding.