prepare to show live people counter value

py3
Level2 DoorBuzz 2016-01-25 23:30:15 +01:00
parent f82755bf20
commit ed85f9a89f
5 changed files with 63 additions and 1 deletions

View File

@ -13,7 +13,7 @@ how to install
sudo vi /etc/xdg/lxsession/LXDE/autostart sudo vi /etc/xdg/lxsession/LXDE/autostart
remove screensaver remove screensaver
sudo apt-get install unclutter xdotool git-core screen imagemagick sudo apt-get install unclutter xdotool git-core screen imagemagick x11-xserver-utils
git clone git://git.drogon.net/wiringPi git clone git://git.drogon.net/wiringPi
cd wiringPi cd wiringPi
./build ./build
@ -27,6 +27,7 @@ cat > /home/pi/.config/lxsession/LXDE/autostart <<"EOF"
@sudo python ./doorbuzz/setneocolor.py @sudo python ./doorbuzz/setneocolor.py
@./doorbuzz/buzzctrl.sh @./doorbuzz/buzzctrl.sh
@./doorbuzz/videoplayer.sh @./doorbuzz/videoplayer.sh
@./doorbuzz/arpspoofdetect.sh
@sudo python ./doorbuzz/shutdownbutton.py @sudo python ./doorbuzz/shutdownbutton.py
@./doorbuzz/phone_notification_client.sh @./doorbuzz/phone_notification_client.sh
EOF EOF

47
arpspoofdetect.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
# led is not neopixel, so use the python lib for that
BUTTONPIN=25
BUZZERURL="$(cat "$(dirname "$0")"/secret.txt)/state.xml?relay1State=2&pulseTime1=5"
BUZZERSTATUSURL="$(cat "$(dirname "$0")"/secret.txt)/state.xml"
ATTENUATION=4
# file secret.txt should contain username:password
cd $(dirname "$0")
showleds() {
./redi.sh <<EOF
neoaction=$1
neored=$2
neogreen=$3
neoblue=$4
neomorse=$5
EOF
}
pulseon() {
red=$1
green=$2
blue=$3
showleds pulse $((red/ATTENUATION)) $((green/ATTENUATION)) $((blue/ATTENUATION)) </dev/null >/dev/null 2>&1 &
echo $!
}
echo "Initializing hardware"
# the button
ledcolor() {
red=$1
green=$2
blue=$3
showleds set $((red/ATTENUATION)) $((green/ATTENUATION)) $((blue/ATTENUATION))
}
echo "Main loop"
while true
do
if [ $(arp -a | awk '{arp[$2]=$4;ip[$4]=ip[$4]" "$2}END{print ip[arp["(10.2.113.1)"]]}' | wc -w) -gt 1 ]
then
ledcolor 255 50 50
sleep 1
pulseon 255 255 255
sleep 60
fi
done

5
peoplecounter.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
wget -qO - http://10.2.113.6/output.cgi |
sed 's/.*Occupancy://'|
awk '{print $2}'

8
presency.py Normal file
View File

@ -0,0 +1,8 @@
# this gives number of people present via spaceapi
# but if network down, this does not work
# better get data direct from pidor or peoplecounter
import urllib, json
url = "https://spaceapi.syn2cat.lu/status/json"
response = urllib.urlopen(url);
data = json.loads(response.read())
print data["sensors"]["people_now_present"][0]["value"]

View File

@ -7,6 +7,7 @@ fi
killall feh killall feh
trap "killall feh; killall omxplayer" 1 2 3 15 trap "killall feh; killall omxplayer" 1 2 3 15
feh -F -x black.png & feh -F -x black.png &
#feh black.png &
while true while true
do do
if [ "$(python ./spacestatus.py)" = "False" ] if [ "$(python ./spacestatus.py)" = "False" ]