Close

Adding timing to push-button

A project log for Smart Intercom

Real-Time system that allow to pass only authorized/invited people, using Face-Recognition or NFC cards.

evgheniiEvghenii 09/12/2017 at 12:150 Comments

In order to disable entrance in specific hours via push-button, i made the following  bash script:

#!/bin/bash

H=$(date +%H)
if (( 7 <= 10#$H && 10#$H < 19 )); then 
    echo between 7AM and 19PM
sh /home/pi/action.sh
elif (( 19 <= 10#$H && 10#$H < 7 )); then 
    echo between 19PM and 7AM
sh /home/pi/error.sh
else
    echo go to bed
fi

action.sh - opens the door between 7 am and 19 pm

error.sh - displays restriction image between 19 pm and 7 am

error.sh script

#!/bin/bash
DISPLAY=:0.0 XAUTHORITY=/home/pi/.Xauthority /usr/bin/feh --hide-pointer -x -q -D 5 -B black -F /home/pi/error.png &
ping -c 4 localhost 2>/dev/null
DISPLAY=:0.0 XAUTHORITY=/home/pi/.Xauthority xdotool key "x"

P.S to run this script you will need to install xdotool

sudo apt install xdotool

Discussions