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
#!/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