hello,
I would like to share with you my approach to interact with my verisure alarm system. It might not be the "easiest" and "cleanest" way but it is the only way i found.
Verisure in Spain is not under the
https://mypages.verisure.com/ websites, so i can not use the verisure API. In fact, verisure bought another alarm system in Spain and rebranded to versiure (
https://customers.securitasdirect.es/)
So... my approach, that you could also use to access data from any other website. I tried to use PhantomJS to access the web site, but i could not manage it, so what i did was to install iceweasel on my RPI, install imacros, record the macro i want to execute and then write a script to run the imacro. To run the scripts you need to open a vncserver terminal
The scripts is calling a html file that is running the imacro. The imacro writes a file with the expected result and then the scripts loops until the file is there
test.html
<meta http-equiv="refresh" content="0; url=imacros://run/?m=Securitas.iim" />
The scripts looks like:
#!/bin/bash
#running server?
vncserver=$(ps aux |grep "[X]tightvnc"|awk '{print $2}')
if [[ "$vncserver" != "" ]];then
kill $vncserver 2>/dev/null >/dev/null
fi
if [[ "$(ls -lah /tmp/.X99-lock 2>/dev/null >/dev/null)" ]];then
rm -rf /tmp/.X99-lock
fi
if [[ "$(ls /tmp/.X11-unix/X99 2>/dev/null >/dev/null)" ]];then
rm -rf /tmp/.X11-unix/X99
fi
#starting
vncserver -geometry 1024x768 :99 2>/dev/null >/dev/null &
#######
sleep 10
killall -9 iceweasel 2>/dev/null >/dev/null
rm -rf /tmp/estado.html
iceweasel --display :99 /home/pi/scripts/alarma/test.html 2>/dev/null >/dev/null &
count=0
while ! [[ -f /tmp/estado.html || count -ge 20 ]];do
sleep 10
#echo "Count: $count - Esperando..."
count=$(($count + 1))
done
sed -n 's/"Tu Alarma est. \(.*\)\"/\1/gp' /tmp/estado.html
#######
#finishing
ps aux |grep "[X]tightvnc :99"|awk '{print $2}'|xargs kill 2>/dev/null >/dev/null
Regards,
Nacho