What version of openhab are you running?
OPenhab 2.3 on RPi3 with openhabian
My bad, the two rules have the same name!!
rule "Garage door direction1"
when
Status_Garagentor_close changed to OPEN or //Door opening
Status_Garagentor_open changed to OPEN //Door closing
then
if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("OPENING")
if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("CLOSING")
end
rule "Garage door direction2"
when
Status_Garagentor_close changed to CLOSED or //Door closed
Status_Garagentor_open changed to CLOSED //Door open
then
if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("CLOSED")
if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("OPEN")
end
Just to show a way of doing this
My items
Switch GarageDoorSwitch [ "Switchable" ] { mqtt=">[broker:cmnd/GarageDoorSonoff/POWER:command:*:default]" }
Rollershutter GarageDoor
String GarageDoorState
Switch GarageDoorClosed { mqtt="<[broker:cmnd/GarageDoorSensors/POWER1:state:default]" }
Switch GarageDoorOpened { mqtt="<[broker:cmnd/GarageDoorSensors/POWER2:state:default]" }
Number Garage_RSSI "Garage: RSSI [%d %%]" { mqtt="<[broker:tele/GarageDoorSonoff/STATE:state:JSONPATH($.Wifi.RSSI)]" }
String Garage_IP "Get Info" { mqtt=">[broker:cmnd/GarageDoorSonoff/IPAddress1:command:*:*]" }
String Garage_IP_String "Info [%s]" { mqtt="<[broker:stat/GarageDoorSonoff/RESULT:state:default]" }
Switch GarageDoorAuto "Garage Door auto close 9PM-5AM"
Switch GarageDoorStateUpdate { mqtt=">[broker:cmnd/GarageDoorSonoff/STATUS:command:*:10]" } //hidden button to get update of garage door status. Runs every minute
String GarageDoorStateString { mqtt="<[broker:tele/GarageDoorSonoff/SENSOR:state:default]" } //hidden string to be updated depending on status
sitemap
Text label="Garage" icon="garage"
{
Frame label="Control"
{
Switch item=GarageDoor label="Garage Door" icon="garagedoor"
}
Frame label="Status"
{
Text item=GarageDoorState label="[%s]" icon="garagedoor" valuecolor=[GarageDoorState=="Closed"="green",GarageDoorState=="Open"="red",GarageDoorState=="Ajar"="orange"]
}
Text label="Settings" icon="settings"
{
Switch item=GarageDoorAuto icon="time"
}
}
rules
var Timer garageDoorTimer
var Timer garageDoorOpenTimer
//*************************************************************************** Garage Door Rules Below********************************************************************
rule "Garage Door Open"
when
Item GarageDoor received command UP
then
if (garageDoorTimer !== null)
{
garageDoorTimer.cancel
garageDoorTimer = null
}
if (GarageDoorOpened.state != ON)
{
GarageDoorSwitch.sendCommand(ON)
garageDoorTimer = createTimer(now.plusSeconds(25)) [|
if (GarageDoorOpened.state != ON && GarageDoorClosed.state == ON)
{
GarageDoorSwitch.sendCommand(ON)
}
]
}
end
//********************************************************************
rule "Garage Door Close"
when
Item GarageDoor received command DOWN
then
if (garageDoorOpenTimer !== null)
{
garageDoorOpenTimer.cancel
garageDoorOpenTimer = null
}
if (garageDoorTimer !== null)
{
garageDoorTimer.cancel
garageDoorTimer = null
}
if (GarageDoorClosed.state != ON)
{
GarageDoorSwitch.sendCommand(ON)
garageDoorTimer = createTimer(now.plusSeconds(25)) [|
if (GarageDoorClosed.state != ON && GarageDoorOpened.state == ON)
{
GarageDoorSwitch.sendCommand(ON)
}
]
}
end
//********************************************************************
rule "Garage Door Stop"
when
Item GarageDoor received command STOP
then
if (garageDoorTimer !== null)
{
garageDoorTimer.cancel
garageDoorTimer = null
}
if (GarageDoorClosed.state != ON && GarageDoorOpened.state != ON)
{
GarageDoorSwitch.sendCommand(ON)
}
end
//********************************************************************
rule "Garage Door State"
when
Item GarageDoorClosed received update or
Item GarageDoorOpened received update
then
Thread.sleep(500)
if (GarageDoorClosed.state == ON && GarageDoorOpened.state == OFF)
{
GarageDoor.postUpdate(DOWN)
GarageDoorState.postUpdate("Closed")
if (garageDoorOpenTimer !== null)
{
garageDoorOpenTimer.cancel
garageDoorOpenTimer = null
}
}
if (GarageDoorOpened.state == ON && GarageDoorClosed.state == OFF)
{
GarageDoor.postUpdate(UP)
GarageDoorState.postUpdate("Open")
}
if (GarageDoorClosed.state == OFF && GarageDoorOpened.state == OFF)
{
GarageDoor.postUpdate(50)
GarageDoorState.postUpdate("Ajar")
}
end
//********************************************************************
rule "Garage Door Button Timer"
when
Item GarageDoorSwitch received command ON
then
createTimer(now.plusSeconds(1)) [|
GarageDoorSwitch.sendCommand(OFF)
]
end
//********************************************************************
rule "Garage Door Auto Close"
when
Time cron "0 0/6 21-5 1/1 * ? *"
then
if (GarageDoorAuto.state == ON)
{
if (GarageDoorClosed.state != ON)
{
sendBroadcastNotification("Garage door will shut in 5 minutes")
garageDoorOpenTimer=createTimer(now.plusMinutes(5)) [|
sendBroadcastNotification("Garage door has closed automatically")
GarageDoor.sendCommand(DOWN)
]
}
}
end
//********************************************************************
rule "Garage Door Auto Close Switch "
when
Item GarageDoorAuto received command OFF
then
if (garageDoorOpenTimer !== null)
{
garageDoorOpenTimer.cancel
garageDoorOpenTimer = null
}
end
//********************************************************************
rule "Garage Door Opening"
when
Item GarageDoorClosed changed from ON to OFF
then
sendBroadcastNotification("Garage Door has opened!")
end
//********************************************************************
rule "Garage Door Closing"
when
Item GarageDoorOpened changed from ON to OFF
then
Thread::sleep(500)
if (GarageDoorOpened.state != ON)
{
sendBroadcastNotification("Garage Door is Closing!")
}
end
Basically. I have a switch which literally sends the MQTT command,
I use a ruller shutter item to have UP X DOWN as commands.
I then run rules to check if the garage is down, and i press down, nothing happens, If the garage is up and i press up, nothing happens. And the X button only works if the garage is neither opened of closed.
I also have 2 reed switches, one for open, one for close.
I have another rule. which when i press either up or down, it sends the command to activate the garage. if after 25 seconds, it hasnāt activated the reed switch i wanted, (either opened or closed depending what i pressed), it will press the garage button one time. If for instance, there is something blocking the door from moving, it wont run the rule again, as I pressed the garage button, not pressed up/down again.
I also have timers, and auto closing after certain times. as you can see in my rules
Nice one, did not think about that. Will implement this too, thx.
Hi Vincent
this doesnĀ“t solve the problems, ist still:
no viable alternative at inpotā¦
and
the method or field triggeritem is undifined.
Christopher thank you for your very welcome input.
I will need some time to see how I can implement your rules as I use two KNX contacts to open and close the carage door and to reed an a KNX sensor to read the status.
Furthermore IĀ“m not sure how these rules handle Inputs from remote, or in my case from usual KNX switches.
THX
Daniel
Items
Switch Garagentor_open "Garagentor" (gAussen) [ "Switchable" ] {knx="5/1/2+<10/3/2"}
Switch Garagentor_close "Garagentor" (gAussen) [ "Switchable" ] {knx="5/1/1+<10/3/1"}
Switch Haustuere "HaustĆ¼re" (gAussen) [ "Switchable" ] {knx="5/1/0"}
Contact Status_Garagentor_open "Garantor offen " <Garagedoor> (gAussen) [ "Switchable" ] {knx="4/3/1"}
Contact Status_Garagentor_close "Garantor geschlossen " <Garagedoor> (gAussen) [ "Switchable" ] {knx="4/3/2"}
String Status_Garagentor "Status Garagentor"
Rule
rule "Garage door direction1"
when
Status_Garagentor_close changed to OPEN or //Door opening
Status_Garagentor_open changed to OPEN //Door closing
then
if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("OPENING")
if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("CLOSING")
end
rule "Garage door direction2"
when
Status_Garagentor_close changed to CLOSED or //Door closed
Status_Garagentor_open changed to CLOSED //Door open
then
if (triggeringItem.name.toString == "Status_Garagentor_close") Status_Garagentor.postUpdate("CLOSED")
if (triggeringItem.name.toString == "Status_Garagentor_open") Status_Garagentor.postUpdate("OPEN")
end
THX
rule "Garage door opening"
when
Status_Garagentor_close changed to OPEN //Door opening
then
Status_Garagentor.postUpdate("OPENING")
end
rule "Garage door closing"
when
Status_Garagentor_open changed to OPEN //Door closing
then
Status_Garagentor.postUpdate("CLOSING")
end
rule "Garage door closed"
when
Status_Garagentor_close changed to CLOSED //Door closed
then
Status_Garagentor.postUpdate("CLOSED")
end
rule "Garage door open"
when
Status_Garagentor_open changed to CLOSED //Door open
then
Status_Garagentor.postUpdate("OPEN")
end
Sorry fore the late respond, was on holydays.
IĀ“m really sorry but I dont get it. Its still the same
no viable alternative at input āStatus_Garagentor_closeā (3,5)
no viable alternative at input āStatus_Garagentor_openā (10,5)
no viable alternative at input āStatus_Garagentor_closeā (17,5)
no viable alternative at input āStatus_Garagentor_openā (24,5)
Found the problem
Just had to add Item before āStatus_Garagentorā
Thank you very much. You helped me a lot Vincent
I canāt believe I missed that!!