leosac / access-control

Leosac Access Control - Open Source Physical Access Control System
https://leosac.com
GNU Affero General Public License v3.0
240 stars 40 forks source link

Open door remotely #130

Closed jeremy-walker closed 3 years ago

jeremy-walker commented 3 years ago

I'm wondering if there is a way to remotely open a door via SSH or some other interface? The door is already configured in leosac and works perfectly fine with a proximity card.

jeremy-walker commented 3 years ago

Solution:

echo "1" > /sys/class/gpio/gpioN"/value

opens the door and

echo "1" > /sys/class/gpio/gpioN/value

closes the door. Replace N with the GPIO number used by the door. So a script like this could be used to open the door for a few seconds and then close it:

#!/bin/bash
# provide door gpio number as an argument

# make sure $1 is an integer
re='^[0-9]+$'
if ! [[ $1 =~ $re ]] ; then
   echo "Please specify door gpio number" >&2; exit 1
fi

# open the door
echo "1" > /sys/class/gpio/gpio"$1"/value

# wait for a couple of seconds
sleep 2s

# close the door
echo "0" > /sys/class/gpio/gpio"$1"/value