Securitas Direct (Verisure EU) Custom Component [TESTERS WANTED]

I have multiple account attached to my ID and i have been trying to get this component to work for me for a few months. I wanted to share what i found and what i got to work.

  1. Where there are mutiple accounts attached to your ID the first suggestion is to create a new user with admin access to the site which you are trying to access
  2. Login to verisure using the new ID created.
  3. Follow the above instructions suggested with custom_components and also with the config yaml.
  4. Restart Home Assistant and it shows no error. Find the alarm_control_panel and off you go

Overall this is better as if there are any problems with the alarm, you can see from the logs which user caused the issue, if any.

I have only had this operational for 24 hours and now i am trying to find out if the below is possible and if so how. Any help with this would be much appreciated

  1. See the state of individual sensors. Such as window/door closed or open
  2. Arm and disarm a secondary alarm only. I see Home Mode and Night Mode.
  3. Request images etc and send them as notifications in case of alarm being triggered.

Thank you

Ross

Hi Ross,

Unfortunately, this cannot be done. The Mobile API just allows to check the panel status, not the sensors. At the end youā€™re not interacting with the panel itself, just with the Securitas backend.

The Securitas backend just allows 5 kinds of arm/disarm operations:

  1. ARM: This means everything but the outside (perimeter sensors)
  2. PERI: This means just the perimeter.
  3. ARMNIGHT: Just those sensors that were configured as ā€œNight Modeā€ when the technician was setting up the pannel.
  4. ARMDAY: Just those sensors that were configured as ā€œDay Modeā€ when the technician was setting up the pannel.
  5. DISARM: This just disarms everything.

ARM, ARMDAY and ARMNIGHT are exclusive modes. You have either one or another.
PERI is optional and stand-alone, so you can arm this mode regardless of the state of ARM, ARMDAY or ARMNIGHT.
DISARM, as said, just disarms the whole thing, regardless of the states above. This means that you cannot actually for example go from PERI+ARMNIGHT to just PERI. You would need to disarm the whole thing and arm PERI again.

This can be done, but the code needs to be extended to fill that gap. I documented how to do it my API notes here:

https://github.com/Cebeerre/VerisureEUAPI

Iā€™m certain that @segalion will be more than happy if you fork his github repository and contribute extending the code to make that happen ! :wink:

Xavi

Thanks @Cebeerre

Itā€™s a shame they donā€™t send the specific sensors as these could really double up for so many other things. I appreciate you can only show what they allow us.

I actually have a ā€œsecondary alarmā€. See screenshot.

This is different to the night and day. I also wouldnā€™t mind being able to see the status. I am happy to do some testing if this hasnā€™t been looked at before?

Would love to work on the images and will reach @segalion as I start work.

Seek to have time on my hands now and running out of things to do now

Hi @jezzard,

I assume these should be the modes ARMANNEX and DARMANNEX, but I donā€™t have this ā€œSecondary Alarmā€, so I wasnā€™t able to test it while reverse engineering the App.

Given that they always operate the same way, I guess the same routines that work with ARM1-2, PERI1-2 would work for ARMANNEX.

You could try using @segalion code in the CLI, as he already prepared the code to send any available command. Something like:

$ ./securitas.py username password ARMANNEX GB
$ ./securitas.py username password DARMANNEX GB

And see what the pannel/app does ā€¦

If it works and from here on, the custom component will need to be extended to be aware of the new status code and therefore be able to check the alarm status through the logs.

Seems quite straight forward ā€¦

BR,
Xavi

I could test, i have a second alarm, but i havenā€™t understood what to doā€¦
i will try from CLI

Iā€™m trying to execute from CLI, but iā€™m not able.
In the CLI from the directory securitas_direct I run

$ ./securitas.py username password DARMANNEX IT

but I got

canā€™t execute python3

Hi Xavi,

I like a lot of people seem to have a lot of time on my hands at the moment so i am determined to get this working.

Is there a reference to @segalion code for this. I have tried a few variations, setting in the app etc but not getting very far at all.
Any advice would be welcomed

Cheers

Ross

Hi @finix77,

Try with:

$ python ./securitas.py username password DARMANNEX IT

Or check first if you have the python interpreter in your path:

$ which python

and

$ python

You should get something like:

Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Hope that helps,
Xavi

Hi @jezzard,

Yes, seems that your prime minister has changed his mind and has finally decided to take some lockdown measures ā€¦

As @finix77, Iā€™d try first to run the securitas.py in the component from the command line using the ANNEX stuff and see if the panel arms and disarms as expected.

If this works, some debugging will be needed to capture the status codes. Securitas uses IDs in the log to identify which mode is enabled. So in order to enable this in hass.io, this modes should be added up to the component using the proper status IDs.

Cheers,
Xavi

Hey @Cebeerre,

Still lokced down but a little further along.
Where do i need to look to set ARMANNEX and DARMANNEX from Home Assistant. I have looked in the custom component and can see they are listed under SC_ALARM but no idea from there. Can you or anyone point me in the right direction?

Thank you

Ross

Hi @jezzard,

All the tweaking should be done in the python script:

https://github.com/segalion/securitasdirect/blob/7df9338a8149f316353f40d0615ed10247eb0f6d/custom_components/securitas_direct/alarm_control_panel.py

As the securitas.py is just an API client.

Youā€™ll need to add the new states, actions and status codes. Not sure though, how the integration should be done to make it work with the alarm panel card, as Iā€™m not a hass.io user ā€¦

One of the important things you should do is understanding the status codes. As these are used to query the API logs and see the status of the alarm without asking the panel itself.

So, youā€™ll need to run the API client in the CLI and do something like:

$ ./verisure.py your_username your_password ARMANNEX

And check the output of:

./verisure.py your_username your_password ACT_V2

and look for status number. Then disarm:

./verisure.py your_username your_password DARMANNEX

At the end, you should be able to add a new status to this part of the code, so play arming in night mode, away, ā€¦ and see the logs in ACT_V2 to identify the codes you need:

SECURITAS_STATUS = {
    STATE_ALARM_DISARMED: ['0',("1","32")],
    STATE_ALARM_ARMED_HOME: ['P',("311","202")],
    STATE_ALARM_ARMED_NIGHT: [('Q','C'),("46",)],
    STATE_ALARM_ARMED_AWAY: [('1','A'),("2","31")],
    STATE_ALARM_ARMED_CUSTOM_BYPASS: ['3',('204',)],
    STATE_ALARM_TRIGGERED: ['???',('13','24')],
}

Hope that helps.
Xavi

Hey Xavi,

I am a lot further along and thank you for your help.
One thing i did struggle with was the manifest needed to be updated to xmltodict rather than xml2dict in case anyone else finds the same. I saw someone else was having issues.

So we have our codes!!! In case anyone else needs them and can help me with the next stepsā€¦ I know you do not use Home Assistant but i am hoping this gets someone else to pass me to the next step. Although i do have a lot of time to R and D at the moment :joy:

{
          "@alias": "Desarmado Anexo",
          "@type": "44",
          "@myverisureUser": "XX",
          "@device": "",
          "@source": "IPHONE",
          "@cost": "0",
          "@idsignal": "xx",
          "@time": "190409095629",
          "@img": "0",
          "@signaltype": "44"
        },
        {
          "@alias": "Armado Anexo",
          "@type": "43",
          "@myverisureUser": "XX",
          "@device": "",
          "@source": "IPHONE",
          "@cost": "0",
          "@idsignal": "XX",
          "@time": "190408200254",
          "@img": "0",
          "@signaltype": "43"
        },

So i take it we are working with 44 and 43?? As i did get a status response of ā€œ6ā€ when i armed it? Just mentioning as i havent checked firing back using the relevant codes.

In theory the last piece should be easy but my only experience with the alarm panel has been this project but i have done quite a bit with HA.

Thank you @Cebeerre for your support with this. If anyone can help fill the gaps i would really appreciate it.

The only things i need to finalise is the 1. images and 2. I did see when in the CLI we could also see which sensor triggered an alarm (i think) as in the act_v2 i saw lots of ā€œdevicesā€ which i can only assume are the sensors. The only reason i mention this is becuase earlier it was said the sensors could not be seen? Again any advice would bve really appreciated but i will continue to see what i can find.

Stay safe out there

Ross

Hi @jezzard !

Exactly, those are the status codes. But seems that your ā€œannexā€ alarm works completely standalone of the rest, as it actually uses a different status code for the disarmed state, which is 0.

Given that the current lovelace alarm panel card just allows 4 states:

and the arm_custom_bypass, is being used for the perimeter, my guess is that you either ask or extend yourself the alarm card to support more states, or ā€¦

you add another panel card, and deploy another instance of the custom component (tweaking the status codes) to treat your annex state as if it was just a completely separated alarm panel.

Does that make sense ?

Xavi

Thanks Xavi @Cebeerre

I think I will go with the custom second alarm panel. It seems the simplest option.

To add a second custom component do I need to give it another name or change references anywhere? For example change securitas_direct to securitas_direct_annexe and would I need to update these in any of the files?

Thanks. We will get there!!

Cheers

Ross

Update. I have the second panel in ha
The issue i am having now is getting it to sync with the correct alarm / annexe

Hi all, did you also get invalid config after upgrading to 0.108?

Indeed, I assume youā€™d need to change all the references from securitas_direct to securitas_direct_annexe in config.yaml, manifest.json and __init__.py, so the secondary alarm is actually a different Domain.

Hi all,
Like Fabien, it stopped working for me too from 0.108 with a brand new config:

Logger: homeassistant.setup
Source: custom_components/securitas_direct/securitas.py:114
First occurred: 6:59:02 PM (1 occurrences)
Last logged: 6:59:02 PM

Error during setup of component securitas_direct
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 175, in _async_setup_component
    component.setup, hass, processed_config  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/securitas_direct/__init__.py", line 64, in setup
    HUB.update_overview()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/securitas_direct/__init__.py", line 107, in update_overview
    self.overview = self.session.last_state()
  File "/config/custom_components/securitas_direct/securitas.py", line 114, in last_state
    if reg['@type'] in filter:
TypeError: string indices must be integers

Thanks

I just added this and itā€™s completely stopped HA working. It didnā€™t even reload the UI. I manually removed it from the configuration.yaml file and had to unplug my RPi and plug it in again. SSH command ha core restart gave an error but no info.

Iā€™d love to get this working. Iā€™m running HA 0.108.1

Thanks!

This is complaining as itā€™s not correctly reading the activity log from the backend ā€¦ try arming/disarming the alarm with the Mobile App or a remote that is being tracked (so there are logs on the backend) and try again.

Yes after removing alarm panel, restarting and adding it again it works again.