Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with GPIO Pin Permissions #23

Open
simonrb2000 opened this issue Feb 12, 2017 · 3 comments
Open

Help with GPIO Pin Permissions #23

simonrb2000 opened this issue Feb 12, 2017 · 3 comments

Comments

@simonrb2000
Copy link

simonrb2000 commented Feb 12, 2017

Hi all, I think I know what the problem is but can't seem to find a way to fix it.

I don't think I have permissions and I don't think I run Homebridge as root. When I try to the accessories don't show up. So when I try to open my garage door I get this error

[2/12/2017, 8:32:50 PM] Homebridge is running on port 51929.
[2/12/2017, 8:32:54 PM] [Garage Door] GarageDoor is CLOSED (1)
[2/12/2017, 8:33:02 PM] [Garage Door] GarageDoor is CLOSED (1)
[2/12/2017, 8:33:02 PM] [Garage Door] Setting state to 0
[2/12/2017, 8:33:02 PM] [Garage Door] Triggering GarageDoor Relay
fs.js:549
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EACCES: permission denied, open '/sys/class/gpio/gpio4/value'
    at Error (native)
    at Object.fs.openSync (fs.js:549:18)
    at Object.fs.writeFileSync (fs.js:1155:15)
    at Object.RaspPiGPIOGarageDoorAccessory.setState (/usr/local/lib/node_modules/homebridge-rasppi-gpio-garagedoor/index.js:103:12)
    at emitMany (events.js:108:13)
    at emit (events.js:182:7)
    at Characteristic.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:155:10)
    at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:727:22)
    at Array.forEach (native)
    at Bridge.Accessory._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:672:8)
    at emitMany (events.js:108:13)
    at HAPServer.emit (events.js:182:7)
    at HAPServer._handleCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:967:10)
    at HAPServer.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:204:39)
    at emitNone (events.js:67:13)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:893:12)
    at doNTCallback2 (node.js:429:9)
    at process._tickCallback (node.js:343:17)

If I run these commands at terminal gpio export 14 in & gpio export 4 out BEFORE I try to open the garage then all works as expected. Unfortunately sometimes my Pi restarts then when someone tries to open the garage door the above error happens. I have made a script with the above commands in and if I run that from terminal then it all works. I just can't find a way to run said script automatically at boot up. I have tried various ways, including the crontab. Any ideas?

Cheers!!!

@benlamonica
Copy link
Owner

benlamonica commented Feb 13, 2017 via email

@simonrb2000
Copy link
Author

I am using systemd to start it with a homebridge.service script. I can add it to that? It's the default way to do it as shown on the wiki.

Cheers!

@Kulen01
Copy link

Kulen01 commented May 9, 2018

You need to add the homebridge user you created for the systemd startup to the gpio group.

usermod -a -G gpio homebridge to add the homebridge user to the gpio group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants