Help, I can not read gpio for a pushbutton

Hello everyone, my name is Pablo, I am from Spain and my English is bad, jejeje
I hope you can help me, two weeks ago I installed openhab and I’m still trying to understand it … jejeje

I tell you my project:
I want to domotize my house, but before I’m doing tests with leds …
I have openhab 1.8.3 with raspbian jessy I have also installed the binding io.gpio and binding.gpio version 1.9.0, I also have the user openhab in the group gpio and as root.

What I try to do is, with a pushbutton, the LED lights up but I can not get it to work, it does not read the gpio.

Here my configuration:

items:
Switch	RaspiLED	{ gpio="pin:4" }
Contact push               { gpio="pin:17 debounce:10 activelow:yes" }

sitemap
sitemap home label="Home"
{

    //------------------------------------------------------------------------
    // Raspberry Pi
   // GPIO
 //------------------------------------------------------------------------
 Frame label="Rasperry Pi GPIO"
{
  Switch item=RaspiLED

}


Rules
rule "Pulsador"
when
   Item Pulsador changed
      then
          if (Pulsador.state == OPEN) {
            RaspiLED.sendCommand(ON) }
      else {
            RaspiLED.sendCommand(OFF) }
      end

The truth is that I have read the wiki openhab many times but I can not do this …

Thank you very much and I love the forum !!

Regards

Hello Pablo,

you defined a contact named push, but the rule triggers to an Item named Pulsador, so no wonder, the rule never gets triggered :wink:

Did you test the GPIOs from command line?

Hi, thanks for replying.
In the rules I also have a push button but it does not work. It’s like I do not read the GPIO.

Rules
rule "Push"
  when
     Item Push changed
          then
               if (Push.state == OPEN) {
                 RaspiLED.sendCommand(ON) }
            else {
               RaspiLED.sendCommand(OFF) }
          end

The GPIO reading is proven

Regards

push is not the same as Push

excuxe me

Rules
    rule "push"
          when
               Item push changed
            then
                if (push.state == OPEN) {
               RaspiLED.sendCommand(ON) }
             else {
           RaspiLED.sendCommand(OFF) }
      end

It’s on like this, and it does not work either

Hi guys, I’ve done a clean installation and now if you read the gpio but the rule does not work because the led does not turn on

Put RaspiLED on your sitemap and see if you can control it manually.

Watch events.log to make sure that push is being updated.

Are you sure that push is going back to CLOSED? If not the rule isn’t firing.

Add logInfo statements to verify the rule is triggering.

Hi, thanks for replying.
RaspiLED manual works correctly

I attach the event.log

2016-11-25 19:31:43 - push state updated to CLOSED
2016-11-25 19:31:44 - push state updated to OPEN
2016-11-25 19:32:44 - push state updated to CLOSED
2016-11-25 19:32:44 - push state updated to OPEN
2016-11-25 19:34:02 - push state updated to CLOSED
2016-11-25 19:34:02 - push state updated to OPEN

Thanks

Home.rules

import org.openhab.binding.gpio-1.9.0-SNAPSHOT.*
import org.openhab.io.gpio-1.9.0-SNAPSHOT.*


    rule "push"
            when
           item push changed
        then
                if (push.state == OPEN) {
                 RaspiLED.sendCommand(ON) }
                  else {
                RaspiLED.sendCommand(OFF) }
            end

Is Good?

Sorry, in the event.log also says:

2016-11-25 20:11:41 - push state updated to Undefined
2016-11-25 20:11:41 - RaspiLED state updated to           Undefine