[NEEDS UPDATING] Raspberry Pi Relay Controller (WebIOPi)

I’m pretty sure that if there was any port being blocked you wouldn’t be able to access the page… and the display wouldn’t show and or you wouldn’t have a visual reaction to any selection on the web page itself. Only other thing I can think of would be to double check the GPIO # with the pin Number. ie GPIO #17 is pin 11.

Well you are right but that did the trick and it has happened before with other devices like the envisalink3 and roowifi of my DSC alarm panel and roomba the moment i added to my router and allowed the port it got back in the game from within the network always…i guess my router is strange.
Anyhow now i can control the relays beautifully with the webIOPi interface through the web browser (always with internet explorer and not chrome its is still non responsive on chrome) i can control the right relays and all of them are wired correctly… but there is still a problem i added the smartapp and the device handler to my IDE and have tried with the right settings on the mobile app such Ip address =192.168.1.96… port =8000… Hub = home …Relay switch = type of device …GPIO = 21 or 5 with my phone on the home wifi network but there is nothing happening to the relays no on no off no clicking no nothing.
The device on the app was added successfully but when you touch on and off there is nothing happening …any ideas???
the moment you fix something something else pops up LOL
Denis

Most likely the relays are all on - by default they are. Go to the web page (in IE) and change the state of one the relays you have added to the SmartApp. See if the state changes in the SmartApp. It should happen fairly quickly. If / when it does - try changing the relay state back with the SmartApp.

If it doesn’t work:

go the API panel and check your ‘My Devices’ section. You should see your 'Virtual Pi Relay’s. Then check their 'Network ID’s It may read as ‘piRelay.192.168.1.96.[your GPIO address]’
If your GPIO address is only listed once - then go back into the SmartApp where the config is and hit Done. (don’t make any changes). Refresh the Device list in the API panel… and your Network ID should show the GPIO address twice after the IP address. Then do the next step…

If it does work:

AKA only flips the relay to one state and not the other. Go the SmartApp in the API panel. Look at line 316 and change it from
def state = parts[6]
to
def state = parts[7]
Then after a Publish and a little time for the app to sync - see if it works.

The device Network id is as follows: piRelay.192.168.1.96.21.21

so twice the 21 gpio so do i go straight to the code and change line 316??

Yeah, that would be my next step.

I tried it changed line 316 to 7 from 6 but still no luck.
went back again and change line 315 from 5 to 6 and again no luck.
I did take my time to make sure that the app had the chance to sync but it did not fix the issue.
here is a screen shot of the log file is " the GET path is: /* "normal it just keeps saying that when trying to update the status

Trace Updating GPIO map
debug the GET path is: /*

at some point it showed this;

trace. Finished Getting GPIO State
debug. getChildDevices(false), children=1

whats next??
thank you

Hi there i am facing the same exact issue …how did you fix it/??
i would take any help i can get
thank you

There is an bug in the DH that causes the string sent to the Pi to be incorrectly formatted. This prevents the GPIOs operating correctly and is documented a long way up this thread. The issue is that it sends a 0 (off) to the Pi for both on and off. To test this you can try turning it on via the WebIOPi web browser. You can then see if it updates and can then turn off the GPIO via the app. Someone developed a temporary fix for it, also documented above.

The problem is that if you go back in and edit the GPIOs it changes the formatting of the string, which means the string formats correctly and the ‘fix’ I mentioned above no longer works.

I’m not seeing any return updates for the switches. Here’s what a full ‘transaction’ looks like for me:

56931fc5-76e5-4e70-ac46-bcf894918287 8:20:34 AM: trace Finished Getting GPIO State
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:34 AM: debug Updating switch Garage Door Right for GPIO 18 with value 1
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:34 AM: debug Updating switch Garage Door Left for GPIO 17 with value 0
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:34 AM: debug getChildDevices(false), children=2
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:34 AM: debug The GET path is: /*
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:34 AM: trace Updating GPIO map
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:31 AM: debug getChildDevices(false), children=2
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:31 AM: debug getChildDevices(false), children=2
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:30 AM: debug The POST path is: /GPIO/17/value/0
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:30 AM: debug Executing ‘setDeviceState’
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:30 AM: debug on
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:30 AM: debug piRelay.192.168.1.203.17.17.on
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:30 AM: debug Switch event!
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:30 AM: debug on
56931fc5-76e5-4e70-ac46-bcf894918287 8:20:30 AM: debug Switch event!

When you change the relay state from the web page in IE, do you see a state change / update in the SmartApp?

When you click the button in the SmartApp, it instantly changes it’s color. It’s waits for the return data from the Updating GPIO map call. Once that data is returned it updates the buttons accordingly in the SmartApp. It appears there may be some disconnect in the SmartApp/Hub connecting to the device.

In the Logs, you should have tab for the name given to the Device marked as GPIO 5 in the WebOIPi Manager.

After some time you should be getting numerous updates to it’s status and should look something like:

c4330ac3-c468-4d50-bebf-4b90ecf22c3e 8:29:04 AM: trace Received update that this switch is now 0
c4330ac3-c468-4d50-bebf-4b90ecf22c3e 8:29:03 AM: debug Executing ‘on’
c4330ac3-c468-4d50-bebf-4b90ecf22c3e 8:28:54 AM: trace Received update that this switch is now 1
c4330ac3-c468-4d50-bebf-4b90ecf22c3e 8:28:44 AM: trace Received update that this switch is now 1
c4330ac3-c468-4d50-bebf-4b90ecf22c3e 8:28:34 AM: trace Received update that this switch is now 1
c4330ac3-c468-4d50-bebf-4b90ecf22c3e 8:28:24 AM: trace Received update that this switch is now 1
c4330ac3-c468-4d50-bebf-4b90ecf22c3e 8:28:14 AM: trace Received update that this switch is now 1
c4330ac3-c468-4d50-bebf-4b90ecf22c3e 8:28:05 AM: trace Received update that this switch is now 1
c4330ac3-c468-4d50-bebf-4b90ecf22c3e 8:27:54 AM: trace Received update that this switch is now 1

I kept googling and trying solutions recommended on various forums. It’s
been months, so I don’t remember exactly what worked. I believe there is
a bug in the code that was a very simple fix. I’ll try to remember and
reply again.

Have you visited here:
https://groups.google.com/forum/#!topic/webiopi/RGtrRfFJMKY

Scott

The ‘temporary fix’ continues to work for me and has persisted through device changes.
default parts are:

piRelay.192.168.1.96.21.[on/off]

That is after the initial setup of the device.
If you go back into the devices and save, the parts are changed to:

piRelay.192.168.1.96.21.21.[on/off]

I have not changed the

def GPIO = parts[5];

But have changed

def state = parts[7];

Once adding a device, and selecting Done, you just have to make sure to go back in to your device list and select Done again to update the new device added to the format.

The point in which it is adding the second GPIO entry to the device Network ID it at line 181

theDevice.deviceNetworkId = theDeviceNetworkId + “.” + deviceConfig

The + "." + deviceConfig part is where it is adding it. If you comment that section out and publish the app … Selecting Done in the Device LIst will remove the duplicated GPIO entry in the Network ID.
But if you have changed line 316 this will no longer work and line 316 will have to be set back to default as [6]

This seems to work as well, but am unsure as to why the GPIO ID was added a second time if the device already exists.

I just got home and its 11:40 Dallas time but
when i change the status of the GPIO though IE webIOpi interface there is nothing showing on the Log files of the ST IDE whether at the webIOpi smartapp or the device which in my case is named Test 1. So yes there is that “disconnect” somewhere between the webIOpi and ST here is what the Log file for Test 1 looks like … no recived updates
I’ll look into the details of the changes that you have mentioned tomorrow and report back

thank you

From the looks of your device log, changing any of those settings won’t help.

It looks like your STHub isn’t able to communicate with your Pi.
Did you remove the password requirement for the WebIOPi?
Can you ping your STHub from the Pi?
In this setup, the STHub communicates directly with the Pi over the local network - and with out being able to do that - you won’t be able to get an update status or be able to send commands

Oh no i havent removed the password from webIOpi no its still the default admin and raspberry …how do i do that ??

Ok so my other question after removing the user name and password of the webIOpi is can i go into the smartapp code after adding my all my 5 relays and hard code the variables or just plainly copy yours and change the IP etc??? i am sorry i don’t know many of the details of writing code just brainstorming out loud

Delete the contents of /etc/webiopi/passwd

You wouldn’t want to try to hard code the variables, it would remove the ability to easily add/remove devices in the future.

hahah progress has been made… i got the two to connect the webIOpi and the ST however i can turn the relays ON from the ST smartapp but i can not turn them OFF. and when i go and turn them off through the webIOPi they report back to the smartthings app as ON.
So the opposite is happening in other words, or only one state is being passed.

1-Right now the actual physical relays are all OFF but in Smartthings app they are being reported as all ON(green)
2-If i click on the ST app the status will go OFF(white) but the physical relays will go ON
3-If i click again the on/off on the ST app nothing will happen

This is whats being reported obviously all on when they are off

step by step we are getting there :slight_smile: :slight_smile:

So what should we do next ???

Have a great night and thank you
Denis

ps. Sorry for the late and infrequent replies but i am gone all day i run my own business and it is demanding as hell very unrelated to what we are doing here.

Yeah, same thing was happening to me - so changed a couple of things…

Hi All,

Just an update to share my mod: add fixes, user/pwd (Tx guys), polling time and contact sensor capability. :wink:

Let you try.
Kall

1 Like

Hi, I’ve almost everything working with this script , my only problem is that button are inverted. in the smartthings app buttons are ON but relays are OFF, if I turn the button to OFF, relays turn ON, same thing in the GPIO List, Pin numbers show ON (orange) but relays are OFF, switching them to OFF (Black) relays turns ON.

Anyone with the same problem?