[SOLVED] Conditional garage door rule

Hey guys,

New to openhab so take it easy on me. I just spent the past several days doing initial setup on a Rpi 3B+. I have I installed another Rpi in my garage with several relays and reed sensors connected to the GPIO for control and status of the garage doors and all is working well.

Now the issue is I am running into is making a rule for my arrival home from work that will turn on several lights, open the garage door ect (right now it is just set to open the door) as I am coming down my street. I would like this rule to only push the garage door button (relay) if the door is closed in case the wife is outside and has it opened so I do not close it on her ect. I am using the following .py script / exec binding to check door status in openhab and all works well during manual operations, however when an attempt is made to make it conditional on door status the rule will not work.

What am I missing?

Door status .py script

import RPi.GPIO as GPIO #import the GPIO library
import time


GPIO.setmode(GPIO.BCM)
GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_UP)


while True:
    if GPIO.input(20):
       print("Closed")
       exit()
    if GPIO.input(20) == False:
       print("Open")
       exit()

.rule file

rule "Arrival"

when
     Item im_home changed from OFF to ON
then
    if(   CenterDoorStatus_Output.state == Closed ){ 
      centerdoorbutton.sendCommand(ON)
     }
End

Post your items please.
I think CenterDoorStatus_Output is a String, then

if (CenterDoorStatus_Output.state == "Closed") {

Does the python-script work correct?

1 Like

Give me just a second and I will post the items. (most of them were added using paper UI)

The output is a string, I completely forgot that dealing with all of the other binary sensors around the house.

Yes, the python-script works fine, the exec binding runs it every 45 sec and the output string is posted to the sitemap as a string.

"centerdoorbutton": {
    "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [],
      "itemType": "Switch",
      "label": "Center Door"
    }
  }
"CenterDoorStatus_Output": {
    "class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
    "value": {
      "groupNames": [],
      "itemType": "String",
      "label": "Center door status"
    }
  }

Is im_home a switch and is there a state-change in the log?

I just updated the rule to make it a string and it fixed it. Obviously I need more coffee.

Thanks for the help!