Verisure alarm status into Domoticz

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.
Post Reply
alfred_j_kwak
Posts: 253
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi
Domoticz version: 2.3530
Location: Finland
Contact:

Verisure alarm status into Domoticz

Post by alfred_j_kwak » Saturday 28 November 2015 19:18

Hi,

I just made small hack. I have Verisure home alarm system and I'd like to switch lights off when I activate alarm.
I buy couple of Smart Plugs.

Image

Inside plug there is relay - just like in all remote control plugs(?) - I open plug, desolder circuit board, cut power contacts from relay to get voltage free contact and add Nexa WBT-912 inside plug. I connect plug relay into Nexa S1 input and now I have my alarm status in Domoticz.

Image

Would have been easier just add 230VAC relay into plug power socket and connect relay contacts into Nexa, but now everything is inside nice package - no hanging wires all around (wife approval factor...)

hansrune
Posts: 73
Joined: Monday 07 October 2013 10:51
Target OS: Raspberry Pi
Domoticz version:
Contact:

Verisure alarm status into Domoticz

Post by hansrune » Saturday 28 November 2015 22:18

I do similar. I have two verisure smartplugs. One on my primary wifi router, one on my guest wifi router. The guest goes off on verisure 'arm home' . They are both off on 'arm away' . I want them off when we are not home, and a 3rd cabled router takes care of the
Internet link. I use a LUA script to ping the wifi routers every minute and update Domoticz security state accordingly . So I never have to deal with Domoticz security state other than via the Verisure panels.
... and no hardware modifications needed!

alfred_j_kwak
Posts: 253
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Verisure alarm status into Domoticz

Post by alfred_j_kwak » Sunday 29 November 2015 0:10

Hah. Creative thinking. I just go with Dremel...

One nice feature in my application is that when I open front door and alarm is on the Smart Plug goes on and Domoticz turns lights on in hallway.

nizaga
Posts: 106
Joined: Monday 30 November 2015 12:36
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by nizaga » Monday 30 November 2015 12:39

Hi,

Could you please post the LUA scripts to access the verisure alarm? I am quite new to this and it would really help!

Thanks!

Nacho

hansrune
Posts: 73
Joined: Monday 07 October 2013 10:51
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by hansrune » Sunday 06 December 2015 18:59

Sorry for not responding before.... My setup using wireless routers controlled by Verisure smartplugs is a based on a LUA script and a helper ping script.

You will have to adjust the helper script or supply the following as command line arguments in the LUA script:
  • Argument 1 or TESTIP - is the router controlled by arm away smartplug
  • Argument 2 or LOCALIP - is another IP adress that is always on. This is used to differentiate router off versus link problems on your Domoticz system
Helper script /usr/local/bin/ping2test:

Code: Select all

#!/bin/bash
#
PROG=$( basename $0 ) 
TESTIP=${1:-"192.168.1.4"}
LOCALIP=${2:-"192.168.1.1"}
DBGPRINT=${DBGPRINT:-":"}
DBGPRINT=${DBGPRINT:-"logger -t ${PROG} -p user.debug"}
LOGINF=${LOGINF:-"logger -t ${PROG} -p user.info"}
LOGERR=${LOGERR:-"logger -t ${PROG} -p user.error"}
#

function pingip {
        local loss=$( ping -w 3 -qc 3 "$1" 2>&1 | sed -ne 's/.*, \([0-9][0-9]*\)% packet loss.*/\1/p' )
        ${DBGPRINT} "Ping to $1 has $loss % loss" >&2
        [[ "$loss" = 100 ]] && return 1
        return 0
}

if pingip ${TESTIP}
then
        ${DBGPRINT} "Can ping ${TESTIP}" >&2
        RC=0
elif pingip ${LOCALIP}
then
        ${DBGPRINT} "Can't ping ${TESTIP} and ping ${LOCALIP} indicates local link ok" >&2
        RC=1
else
        ${DBGPRINT} "Can't ping ${TESTIP} nor ${LOCALIP}" >&2
        RC=0
fi
exit $RC
The second part is the LUA script to change security state accordingly:

Code: Select all

--
-- $Id: script_time_alarm.lua,v 1.1 2014/11/06 20:12:01 pi Exp $ 
-- Ping test IP and use gateway as fallback / link test 
--
debug = false
logging = true
device  = "Husalarm"
oldstate = otherdevices[device]
secstate = globalvariables["Security"]

-- for i, v in pairs(otherdevices_svalues) do print("Idx=" ..  i .. " svalue=" .. v .. "<--") end
-- for i, v in pairs(otherdevices) do print("Idx=" ..  i .. " otherdevice=" .. v .. "<--") end

function lprint(cond, s)
        if (cond) then print(s) end
end

commandArray = {}
if ( oldstate == nil ) then
        lprint(logging, "Giving up: Cannot get security state via device " .. device)
        return commandArray
end
ping_success=os.execute('/usr/local/bin/ping2test')
-- ping_success=false
if ping_success then
        newstate="Disarm"
        lprint(debug, "ping2test success. State for " .. device .. " is " .. oldstate .. "-->" .. newstate) 
else
        newstate="Arm Away"
        lprint(debug, "ping2test failure. State for " .. device .. " is " .. oldstate .. "-->" .. newstate)
end

if ( newstate == "Arm Away" and secstate ~= "Armed Away" )
then
        commandArray[device] = newstate
        lprint(logging,"change " .. device .. "=" .. oldstate .. " and  secstate=" .. secstate .. " to " .. newstate ) 
elseif ( newstate == "Disarm" and secstate == "Armed Away" )
then
        commandArray[device] = newstate
        lprint(logging, "change " .. device .. "=" .. oldstate .. " and  secstate=" .. secstate .. " to " .. newstate ) 
else
        lprint(debug,"No change needed for " .. device .. "=" .. oldstate .. " and secstate=" .. secstate .. " to " .. newstate)
end

return commandArray

nizaga
Posts: 106
Joined: Monday 30 November 2015 12:36
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by nizaga » Thursday 24 December 2015 12:35

thank you very much for the scripts!

do you have any scripts to access the Verisure customers website and interact with your alarm system?

Regards,

Nacho

hansrune
Posts: 73
Joined: Monday 07 October 2013 10:51
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by hansrune » Thursday 24 December 2015 16:28

Sorry. I do not. Tried sometime back to ask for verisure APIs, but that was negative.


Sent from my iPad using Tapatalk

alfred_j_kwak
Posts: 253
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Verisure alarm status into Domoticz

Post by alfred_j_kwak » Thursday 07 January 2016 18:18

I just tested Python script to get Verisure status: http://www.domoticz.com/forum/viewtopic ... 737#p68732
Downside is that it only works if there is internet connection.

nizaga
Posts: 106
Joined: Monday 30 November 2015 12:36
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by nizaga » Monday 18 January 2016 21:07

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

alfred_j_kwak
Posts: 253
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Verisure alarm status into Domoticz

Post by alfred_j_kwak » Monday 18 January 2016 23:02

So many ways :)
I just noticed that some of recent updates add new notifications to Android Verisure app. Before, when you alarm/disalarm, app only gives Verisure notification - now it says that alarm is armed or disarmed and shows who has activate event. This makes it possible to use Tasker in Android to check notification text and trigger url to update Domoticz info.

fritz
Posts: 2
Joined: Wednesday 23 September 2015 23:03
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by fritz » Tuesday 01 March 2016 11:49

Hi @nizaga, Does your macro keep logged into securitas' web page or do you login with some frequency to check the status? Can you share some more of how you have done this? I am also in Spain.

nizaga
Posts: 106
Joined: Monday 30 November 2015 12:36
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by nizaga » Tuesday 01 March 2016 21:33

hi, i only access the verisure website whenever i want to enable / disable my alarm.

You can add a IFTTT rule base on Geolocalization and tell domoticz to run the script whenever you are approaching / exiting your area.

The macro is developed using imacros and i installed weasel in RPI.

The tricky part is to run the imacro, using vncserver. You have the scripts added to my previous comment.

Regards,

Nacho

fritz
Posts: 2
Joined: Wednesday 23 September 2015 23:03
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by fritz » Wednesday 02 March 2016 0:31

Thanks Nacho!

nizaga
Posts: 106
Joined: Monday 30 November 2015 12:36
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by nizaga » Wednesday 02 March 2016 14:02

hi fritz, let me know if it is working on your side. the script i posted was to check the status, you can change it and the imacro to activate / deactivate the alarm.

nacho

IvovanTulden
Posts: 1
Joined: Friday 16 February 2018 19:53
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Verisure alarm status into Domoticz

Post by IvovanTulden » Friday 16 February 2018 19:59

Thank you for the post and the great idea.
I have a question about the 2-channel transmitter you just, nexa wbt-912.
This looks like a local product from Finland, do you think it is possible to use a qubino for this also?

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests