[NEEDS UPDATING] Raspberry Pi Relay Controller (WebIOPi)

Tom,

I did use @mparentes solution and although it is a little better it is still hit and miss. I refreshed everything and the first GPIO worked. It sends a 1 or 0 when it is supposed to. I then went back in an added a second and that one does not work. It sends 0 for both on an off.

I have noticed the following in the debug after a switch event for each GPIO

piRelay.192.168.0.8.17.on
piRelay.192.168.0.8.2.2.on

piRelay.192.168.0.8.17.off
piRelay.192.168.0.8.2.2.off

This is what is causing the issue. Implementing @mparentes fix shifts the parse along so it picks up the ones that format with the GPIO twice, but breaks it when it formats correctly. It seems that when you create a GPIO it does not work, but if you then go back in an edit it (say change the name) it then works.

Hi Tom,

Thanks for all your hard work on this project - Very cool stuff.
Iā€™m using a Version 3 Raspberry Pi which seems to be doing my head in.

For starters, WebIOPi didnā€™t work. I have resolved that by following instructions here:

Iā€™ve added the GPIOs to the WebIOPi config, so on boot of the Raspberry Pi the two Relays I am using move into an open state.
I am still having no luck getting SmartThings to trigger a relay state change.

I assume there is something in the SmartThings code that you created referencing the GPIO port addresses that would need to be updated for the new Raspberry Pi? My coding skills are not good enough to figure this one out :slight_smile:

Hopefully youā€™re able to help :smiley:

Cam

@iBeech
Nudge nudge :smile:

It shouldnā€™t be a problem using Raspberry Pi Zero right ?
I imagined to build kind-of IR blaster using raspberry to control any kind of device with IR control
How about that ?

Has anyone been able to modify this to support contact sensors or motion sensors? Iā€™ve been able to hack through it a bit, and am able to get it to change the GPIO mode to input. It gets the correct response back for the state of the sensors 1=active 0=inactive, but I cannot get the state to change on the mobile app. Any pointers?

Can you elaborate on #2? Is that 1 WebIOPI, or can I only have one smartApp which makes API calls on the local network? Do you have any documentation pointers?

Question. I installed this and sort of got it working. I have a raspberry PI configured to open and close my garage. I added the relay controller to smart things. I can successfully click On and the relay opens up my garage. To close my garage I have to click off and then On again. Is there a way to have it read the current state and literally just open and close it with a single button?

Tom - any way to get some of your time to stabilize this for a raspberry pi garage door opener? It works, just not consistently.

Got this installed yesterday and so far it works great to control the pins. The only issue i have is if the pi reboots, the service doesnt start automatically, so i have to SSH in and start the service. It restarts every night (something i need to change but am having trouble finding the file i edited to make that happen - im still a ubuntu noob), so i had to manually start the service this morning. Any thoughts?

well i added the command to start the service to the crontab file so it starts the service at reboot. i might have skipped a step at setup, but that seems to be resolved now. so far it works awesome!

Good job- sorry i havent been active in the discussion :slight_smile: From what I remember, there is a limitation in smartthings which made it difficult to support multiple Pis on the local network.

ok, i suppose that makes sense. im still working on the Pi with 8 relays connected. I had it configured, but it seems like the high/low signals werent working right, the relays would come on when it said in the app they were off. i thought it might have been an issue with my install, so i removed the virtual buttons and then uninstalled the device handler, but i couldnt uninstall the smartapp, i get an error every time:

This SmartApp canā€™t be deleted at this time because it is installed by one or more users

i dont have any buttons that i can find in the smart app, i just want to remove and reinstall it. any advice?

There is a known issue where if the state of the relay changes outside smartthings, smartthings may take a while to update the state of the relayā€¦ if it does at all. Receiving events is not something the system is good at.

To uninstall, my advice is to go into the smart app, comment out line 136 -> 150 with a // at the beginning of each line. like this:

//subscribe(location, null, response, [filterEvents:false])

//updateVirtualRelay(deviceName1, deviceType1, deviceConfig1);
//updateVirtualRelay(deviceName2, deviceType2, deviceConfig2);    
//updateVirtualRelay(deviceName3, deviceType3, deviceConfig3);
//updateVirtualRelay(deviceName4, deviceType4, deviceConfig4);
//updateVirtualRelay(deviceName5, deviceType5, deviceConfig5);
//updateVirtualRelay(deviceName6, deviceType6, deviceConfig6);
//updateVirtualRelay(deviceName7, deviceType7, deviceConfig7);
//updateVirtualRelay(deviceName8, deviceType8, deviceConfig8);
//updateVirtualRelay(deviceName9, deviceType9, deviceConfig9);
//updateVirtualRelay(deviceName10, deviceType10, deviceConfig10);

//device.network
//updateGPIOState();

Hit ā€˜Saveā€™ then 'Publishā€™
Open the smartapp, open
Hit ā€˜Doneā€™

You should now be able to remove the devices / smartapp

Remove the comments from the smart app then save / publish again :slight_smile:

awesome, thanks a bunch! ill try to do that on lunch, its a busy morning at work! ill let you know how it works.

another question, how quick is the response? This is going to control relays that turn on and off pumps that are dispensing beverages. it doesnt need to be to the millisecond, but i would like to be able to turn the button on to start the pump then stop it close to when i hit the button (ideally within half of a second), since its pouring bourbon or coke or some other delicious beverage.

well, hot dogā€¦ iā€™d like to see this in action!

The response time is pretty quick, within your tolerance :slight_smile:

thanks! Ill try and get a new video of it working once i get this working and smarttiles configured.

this is what lines 134-150 look like in my app, its not the same as what you have above:

** setupVirtualRelay(deviceName10, deviceType10, deviceConfig10);
}

def updated() {
log.debug ā€œUpdated with settings: ${settings}ā€

updateGPIOState();
unsubscribe();

updateVirtualRelay(deviceName1, deviceType1, deviceConfig1);
updateVirtualRelay(deviceName2, deviceType2, deviceConfig2);    
updateVirtualRelay(deviceName3, deviceType3, deviceConfig3);
updateVirtualRelay(deviceName4, deviceType4, deviceConfig4);
updateVirtualRelay(deviceName5, deviceType5, deviceConfig5);
updateVirtualRelay(deviceName6, deviceType6, deviceConfig6);

**

it looks like 125-136 are a match for most of the code you say to comment out, then " updateGPIOState();" is line 142. i dont see ā€œdevice.networkā€ anywhere in the code. Maybe i have an old version of the app? This is the section that mostly matches:

subscribe(location, null, response, [filterEvents:false])    

setupVirtualRelay(deviceName1, deviceType1, deviceConfig1);
setupVirtualRelay(deviceName2, deviceType2, deviceConfig2);
setupVirtualRelay(deviceName3, deviceType3, deviceConfig3);
setupVirtualRelay(deviceName4, deviceType4, deviceConfig4);
setupVirtualRelay(deviceName5, deviceType5, deviceConfig5);
setupVirtualRelay(deviceName6, deviceType6, deviceConfig6);
setupVirtualRelay(deviceName7, deviceType7, deviceConfig7);
setupVirtualRelay(deviceName8, deviceType8, deviceConfig8);
setupVirtualRelay(deviceName9, deviceType9, deviceConfig9);
setupVirtualRelay(deviceName10, deviceType10, deviceConfig10);

}

i guess ill comment those and 142 out and follow the rest of the steps. Can you confirm the page with the current code? I got this from here:

thanks again for the help! i really appreciate it!

1 Like

i removed the app from the ST app, added it again and added my Pi. It seems to add fine, but i cant add any devices. Im assuming this is because im not at home, so it cant find the IP? I might have to wait until i get home to do more work on this if thats the case, but at least i feel like im back on track

Make sure you uncomment those lines :slight_smile: based on the source from git, youā€™d want to comment out 145-156

Itā€™s the updated method which will get run when you hit ā€˜Doneā€™ in the smartapp. Not re-subscribing will make sure its not linked to the children.

I must be missing something. I commented the lines you said in your last post, saved, published for me, then from the app i removed the smart app. i uncommented, saved again, published again, installed the app. i configured it with the LAN IP of my pi, port 8000 on my only hub. when i touch Done, it looks like it installs it fine, it shows up under my smartapps in the automation tab of the app. Then when i try to add a button, i just get an error saying ā€œError Saving Pageā€

I can remote to my laptop at home and hit the gpio-list page, and i see the tile change color when i toggle the relay, so that all seems to be working fine. but when i add a button in the smart app i just get that generic error, no matter which GPIO pin i use. I dont know what im missing, but i feel like im close and its probably something simple.

Looks like a big part of it was user error. Not sure how, but i must have screwed something up when i installed the device handler. I removed that and the smartapp and then installed them new in the IDE. now i can add devices and control the pins, but when the pin is off, the button in the app shows as ON. so when i turn the button OFF, the pin goes ON. there is also sometimes an issue where when i toggle the button back to on (to turn the pin off), it doesnt respond so i have to SSH to the pi and run a script to shut off that pin. but it doesnt affect every pin. and i have a bunch of scripts tied to specific pins that id rather not move that relay to another pin and rewrite the scripts. any ideas? sorry for all the questions today, but i really do appreciate the help!