Remotely resetting gpio via openhab

  • Platform information:
    • Hardware: rpi 3b
    • OS: Openhabian
    • openHAB version:3.0.1
  • Issue of the topic: I’m on the road and I cannot access my server via ssh. I can vpn to my network but I don’t have ssh port forwarding setup. I need to be able to reset my remote gpio on my server to get some pumps working again. Does anyone have any idea how I might go about this? I can access my web portal on my pfsense firewall and openhab via myopenhab.

Could I create a thing using the exec binding to perform the reset?

If so how do I do this in OH3?

Thanks!!

Your question reminds me of an experience a former manager had.

Customer: We need the computer to do this for us.

Computer Guy: How do you do this now?

Customer: We don't know how. That is why we need toe computer to do this.

You need to figure out how to do what you desire from the command line before trying the exec binding. If this is important to you, show som eeffort by showing us what you tried and how it failed.

Ine las point? What problem are you trying to solve by resetting GPIO? There may be another way to accomplish the desired results.

How to ask a good question / Help Us Help You - Tutorials & Examples - openHAB Community

@Bruce_Osborne

I need to run this command with the exec binding.

systemctl restart pigpiod

I don’t have experience with GPIO on RPI but I would assume that sudo privileges are required to do so.
If that is the case you need to provide the openhab user sudo privileges for the exec binding. Without a shell you cannot do that.
You wrote you could get into your network via VPN why don’t you have access to ssh then ? Does it mean you restrict VPN access to a subset of ports ?

I asume that you also would require sudo privileges for this command, right ?
The exec binding requires an entry in the whitelist to allow the comand to be executed so you need to have write access to /etc/openhab/misc/exec.whitelist.
You may use executeCommandLine .

Thanks for the quick response. Yes I do have vpn access to my internal network. I didn’t get a chance to test the ports before I left. I just tested to be sure I could ping my openhab server before I left. I ran out of time to test it further. But I can get in and update my firewall port forwarding settings.

It sounds like I’ll need to setup a rule to gain access to ssh. I’ve done so in the past, I just need to figure it out again.

Yes you do need to run that with sudo.

I was hopeful there was a quicker work around as I’ve never used the exec binding before.

Thanks!!

since the exec binding does not have a shell or path (where is systemctl command located?) many people have more success placing the command in a shell script and executing that.

Thanks all for the comments and words of advice. I ended up enabling all ports on my VPN connection and was able to re enable the GPIO binding…

For anyone on the forum that stumbles across this post… I COULD have fixed the problem by following the advice listed on the GPIO binding wiki by simply disabled and enabling the GPIO binding within openhab. That said, it was still helpful having my VPN tunnel fixed.

Cheers!

So that was the original problem you needed to solve but neglected to state.