Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Allow management and report status of "PERI" alarm #3

Closed
bvis opened this issue Dec 6, 2021 · 21 comments
Closed

Comments

@bvis
Copy link

bvis commented Dec 6, 2021

First of all thanks for this great job!

One thing I miss in the Securitas Direct integration in HA is that I cannot check the status of the perimeter alarm or activate/deactivate it.

I know it was exposed by the earlier API because the component Cebeerre developed by supported it.

Is it anything you could do for adding this feature?

@sion-roberts
Copy link

Thanks for this. I am a total noob to HA, Python etc. so I have a lot to learn. I DID get it working, so am really thrilled. +1 for any feature requests - Annex (secondary) alarm would be great, and I can't see how to set Partial Day/Night... I will keep exploring.

@guerrerotook
Copy link
Owner

Thanks @bvis for the feature request. How I write the api was by opening the https://customers.securitasdirect.es/owa-static/login web application and logging calls to the /owa-api/graphql with the json payload.

If you need help let me know and we can work on getting those logs.

@bvis
Copy link
Author

bvis commented Jan 7, 2022

Hi, now I have had some time for doing this. It was so easy because all the calls are as you said between the browser and the backend:

First request:

{
   "operationName":"xSArmPanel",
   "variables":{
      "request":"PERI1",
      "numinst":"XXXX",
      "panel":"SDVFAST",
      "currentStatus":"D"
   },
   "query":"mutation xSArmPanel($numinst: String!, $request: ArmCodeRequest!, $panel: String!, $pin: String, $currentStatus: String) {\n  xSArmPanel(numinst: $numinst, request: $request, panel: $panel, pin: $pin, currentStatus: $currentStatus) {\n    res\n    msg\n    referenceId\n  }\n}\n"
}

First response:

{
   "data":{
      "xSArmPanel":{
         "res":"OK",
         "msg":"Su solicitud ha sido enviada",
         "referenceId":"XXXX"
      }
   }
}

Polling request:

{
   "operationName":"ArmStatus",
   "variables":{
      "request":"PERI1",
      "numinst":"XXXX",
      "panel":"SDVFAST",
      "currentStatus":"D",
      "referenceId":"YYYY",
      "counter":1
   },
   "query":"query ArmStatus($numinst: String!, $request: ArmCodeRequest, $panel: String!, $referenceId: String!, $counter: Int!) {\n  xSArmStatus(numinst: $numinst, panel: $panel, referenceId: $referenceId, counter: $counter, request: $request) {\n    res\n    msg\n    status\n    protomResponse\n    protomResponseDate\n    numinst\n    requestId\n    error {\n      code\n      type\n      allowForcing\n      exceptionsNumber\n      referenceId\n    }\n  }\n}\n"
}

Polling first response:

{
   "data":{
      "xSArmStatus":{
         "res":"WAIT",
         "msg":"Petición en proceso",
         "status":null,
         "protomResponse":null,
         "protomResponseDate":null,
         "numinst":null,
         "requestId":"_pollingStatus_56613",
         "error":null
      }
   }
}

Final response:

{
   "data":{
      "xSArmStatus":{
         "res":"OK",
         "msg":"La zona exterior ha sido conectada",
         "status":"3",
         "protomResponse":"E",
         "protomResponseDate":"2022-01-07 22:38:22.306",
         "numinst":"XXXX",
         "requestId":"_pollingStatus_57119",
         "error":null
      }
   }
}

@bvis
Copy link
Author

bvis commented Jan 7, 2022

When only the perimetral alarm is activated the request/answer is like this:

{
   "operationName":"CheckAlarmStatus",
   "variables":{
      "numinst":"XXXXX",
      "panel":"SDVFAST",
      "referenceId":"XXXX",
      "idService":"11",
      "counter":3
   },
   "query":"query CheckAlarmStatus($numinst: String!, $idService: String!, $panel: String!, $referenceId: String!) {\n  xSCheckAlarmStatus(numinst: $numinst, idService: $idService, panel: $panel, referenceId: $referenceId) {\n    res\n    msg\n    status\n    numinst\n    protomResponse\n    protomResponseDate\n  }\n}\n"
}

After some WAITS, the final answer:

{
   "data":{
      "xSCheckAlarmStatus":{
         "res":"OK",
         "msg":"Tu Alarma está conectada en el exterior",
         "status":"3",
         "numinst":"XXXX",
         "protomResponse":"E",
         "protomResponseDate":"2022-01-07 22:56:47.126"
      }
   }
}

@bvis
Copy link
Author

bvis commented Jan 7, 2022

Other statuses are:

{
   "operationName":"CheckAlarmStatus",
   "variables":{
      "numinst":"XXXXX",
      "panel":"SDVFAST",
      "referenceId":"YYYYY",
      "idService":"11",
      "counter":3
   },
   "query":"query CheckAlarmStatus($numinst: String!, $idService: String!, $panel: String!, $referenceId: String!) {\n  xSCheckAlarmStatus(numinst: $numinst, idService: $idService, panel: $panel, referenceId: $referenceId) {\n    res\n    msg\n    status\n    numinst\n    protomResponse\n    protomResponseDate\n  }\n}\n"
}

{
   "data":{
      "xSCheckAlarmStatus":{
         "res":"OK",
         "msg":"Tu Alarma está conectada en modo Parcial Día y en el exterior",
         "status":"B",
         "numinst":"XXXXX",
         "protomResponse":"B",
         "protomResponseDate":"2022-01-07 23:01:45.716"
      }
   }
}

{
   "data":{
      "xSArmStatus":{
         "res":"OK",
         "msg":"Tu Alarma está conectada en modo Parcial Noche y en el exterior",
         "status":"C",
         "protomResponse":"C",
         "protomResponseDate":"2022-01-07 23:05:29.380",
         "numinst":"XXXXX",
         "requestId":"_pollingStatus_238933",
         "error":null
      }
   }
}

@guerrerotook
Copy link
Owner

Awesome! Let me work on that tomorrow!

@guerrerotook
Copy link
Owner

I added the support for the PERI1 type of alarm in this commit, can you download and test it and tell me if it works?

@bvis
Copy link
Author

bvis commented Jan 8, 2022

I’ll do it asap, tonight when I’m at home

@bvis
Copy link
Author

bvis commented Jan 8, 2022

When I pressed the CUSTOM BYPASS it has activated the "PERI" alarm! Nice!

But it's incorrectly seen in the panel:
image

In fact the current status is this one:
image
It seems it's displaying the different statuses wrongly.

When I press the ARMAR EN CASA button the status shown in the panel is this one:
image

And the real status is:
image

And when I press the button of ARMAR AUSENTE the other is activated, why seem to be switched by mistake, could it be?

@bvis
Copy link
Author

bvis commented Jan 8, 2022

On other hand it would be very useful, I don't know if it's possible, to have a "button" or activator to do a call to the remote system and update the status of the sensor. This way I could check the current status of the alarm in case I want to program an scenario or script, as it's very usual to change the status via the control panel we have in home.

@guerrerotook
Copy link
Owner

Thanks for the update on the perimeter alarm. I see what you mean when you said that is reporting the incorrect status.

Home Assistant define a set of possible status for the alarm, defined here.

The original code for the integration of the alarm used that custom state STATE_ALARM_ARMED_CUSTOM_BYPASS for the perimeter alarm. I don't know how to set a custom state for the panel.

@guerrerotook
Copy link
Owner

On other hand it would be very useful, I don't know if it's possible, to have a "button" or activator to do a call to the remote system and update the status of the sensor. This way I could check the current status of the alarm in case I want to program an scenario or script, as it's very usual to change the status via the control panel we have in home.

This is happening in the background automatically. I push a new changed in the alarm_control_panel.py file, please update and tell me if it fix the issue.

@bvis
Copy link
Author

bvis commented Jan 8, 2022

After this update now it's reported like this:
image

@bvis
Copy link
Author

bvis commented Jan 8, 2022

This is how it's seen:

image

AFAIK it should be in the state armed_custom_bypass, as I see in the possible status list:
https://developers.home-assistant.io/docs/core/entity/alarm-control-panel/#states

@guerrerotook
Copy link
Owner

Now I realized that there are three new states for when the perimeter is active,
"protomResponse":"C", Tu Alarma está conectada en modo Parcial Noche y en el exterior
"protomResponse":"B", Tu Alarma está conectada en modo Parcial Día y en el exterior
"protomResponse":"E", Tu Alarma está conectada en el exterior

So I pushed new changes to group all those changes into the CUSOM_BYPASS.

image

Here is the commit

Tell me how it looks like right now.

@bvis
Copy link
Author

bvis commented Jan 9, 2022

Hi and thanks again for this, you are so responsive!

image

As you may see it right now show the "correct", based in the current limitations the alarm control panel card has. Thanks a lot for this!

One improvement which I think shouldn't be hard to do is to add an attribute to the current sensor with the obtained message, it contains the exact sentence like in my example: `"msg":"Tu Alarma está conectada en modo Parcial Noche y en el exterior".

It could be something like this, it would be very helpful because I could show the message below the alarm card to give me more information.

state: armed_custom_bypass
code_format: number
changed_by: null # I always see this as null, maybe it's a bug, IDK
code_arm_required: false
friendly_name: CASA
supported_features: 23
message: Tu Alarma está conectada en modo Parcial Noche y en el exterior

On other hand I suspect there's another protomResponse to add that I didn't add in my examples, when it's completely activated (AWAY+PERI).

This is answer I obtain when it's in this status:

{
   "data":{
      "xSArmStatus":{
         "res":"OK",
         "msg":"Tu Alarma está conectada en modo Total y en el exterior",
         "status":"4",
         "protomResponse":"A",
         "protomResponseDate":"2022-01-09 01:40:23.536",
         "numinst":"XXXXXXXX",
         "requestId":"_pollingStatus_244486",
         "error":null
      }
   }
}

@bvis
Copy link
Author

bvis commented Jan 9, 2022

Related to this I've created this PR: #16

@guerrerotook
Copy link
Owner

Yeah, I'm looking forward in how to add custom attributes to an entity so I can add more information. I'm going to investigate this.

@quentinreytinas
Copy link

Hi,
Thanks for this work!
I can activate the exterior perimeter with arm_custombypass but I cannot disarm it... Even when I set with node red, alarm_arm_home and then alarm_arm_custombypass and after when I disarm with alarm_disarm, only the mode Home (or away) is disarmed and not the exterior perimeter. It stays armed.
What do I need to do to disarm the custombypass and not only the arm_away or arm_home ?
Thanks a lot!

@Javvaz
Copy link

Javvaz commented Oct 11, 2022

#71 It is the same that this issue.

@cantupaz
Copy link
Collaborator

I think this is solved with latest releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants