Skip to content

WIP: Support for Securitas Direct API#41

Closed
ptz0n wants to merge 5 commits into
masterfrom
securitas-direct
Closed

WIP: Support for Securitas Direct API#41
ptz0n wants to merge 5 commits into
masterfrom
securitas-direct

Conversation

@ptz0n
Copy link
Copy Markdown
Owner

@ptz0n ptz0n commented Feb 6, 2020

For some time it's been a requested feature of homebridge-verisure to support Securitas Direct installations. I argue that this actually make sense from a user perspective, as these are often nowadays branded as Verisure.

I don't personally have access to such a system, but thanks to @Cebeerre who put a lot of effort into documenting the API this is now within reach of development.

This should allow integrations with Securitas Direct systems with mobile access in the following countries:

  • Spain
  • Italy
  • France
  • United Kingdom
  • Portugal

Please help out with testing the client

1. Install the module from this branch.

npm install git://github.com/ptz0n/node-verisure.git#securitas-direct

2. Put the following lines into a file called test.js

Then replace username, password and country on line 3 with values for your system. Country should be set to one of es, fr or pt:

const SecuritasDirect = require('verisure/es');

const client = new SecuritasDirect('username', 'password', 'country');

const run = async () => {
  await client.login().catch((error) => {
    console.error('Oh, no!', error.response.status, error.response.data);
  });

  console.log('Success!');

  await client.logout();
}

run();

3. Run it with the following command

node test.js

4. Additional info of your environment

node -v && npm -v

5. Paste the output as comments here below 👇

The test script should not output any secrets about your system but please read through the output before posting. I will try to promptly remove any such information if posted.


@gabriuelucho
Copy link
Copy Markdown

Hi
I would like to help as much as I can, but unfortunately I'm a noob on these things. I've made the installation but I have no idea about how can I test it...
Please could you give me some steps to follow?
Thank you!

@ptz0n
Copy link
Copy Markdown
Owner Author

ptz0n commented Feb 7, 2020

@gabriuelucho Great feedback! I've updated the description above with step by step instructions. Please reach out again if you get stuck at any point. Looking forward to the results.

@ptz0n ptz0n self-assigned this Feb 7, 2020
@gabriuelucho
Copy link
Copy Markdown

@gabriuelucho Great feedback! I've updated the description above with step by step instructions. Please reach out again if you get stuck at any point. Looking forward to the results.

Thank you for your help, here you are the results, seems there was no luck

pi@raspberrypi:~ $ node test.js Oh, no! 200 { PET: { RES: [ 'ERROR' ], ERR: [ '3000' ], MSG: [ 'Por favor, vuelva a escribir sus datos de acceso' ] } } pi@raspberrypi:~ $ node -v && npm -v v10.16.3 6.9.0
Hope it helps, let me know if I can do any other test

@artik
Copy link
Copy Markdown

artik commented Feb 7, 2020

Same here:

/homebridge/node_modules/verisure # node test.js                                                                            
Oh, no! 200 {                                                                                                               
  PET: {                                                                                                                    
    RES: [ 'ERROR' ],                                                                                                       
    ERR: [ '3000' ],                                                                                                        
    MSG: [ 'Por favor, vuelva a escribir sus datos de acceso' ]                                                             
  }                                                                                                                         
}                                                                                                                           

My test.js:

/homebridge/node_modules/verisure # cat test.js                                                                             
const { login } = require('verisure/es')                                                                                    
                                                                                                                            
login('20******', 'mz**********', 'es')                                                                                      
  .then(() => {                                                                                                             
    console.log('Success!')                                                                                                 
  })                                                                                                                        
  .catch((error) => {                                                                                                       
    console.error('Oh, no!', error.response.status, error.response.data)                                                    
  }) 

node -v && npm -v

v12.14.1                                                                                                                    
6.13.4 

@ptz0n
Copy link
Copy Markdown
Owner Author

ptz0n commented Feb 8, 2020

@gabriuelucho @artik Thanks a lot for the speedy tests! Sorry that it did not work as intended.

I’ll have another look to see what might be wrong.

Repository owner deleted a comment from artik Feb 8, 2020
Repository owner deleted a comment from artik Feb 8, 2020
@ptz0n
Copy link
Copy Markdown
Owner Author

ptz0n commented Feb 8, 2020

Client updated - Please follow all the steps from the top to try again.

@artik
Copy link
Copy Markdown

artik commented Feb 9, 2020

Haha! great job!

/homebridge/node_modules/verisure # node test.js                                                                            
Success! 

@gabriuelucho
Copy link
Copy Markdown

yeah!

pi@raspberrypi:~ $ node test.js
Success!

@ptz0n
Copy link
Copy Markdown
Owner Author

ptz0n commented Feb 16, 2020

I decided to move this logic to it's own module.

First version published: https://github.com/ptz0n/node-securitas-direct

@ptz0n ptz0n closed this Feb 16, 2020
@ptz0n ptz0n deleted the securitas-direct branch February 16, 2020 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants