guerrerotook / securitas-direct-new-api

This repository contains the new securitas direct API that can be integrated in Home Assistant
Apache License 2.0
73 stars 30 forks source link

Only disarm works, no type of arm works #202

Closed hajar97 closed 4 months ago

hajar97 commented 6 months ago

Hi, any idea what I may be doing wrong? I setup integration, it recognised all the sensors correctly. Everything seems to be fine.

But no matter which type of arming I choose, it always reverts back to disarmed in 2s. And there is no way to arm my alarm panel it seems.

hajar97 commented 6 months ago

I enabled detailed logging and from its details it seems its not even trying to arm when I select Away, Night or Custom:

2024-01-26 22:24:00.879 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Authentication token expires 2024-01-26 22:34:54 and now is 2024-01-26 22:24:00.879478 2024-01-26 22:24:00.879 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Capabilities token expires 2024-01-26 22:34:54 and now is 2024-01-26 22:24:00.879590 2024-01-26 22:24:00.879 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Making request CheckAlarm with device_id 679873ed41bb4095, uuid 679873ed41bb4095 and idDeviceIndigitall 2024-01-26 22:24:01.189 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] --------------Response-------------- 2024-01-26 22:24:01.189 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] {"data":{"xSCheckAlarm":{"res":"OK","msg":"alarm-manager.processed.request","referenceId":"ddfeab9a-ef85-488c-8b3d-2e386b750420"}}}

2024-01-26 22:24:02.190 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Authentication token expires 2024-01-26 22:34:54 and now is 2024-01-26 22:24:02.190875 2024-01-26 22:24:02.190 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Capabilities token expires 2024-01-26 22:34:54 and now is 2024-01-26 22:24:02.190985 2024-01-26 22:24:04.192 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Making request CheckAlarmStatus with device_id 679873ed41bb4095, uuid 679873ed41bb4095 and idDeviceIndigitall 2024-01-26 22:24:04.285 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] --------------Response-------------- 2024-01-26 22:24:04.285 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] {"data":{"xSCheckAlarmStatus":{"res":"OK","msg":"alarm-manager.inactive_alarm","status":null,"numinst":null,"protomResponse":"D","protomResponseDate":"2024-01-26T21:24:01Z"}}}

It seems it only calling CheckAlarm and CheckAlarmStatus functions. I guess none of these is for arming?

hajar97 commented 6 months ago

After playing with the configuration parameters and disabling PIN setting, but enabling perimetral alarm I can now do partial arm of the alarm, but I cannot do full arm and I cannot disarm. When I try to disarm I get the following error each time:

2024-01-26 23:07:13.689 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Authentication token expires 2024-01-26 23:21:44 and now is 2024-01-26 23:07:13.689695 2024-01-26 23:07:13.689 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Capabilities token expires 2024-01-26 23:21:44 and now is 2024-01-26 23:07:13.689785 2024-01-26 23:07:13.689 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Making request xSDisarmPanel with device_id 19534647989f464a, uuid 19534647989f464a and idDeviceIndigitall 2024-01-26 23:07:13.877 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] --------------Response-------------- 2024-01-26 23:07:13.877 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] {"data":{"xSDisarmPanel":{"res":"OK","msg":"Su solicitud ha sido enviada","referenceId":"OWA___20240126230713748____"}}}

2024-01-26 23:07:15.878 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] Making request DisarmStatus with device_id 19534647989f464a, uuid 19534647989f464a and idDeviceIndigitall 2024-01-26 23:07:15.959 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] --------------Response-------------- 2024-01-26 23:07:15.959 DEBUG (MainThread) [custom_components.securitas.securitas_direct_new_api.apimanager] {"data":{"xSDisarmStatus":{"res":"ERROR","msg":"Ha ocurrido un problema, vuelve a intentarlo o contacta con nosotros.","status":null,"protomResponse":null,"protomResponseDate":null,"numinst":null,"requestId":"_pollingStatus_697832","error":{"code":"60067","type":"TECHNICAL_ERROR","allowForcing":false,"exceptionsNumber":null,"referenceId":null}}}}

cantupaz commented 5 months ago

can you try with the new release? 2.7.2

hajar97 commented 5 months ago

Tried. Unfortunately nothing changed. The same issue. If I use Arm Night then I get the following error appearing in HA:

Failed to call service alarm_control_panel/alarm_arm_night. ('Request ARMNIGHT1 is not valid for Central Unit', {'errors': [{'message': 'Request ARMNIGHT1 is not valid for Central Unit', 'name': 'ApiError', 'time_thrown': '2024-02-22T11:50:36.189Z', 'data': {'res': 'ERROR', 'err': 'Request ARMNIGHT1 is not valid for Central Unit'}, 'path': ['xSArmPanel']}], 'data': {'xSArmPanel': None}}, {'app': '{"appVersion": "10.102.0", "origin": "native"}', 'User-Agent': 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.41', 'X-APOLLO-OPERATION-ID': 'ceffd86b2eaa6b3bc56b62e98c6980859a01ab51f9959cf5850d7c84f2754d808646d34378c3ffda20e27c7917d48d181f49e204b57e8cb39a7d44bb7138e83e', 'X-APOLLO-OPERATION-NAME': 'xSArmPanel', 'extension': '{"mode":"full"}', 'numinst': '4705583', 'panel': 'SDVECU', 'X-Capabilities': 'eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5ZDdlOWQ5Ni00ZmM5LTQxMmUtOTdiYy04ZjQzOTYxMTkxZWYiLCJpYXQiOjE3MDg2MDI0MTIsImV4cCI6MTcwODYwMzMxMSwicm9sZSI6IlJFU1RSSUNURUQiLCJpbnMiOiI0NzA1NTgzIiwiY2FwIjpbIkVTVElOViIsIkFSTU5JR0hUIiwiQVJNIiwiR0RQUlBPUFVQIiwiRElZIiwiR0MiLCJBU0kiLCJDT05GT1JUIiwiRVNUIiwiREFSTSIsIklNRyIsIk5PVCIsIkFDVCIsIkNPTkYiLCJDT05UUkFDVFMiLCJEWU5BTUlDSU5GTyIsIk9MUyIsIktFWSIsIkNBTUVSQVMiLCJQTEFOIiwiTVlTRCIsIklOU1RXT1JEUyIsIkNPTkZTRVJWIiwiV0hBVE5FVyIsIkFSTU1PREVTREVWQ09ORiIsIkRFVklDRVNDT05GIiwiVElNRUxJTkUiLCJOT1RDT05GIiwiUkVNSU5ERVJTIiwiSU5BUFBDQU1QQUlHTiIsIk1BSUxCT1giLCJDT05OU1RBVFVTIiwiVFJVU1RQSUxPVCJdfQ.RSwb-lkY4tTVbvSVBZj2qeRHyElcrzdR46kJC3vpM90', 'auth': '{"loginTimestamp": 1708602411852, "user": ", "id": ***___20242221250123590", "country": "ES", "lang": "es", "callby": "OWA_10", "hash": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJrYXR5YS5lbG5hckBnbWFpbC5jb20iLCJjbnQiOiJFUyIsImNieSI6Ik9XQV8xMCIsInZlciI6IjEwLjEwMi4wIiwidXNyaWQiOiIxMTYzOTg4NSIsImp0aSI6Ijg1ZDllNjM4LTlhOGItNDY3Ny05ZjMxLWZmYjBjZDgxNWNkNiIsImlhdCI6MTcwODYwMjQxMSwiZXhwIjoxNzA4NjAzMzExfQ.uSkSXIpcgRt7OHRSknqojbSdnsuyTfZngyUZSQtmCl4"}'}, {'operationName': 'xSArmPanel', 'variables': {'request': 'ARMNIGHT1', 'numinst': '4705583', 'panel': 'SDVECU', 'currentStatus': 'D'}, 'query': 'mutation xSArmPanel($numinst: String!, $request: ArmCodeRequest!, $panel: String!, $currentStatus: String) {\n xSArmPanel(numinst: $numinst, request: $request, panel: $panel, currentStatus: $currentStatus) {\n res\n msg\n referenceId\n }\n}\n’})

If I use Arm Home I get partial arming on normally.

If I use Arm Away or Arm Custom absolutely nothing happens. And even with Debug Logging enabled no logs are added when I press Arm Away or Arm Custom, only when I press Arm Night.

On 22 Feb 2024, at 11:47, Erick Cantú Paz @.***> wrote:

can you try with the new release? 2.7.2

— Reply to this email directly, view it on GitHub https://github.com/guerrerotook/securitas-direct-new-api/issues/202#issuecomment-1959179719, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2QG7QGTTGVFV2ZTMVDYT3YU4O2XAVCNFSM6AAAAABCMX2L3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJZGE3TSNZRHE. You are receiving this because you authored the thread.

cantupaz commented 5 months ago

One thing I noticed is that when I decode the x-capablities token in our logs, I get (among many other things): 'role': 'RESTRICTED'

I'm not sure what that means, but are you using the credentials of the main user of the account, or some other user? Try using the credentials of the main user to see if that solves the problem.

hajar97 commented 5 months ago

Yes, you’re absolutely right, this is for restricted user. But this user has full control to enable and disable Alarm both fully and partially. Here is the screenshot for its settings: 

The next level of access is administrator access, which enables it not only to turn on/off the alarm, but also full control over the contract, devices, etc. This is way too much access and for security reasons it wouldn’t be ideal if integration only worked with full administrator access.

Could you possibly explore what changes are needed in the API calls to make sure these calls happen correctly for restricted user as well, if that user is enabled to do both both full and partial arming and works perfectly fine via the mobile app or web browser?

On 22 Feb 2024, at 17:54, Erick Cantú Paz @.***> wrote:

One thing I noticed is that when I decode the x-capablities token in our logs, I get (among many other things): 'role': 'RESTRICTED'

I'm not sure what that means, but are you using the credentials of the main user of the account, or some other user? Try using the credentials of the main user to see if that solves the problem.

— Reply to this email directly, view it on GitHub https://github.com/guerrerotook/securitas-direct-new-api/issues/202#issuecomment-1959863514, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2QG7Q55J2N5HJ7WABHFOLYU5Z4JAVCNFSM6AAAAABCMX2L3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJZHA3DGNJRGQ. You are receiving this because you authored the thread.

guerrerotook commented 5 months ago

The log that you shared says

Request ARMNIGHT1 is not valid for Central Unit.

also in the past other users who dowload and install the integration with an user told me that it works, but the user need to have permission as well. Did you try with that user in the customers.securitasdirect.es?

hajar97 commented 5 months ago

The log I shared is the only log I get. I don’t care about nightarm. I care about full arm and partial arm, but I do not get any logs for them. If I do these types of arm via web or mobile app with that same user it works perfectly. If I do that via the integration it only works for partial arm, but during full arm nothing happens.

I have a suspicion that it is because some of my windows are open when I am trying to do full arm and this is why it fails via the HA integration. When I do it via web or mobile it asks me if its OK to ignore those warnings that some windows are open and when I say yes it proceeds to full arm. This is a hypothesis right now. I will double check it and get back to you confirming if this is the issue. May be you can check in parallel if there is an API parameter that needs to be set to ignore warnings in order to complete full arm.

On 23 Feb 2024, at 18:49, Luis Guerrero @.***> wrote:

The log that you shared says

Request ARMNIGHT1 is not valid for Central Unit.

also in the past other users who dowload and install the integration with an user told me that it works, but the user need to have permission as well. Did you try with that user in the customers.securitasdirect.es?

— Reply to this email directly, view it on GitHub https://github.com/guerrerotook/securitas-direct-new-api/issues/202#issuecomment-1961748692, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2QG7VTQJIQE22S62CBRXTYVDJBXAVCNFSM6AAAAABCMX2L3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRG42DQNRZGI. You are receiving this because you authored the thread.

cantupaz commented 5 months ago

@hajar97 Do you have a perimetral (exterior) alarm? Make sure that the checkbox in the config matches your installation. I do have one and I can replicate the "Request ARMNIGHT1..." if I misconfigure the integration to indicate that I don't.

However, I get logs for all the arm modes.

Could you try deleting the integration. Then re-add it and configure it without a PIN and using the credentials of the owner.

hajar97 commented 5 months ago

Hi Erik, in the My Verisure app I have 2 modes of alarm: Full and Partial. I think partial is the one people also refer to as perimetral, because what it does is set alarm for all external doors of the house, while people can be inside without triggering the alarm. Here is the screenshot from the app for the restricted user:With these 2 modes of alarm, do I need to enable that checkbox or not?Could you explain what are we trying to test by reconfiguring it with credentials of owner? I can do that temporarily if its for some testing, but I do not want those credentials to be stored or used anywhere in HA. I prefer to use restricted account which has full access to arming and disarming through web and app interfaces, which both operate via web APIs. On 25 Feb 2024, at 07:08, Erick Cantú Paz @.***> wrote: @hajar97 Do you have a perimetral (exterior) alarm? Make sure that the checkbox in the config matches your installation. I do have one and I can replicate the "Request ARMNIGHT1..." if I misconfigure the integration to indicate that I don't. However, I get logs for all the arm modes. Could you try deleting the integration. Then re-add it and configure it without a PIN and using the credentials of the owner.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

cantupaz commented 5 months ago

hi. I cannot see the screenshot, but Perimetral means that you have some sensors in the outside of your home. In the Securitas app you'd see something like "Exterior mode." If you don't have that, don't select the Perimetral option when you set it up.

I'm trying to isolate things, so that's why I suggested to use the owner credentials, but I think the most important thing is to delete the integration and then configure it from the initial config screen without a PIN, enable logs, and try again.

hajar97 commented 5 months ago

Sorry that you don’t see the screenshots. Github must be filtering them out. Anyway, what I have in the app is:DesconectadoParcialTotalI do not have any sensors outside. But I have two modes of arming: 1)Full and 2)Partial. I guess you know what partial mode is, but if not let me know and I will explain. I will also try to recreate configuration as you suggest and see what happens. On 25 Feb 2024, at 12:18, Erick Cantú Paz @.***> wrote: hi. I cannot see the screenshot, but Perimetral means that you have some sensors in the outside of your home. In the Securitas app you'd see something like "Exterior mode." If you don't have that, don't select the Perimetral option when you set it up. I'm trying to isolate things, so that's why I suggested to use the owner credentials, but I think the most important thing is to delete the integration and then configure it from the initial config screen without a PIN, enable logs, and try again.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

cantupaz commented 5 months ago

I know about partial and full :-) When the integration is configured correctly, you'll be able to select them from HA too

hajar97 commented 5 months ago

Hi Erick. I just tried it - deleted and re-added without PIN code and without perimetral alarm. No change, same behavior. In HA I get the following options:HomeAwayNightCustomDisarmedOnly Home and Disarmed work. Home does partial arm. Disarm always asks for PIN code even if I configure it without pin code, but to disarm I just don’t type any code when HA asks for it and disarm happens correctly. Away, Night, Custom do not work and leave no traces in the log. Anything else I can try?On 25 Feb 2024, at 12:33, Erick Cantú Paz @.***> wrote: I know about partial and full :-) When the integration is configured correctly, you'll be able to select them from HA too

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

cantupaz commented 5 months ago

I had an unrelated issue that reminded me of something.... when you deleted the integration, did you check that the directory custom_components/securitas was gone?

Try deleting the integration and make sure the directory is gone. If it's still there, delete it manually. Restart HA. Reinstall the integration from HACS.

I don't know if that will help. The only way I know that pressing a button on the alarm panel doesn't leave a trace in the logs is that there is a PIN set and the code you enter to arm/disarm is different from the code saved. What is weird here is that you set up the integration without a PIN and even more weirdly you get it to work with some modes but not others. I made some code changes to log the cases where a PIN doesn't match and that may help debug this. I'll send a pull request in a day or so after I run this in my installation for a while. If you want to test, you can install the integration from my repo.

hajar97 commented 5 months ago

Ok, I tried exactly what you said. Deleted configuration and then deleted the securitas folder. Then added a configuration again with no PIN and no perimetral alarm. End result is the same. Partial arming is working. Full arming is not working. Night arm and Custom are still present in the list of types of armings and nome of them work. But I did start seeing these log messages when trying full arm:Arming triggered by service Alarm Control Panel: Arm away18:42:00Disarmed triggered by service Alarm Control Panel: Arm away18:42:01On 26 Feb 2024, at 18:13, Erick Cantú Paz @.***> wrote: I had an unrelated issue that reminded me of something.... when you deleted the integration, did you check that the directory custom_components/securitas was gone? Try deleting the integration and make sure the directory is gone. If it's still there, delete it manually. Restart HA. Reinstall the integration from HACS. I don't know if that will help. The only way I know that pressing a button on the alarm panel doesn't leave a trace in the logs is that there is a PIN set and the code you enter to arm/disarm is different from the code saved. What is weird here is that you set up the integration without a PIN and even more weirdly you get it to work with some modes but not others. I made some code changes to log the cases where a PIN doesn't match and that may help debug this. I'll send a pull request in a day or so after I run this in my installation for a while. If you want to test, you can install the integration from my repo.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

hajar97 commented 4 months ago

Ok, have an update. When I tried to connect alarm using the My Securitas app it would give me a warning that one of the windows was opened. I would then say to ignore all warnings and setup full alarm and it would work fine. Then trying to do full alarm via HA would always fail as I was describing before. Then I closed the window and tried to do full alarm via the My Securitas app and it would set alarm without any warnings. This is when trying to enable full alarm in HA started to work. So it seems your integration works in full alarm (Away Alarm) only when there are no warnings. There is no way to ignore those warnings in HA. Question: can you check integration APIs to see if it would be possible to make setting alarm work also when there are warnings such as as an opened window?On 26 Feb 2024, at 18:46, Elnar Hajiyev @.> wrote:Ok, I tried exactly what you said. Deleted configuration and then deleted the securitas folder. Then added a configuration again with no PIN and no perimetral alarm. End result is the same. Partial arming is working. Full arming is not working. Night arm and Custom are still present in the list of types of armings and nome of them work. But I did start seeing these log messages when trying full arm:Arming triggered by service Alarm Control Panel: Arm away18:42:00Disarmed triggered by service Alarm Control Panel: Arm away18:42:01On 26 Feb 2024, at 18:13, Erick Cantú Paz @.> wrote: I had an unrelated issue that reminded me of something.... when you deleted the integration, did you check that the directory custom_components/securitas was gone? Try deleting the integration and make sure the directory is gone. If it's still there, delete it manually. Restart HA. Reinstall the integration from HACS. I don't know if that will help. The only way I know that pressing a button on the alarm panel doesn't leave a trace in the logs is that there is a PIN set and the code you enter to arm/disarm is different from the code saved. What is weird here is that you set up the integration without a PIN and even more weirdly you get it to work with some modes but not others. I made some code changes to log the cases where a PIN doesn't match and that may help debug this. I'll send a pull request in a day or so after I run this in my installation for a while. If you want to test, you can install the integration from my repo.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

hajar97 commented 4 months ago

Hi Luis, Erick,

Any update on ability to turn on alarm ignoring warnings by Securitas in case some windows are left open, like one can do using Securitas website?

On 3 Mar 2024, at 14:22, Elnar Hajiyev @.***> wrote:

Ok, have an update.

When I tried to connect alarm using the My Securitas app it would give me a warning that one of the windows was opened. I would then say to ignore all warnings and setup full alarm and it would work fine. Then trying to do full alarm via HA would always fail as I was describing before.

Then I closed the window and tried to do full alarm via the My Securitas app and it would set alarm without any warnings. This is when trying to enable full alarm in HA started to work.

So it seems your integration works in full alarm (Away Alarm) only when there are no warnings. There is no way to ignore those warnings in HA. Question: can you check integration APIs to see if it would be possible to make setting alarm work also when there are warnings such as as an opened window?

On 26 Feb 2024, at 18:46, Elnar Hajiyev @.***> wrote:

 Ok, I tried exactly what you said. Deleted configuration and then deleted the securitas folder. Then added a configuration again with no PIN and no perimetral alarm.

End result is the same. Partial arming is working. Full arming is not working. Night arm and Custom are still present in the list of types of armings and nome of them work.

But I did start seeing these log messages when trying full arm:

Arming triggered by service Alarm Control Panel: Arm away 18:42:00

Disarmed triggered by service Alarm Control Panel: Arm away 18:42:01

On 26 Feb 2024, at 18:13, Erick Cantú Paz @.***> wrote:



I had an unrelated issue that reminded me of something.... when you deleted the integration, did you check that the directory custom_components/securitas was gone?

Try deleting the integration and make sure the directory is gone. If it's still there, delete it manually. Restart HA. Reinstall the integration from HACS.

I don't know if that will help. The only way I know that pressing a button on the alarm panel doesn't leave a trace in the logs is that there is a PIN set and the code you enter to arm/disarm is different from the code saved. What is weird here is that you set up the integration without a PIN and even more weirdly you get it to work with some modes but not others. I made some code changes to log the cases where a PIN doesn't match and that may help debug this. I'll send a pull request in a day or so after I run this in my installation for a while. If you want to test, you can install the integration from my repo.

— Reply to this email directly, view it on GitHub https://github.com/guerrerotook/securitas-direct-new-api/issues/202#issuecomment-1964677998, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD2QG7ULTPSEFRZMF6627ITYVS7ELAVCNFSM6AAAAABCMX2L3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGY3TOOJZHA. You are receiving this because you were mentioned.

cantupaz commented 4 months ago

I opened https://github.com/guerrerotook/securitas-direct-new-api/issues/222 to track the request. It makes sense as a feature of the integration, but I cannot tell you when (or if) I'll work on it.

cantupaz commented 4 months ago

Closing this