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

@fabtget51+@Cebeere Thanks a lot to you both guys, it now works again :sweat_smile:

Sorry about no connection here since a few months. I have been working in other projects, and have this a little abandoned.

Yesterday I updated HA to 108 (from more than 4 months old) and experienced same problem reported, so I have merged the PR from jmservera.

Thanks for all people supporting this, specially @Cebeerre (author of RE mobile API), answering some questions and helping here.

Although I don’t have time yet, I’ll try to be more attentive here.

Thanks.

2 Likes

Hey Xavi @Cebeerre,

I am getting closer and feel i am only missign something very small now.
Everything is showing as setup but i cannot get it to actually interact with the alarm itself.

As mentioned. Anywhere in the second custom component i saw securitas_direct i changed it to securitas_direct_garage and finally in the alarm_control_panel.py i changed the following to;

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

Now within Home Assistant if i try and set the alarm to ARM AWAY on the alarm control panel on lovelace it just shows the below and doesnt actually do anything.

image

and then returns back to

image

which is where is started. I know i am so very close but i cannot for the life of me work this out. Can anyone out there think of anything obvious i am missing?

Cheers

Ross

Since I uploaded last securitas.py version I am constantly getting the below error. Any idea ?

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  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/alarm_control_panel.py", line 124, in update
    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 111, in last_state
    regs= res['PET']['LIST']['REG']
KeyError: 'REG'

Which version of HA are you using? I think this may be a known issue with 1.08 noted above?

Hi Ross @jezzard ,

I’d say that in your case you can just actually add your status codes to the armed/disarmed tuples:

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

Cheers,
Xavi

Thanks Xavi,

I tried your selection and this actiavted my main alarm which is on its own components. Could that be becuase we are still showing statuses which reflect the main alarm? Are we able to jiust remove the statuses not required when the alarm is on its own component? I am guessing now as i can feel how close it is

Cheers

Uops ! Sorry @jezzard , I forgot that you’ll need to change in the alarm_control_panel.py all the references from ARM to ARMANNEX and DARM to DARMANNEX

or probably easier (less work), change just the PERI to ARMANNEX and then:

SECURITAS_STATUS = {
    STATE_ALARM_DISARMED: ['0',("1","32","44")],
    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',('43',)],
    STATE_ALARM_TRIGGERED: ['???',('13','24')],
}

@jezzard forgot what I said, you need to send the DARMANNEX action to the API (as DARM does nothing on your annex alarm), so you’ll need to follow my first recommendation …

XAVI WE’VE DONE IT!!
Thank you so much for sticking with me on this @Cebeerre.

In case anyone has the Annexe set there was one little thing we missed. I knew it would be. To help everyone i have detailed the steps below;

  1. First set a seperate custom_component and give it a unique name such as securitas_direct_annex. Add this to your config.yaml replacing securitas_direct as the component to securitas_direct_annex
  2. Inside all of the __init__.py and also the manifest files change any refernece to securitas_direct to securitas_direct_annex. Check all the files but i am sure it was just these two.
  3. In the alarm_control_panel file, change the status codes section to
SECURITAS_STATUS = {
    STATE_ALARM_DISARMED: ['0',("1","32","44")],
    STATE_ALARM_ARMED_HOME: ['P',("311","202")],
    STATE_ALARM_ARMED_NIGHT: [('Q','C'),("46",)],
    STATE_ALARM_ARMED_AWAY: [('1','A'),("2","31","43")],
    STATE_ALARM_ARMED_CUSTOM_BYPASS: ['3',('204',)],
    STATE_ALARM_TRIGGERED: ['???',('13','24')],
}
  1. Update any references in the alarm_control_panel file from DARM to DARMANNEX and ARM to ARMANNEX
  2. In the securitas.py file search for filters and you will see filter = ('1','2','31','32','46','202','311','13','24','204')
    simply add the additional codes “43” (ARMANNEX) and “44” (ARMANNEX) to the end so it looks like filter = ('1','2','31','32','46','202','311','13','24','204','43','44'). This is very important.
  3. Restart Home Assistant and it should be working using the ARM AWAY method.

I hope this helps. A massive thank you to @Cebeerre for sticking with me on this. Its amazing the things you do when there is a global pandemic.

Stay safe everyone and i hope i can help someone else out ther who may be having issues.

Good luck

Ross

Good stuff Ross @jezzard ! Glad it worked out … I missed the filters bit in the API client script, but you figured out !

Cheers !
Xavi

1 Like

Hey,

So i have found a few inconsitances. Most of which i have overcome but one i am struggling with!!
First thing is if you have a second alarm using the annexe then in the filters you will need to only show 13,43 and 44 as the others will send false positives in Home Assistant as you see the main alarm. This is different to just adding as i suggest above.

The issue i am having is with Home Assistamt and setting the device name. As both devices are at the same installation address i think it is swapping the entity names in Home Assistant.
Basically it automatically creates an entity alarm_control_panel.securitas_xxxx and for the second alarm it uses alarm_control_panel.securitas_xxxx_2. The issue is when you restart _2 can be on either alarm at the order they load. So i need a way to manually set the entity ID in Home Assistant to a custom name. such as alarm_control_panel.main and alarm_control_panel.annexxe.

I think at the moment it pulls the name from the code at the installation address but i need to set a custom name there. Any ideas

Cheers

Ross

Dear SecuritasDirect HA community :grinning:

Not sure if useful but … I have added to the code the ability to write on the HA log what the web service is answering to every minute status request being performed. When the error (“KeyError: ‘REG’”) happens it is because the answer does not contain the “REG” info, hence the error is pretty obvious, it can be monitored and avoid the problem fixing the code. But I am more concerned when the error does not happen, I see the web service throwing +200k containing a whole year of log entries which can be overloading their servers and slowing our HA instances. I am not sure if that is happening only to me or to everybody else. In theory there is a paremeter in the request asking for only 5 days history which is not clearly working.

I need to make more digging to troubleshoot this but unfortunately I do not have too much time available. Only whanted to share what I found up to now.

I have now ammend the code to remove the noise caused by the “REG” Keyerror in the HA Log. Will test it a few days at home and will upload it to the repository afterwards.

Really great job, my annex arms and disarms.
Thank you very much to all.
I have followed the @jezzard 's steps.

1 Like

Hello everyone I installed the custom component on a hassio running on docker and it seems to work fine except that I can only arm outside home or in home and not day and night. I’m in Italy. Any suggestion on how to implement day/night setup?

Update: I could manage to modify layout to see day/night option, I confirm it works well!

Hi all, after 1 week of usage:

Arming from ha works fine

Arming from verisure hub does not update ha anymore. At the beginning used to work. During the week I changed my connection from http to https, maybe there is something wrong with ssl?

Cannot arm with Alexa, says alarm is unavailable

Hello, I’m struggling in integrating Verisure to HA. I followed all the procedures, copied the custom_component folder and configured the config.yaml but when trying to activate or disactivate the alarm through HA, I got this error message:
2020-05-03 11:28:09 WARNING (SyncWorker_15) [custom_components.securitas_direct.alarm_control_panel] Securitas: disarming (res=OrderedDict([(‘PET’, OrderedDict([(‘RES’, ‘ERROR’), (‘ERR’, ‘60067’), (‘MSG’, “Merci de vous déconnecter et de vous connecter à nouveau à l’application”), (‘BLOQ’, OrderedDict([(’@remotereqactive’, ‘1’), (’#text’, ‘Nos serveurs sont actuellement en cours de maintenance. Veuillez r?essayer ult?rieurement’)]))]))]))

Is there anything I do wrong?

After updating now to new versión 0.109.3 the component is not starting:

The following integrations and platforms could not be set up:

Please check your config.

Logger: homeassistant.setup
Source: custom_components/securitas_direct/securitas.py:111 
First occurred: 14:18:46 (1 occurrences) 
Last logged: 14:18:46

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 111, in last_state
    regs= res['PET']['LIST']['REG']
KeyError: 'REG'

Yesterday before update was working.

Hi Javy, I seen you had the same error than I’m currently having, how did you solve it ?