Hy,
I want to control a relay with a button in openHab, and i want to create a rule to check if state is ON or OFF and after that to do a thing.
I am new in codding and i don't know what I've done wrong.
I need some help, please.
This si the code from home.items
Switch buc1_releu "Bec1" (LivingRoom) { gpio="pin:18 activelow:yes initialValue:high force:true" }
Contact buc1_intrerupator "Intrerupator [%s]" (LivingRoom) { gpio="pin:23 activelow:yes" }
And this si the home.rules
rule "buc1"
when
Item buc1_intrerupator changed
then
if (buc1_releu.state == ON){
sendCommand(OFF)
}
else if (buc1_releu.state == OFF){
sendCommand(ON)
}
end
Found the problem, this is the correct code :D