Hi all,
I am living on the top floor in an apartment, and to get into my flat i have hacked the intercom phone. I have then attached this to a relay that i control with a switch item:
Switch Div_DoorOpener "Door Opener" (Group_Hallway,Group_LightLogging) { gpio="pin:22" } //mappings=[ON="On"] //Relay 5
However i want to just push the switch item, then the PIN(Rpi) goes HIGH for around 6 seconds and then the pin go back to LOW
However I am having some problem with my rule on reboot, and changing the state of switch, sometimes its just flickers between high and low state on the pin
Here is my rule:
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.openhab.core.library.types.*
var Timer timer=null
rule "Opening Door"
when
Item Div_DoorOpener changed from OFF to ON
then
if(Div_DoorOpener.state == OFF){
sendCommand(Div_DoorOpener,ON)
postUpdate((Div_DoorOpener,ON)
timer = createTimer(now.plusSeconds(6)) [|
sendCommand(Div_DoorOpener, OFF)
postUpdate((Div_DoorOpener,OFF)
]
}
else {
//sendCommand(Div_DoorOpener, OFF)
}
end
Should I change my item to
Switch Div_DoorOpener "Door Opener" (Group_Hallway,Group_LightLogging) { gpio="pin:22" } { autoupdate="false" } mappings=[ON="Open"] //Relay 5
I also tried to initialize my switch:
rule “Initialize all items”
when
System started
then
logInfo( “Initializer”, “Started Timer …”)
createTimer(now.plusSeconds(45)) [|
logInfo( "Initializer", "... initializing!")
//Wir warten 45 Sekunden, dann initalisieren wir alle die nicht aus der Datenbank befüllt wurden
Group_LightLogging.members.filter( x | x.state == Uninitialized).forEach[ item |
postUpdate( item, OFF)
]
]
end
Did I miss something, how should my item be defined and how should the rule look like to get it to work?
ANy hint will help:)
