[NEEDS UPDATING] Raspberry Pi Relay Controller (WebIOPi)

Cool project here. I have most of it working, but one issue stumps me. When I use the app to run on a relay it goes green for on and then goes off immediately. Monitoring WebIOPi via the web interface shows no state change. If I change the state of a GPIO using the WebIOPi web interface it changes and then shows as changed on the app. I had a look at the debug output form WebIOPOi and it seems that the app only sends an off command for both off and on.

The following is the debug output form an on/off/on/off sequence on the app.

2016-04-01 15:46:38 - HTTP - DEBUG - “POST /GPIO/2/function/OUT HTTP/1.1” - 200 OK (Client: 192.168.0.32 <Linux UPnP/1.0 SmartThings>)
2016-04-01 15:46:38 - HTTP - DEBUG - “POST /GPIO/2/value/0 HTTP/1.1” - 200 OK (Client: 192.168.0.32 <Linux UPnP/1.0 SmartThings>)
2016-04-01 15:46:40 - HTTP - DEBUG - “POST /GPIO/2/function/OUT HTTP/1.1” - 200 OK (Client: 192.168.0.32 <Linux UPnP/1.0 SmartThings>)
2016-04-01 15:46:40 - HTTP - DEBUG - “POST /GPIO/2/value/0 HTTP/1.1” - 200 OK (Client: 192.168.0.32 <Linux UPnP/1.0 SmartThings>)
2016-04-01 15:46:41 - HTTP - DEBUG - “POST /GPIO/2/function/OUT HTTP/1.1” - 200 OK (Client: 192.168.0.32 <Linux UPnP/1.0 SmartThings>)
2016-04-01 15:46:42 - HTTP - DEBUG - “POST /GPIO/2/value/0 HTTP/1.1” - 200 OK (Client: 192.168.0.32 <Linux UPnP/1.0 SmartThings>)
2016-04-01 15:46:43 - HTTP - DEBUG - “POST /GPIO/2/function/OUT HTTP/1.1” - 200 OK (Client: 192.168.0.32 <Linux UPnP/1.0 SmartThings>)
2016-04-01 15:46:43 - HTTP - DEBUG - “POST /GPIO/2/value/0 HTTP/1.1” - 200 OK (Client: 192.168.0.32 <Linux UPnP/1.0 SmartThings>)

Ideas?

I think I am a little closer. For some reason “state” is picking up the GPIO number instead of “on” or “off” which forces the logic to always append the post path with a zero. I also notice than the GPIO number seems to have been added twice to the DeviceNetworkId e.g. piRelay.192.168.0.8.2.2.on. This messes up the parts routine which causing part[6] to return a “2” instead of “on”

Im running into an issue i can only get the pin to to turn on via the smartthings app. When i try to turn off the gpio pin nothing happens. i have attached some of the logs. im a noob so any help would be helpful.


I assum you set the pin to output first. You have to do this before you can turn it on and off

1 Like

I didnt at first, thanks for the tip. But i am still having problems. the state updates if i use the web interface to control the pi but from the app im not able to control the pins.

im running into an issue that the smartthings app will pull the states on and off and will turn the pin on but will not turn off the pin. Any ideas?

ooops it will turn off the pin but wont turn it on

That looks to be the same issue I have. The state command picks up a 2 instead of on or off which always evaluates to an off action. If you turn the pin on via the web app you can turn off via ST, but new er turn it on. If you watch the debug as you try to turn on via ST you see that switch is 0 every time.

Do i need to install virtualpi relay also as it has errors (No signature of method: script). I am putting it as code as a new smartapp. line 48 has switch spelt wrong. still no install as app
The Weboipimanager seems to install fine.

sounds like you are trying to install a device type as a smartapp. Install it as a device type instead.

Thank you.
First day with this so i didn’t see the different code

I am also having the same issue. I can turn the relay off from the smartapp, but the on switch never works. Any idea?

ps. The relay does work fine when I change the state from WebIOPi frontend.

I found the problem that was preventing the switch to turn on.

I changed the lines 315 and 316. The index didn’t match with what I saw in the logs:

[piRelay, 192, 168, 1, 108, 17, 17, off]

adding 1 to the each index seems to have fixed the problem. My code looks like this now:

def GPIO = parts[6];
def state = parts[7];

Hope it helps!!!

2 Likes

Thanks for those edits. It is certainly better now. Not 100% thought as there is still something funny going on. It seems to vary depending on first creating the devices in the app or going back and adding additional ones. I also think that having two instances of the GPIO pin in that string [piRelay, 192, 168, 1, 108, 17, 17, off] is part of the problem. In that string you have “device type, IP address, GPIO pin, GPIO pin, action”. ?

Does this send a steady signal to relay or a timed signal (on 1 second,off)? It seems to lock up my garage door opener and then hub gives me network errors when I have it activate the relay…
My system only needs a button push and release.
Thanks

The way its programmed by default is an ‘on’ or ‘off’ function. I think you would need to add some code to make it a momentary action.

1 Like

Hi all, sorry i havent been very active. I’ve been very busy at work, and just moved home. I’ll try to review everything that has been posted and see where things are up to.

Thanks Tom!

Tom, Any news?

OK, so I’m going to whip out my raspberry pi this weekend and get it back online. There are a couple of issues which I can see:

  1. We struggle to pick up changes from WebIOPi due to the scheduling issues in SmartThings
  2. Having more than 1 WebIOPi does not work, due to the way that messages are received on the local network to smartthings.
  3. Looks like there was a problem with the index numbers used to parse out the request information. @slwilson, have you tried @mparentes solution? If so i can get this fix in ASAP.