tkleijkers / homebridge-visonic-powerlink3

MIT License
1 stars 3 forks source link

Error crashing homebridge / API changed #5

Closed davidt94 closed 3 years ago

davidt94 commented 4 years ago

Hi,

I am getting the following error causing my homebridge to crash. is this something you can help with?

https://pastebin.com/EUiBymF1

many thanks!

tkleijkers commented 4 years ago

Hi @cjones813, it seems that the authentication request to Visonic failed. Are you sure you added the correct configuration and authentication details?

The error is thrown at parsing the response from Visonic: https://github.com/tkleijkers/visonic-powerlink3/blob/eea8666d6abf60c852d2da572dc9c0bfb33185a5/index.js#L82

davidt94 commented 4 years ago

Hi @tkleijkers, Yes I am sure its the correct config. Visonic have done an update to include 2 factor authentication, do you think this could be why?

tkleijkers commented 4 years ago

I indeed think that Visonic changed their API and thus the authentication flow should be corrected. I am not active on development on this project, so someone can make a pull-request to fix this or I may fix it in the future.

davidt94 commented 4 years ago

Thanks for the reply. yes, I now need to enter a username and password on the VisonicGo app unfortunately. That is a shame, I would happily make a donation to anybody that is able to fix this 👍

Thanks!

StuFull commented 4 years ago

Same problem for me. It seems Tyco has changed the way the login is managed.

I have had to log in to the app again.

StuFull commented 4 years ago

I don't know if it helps but I found this document

https://www.visonic.com/Data/Uploads/Alarm_Install_App_User_Guide_English_D_307194.pdf

tkleijkers commented 4 years ago

I don't know if it helps but I found this document

https://www.visonic.com/Data/Uploads/Alarm_Install_App_User_Guide_English_D_307194.pdf

This is another app

tkleijkers commented 4 years ago

I based the API request on https://github.com/barcar/visonic_control. If someone knows how the new API works, I can update this package. However this API is not documented by Tyco / Visonic so someone has to sniff the request from the app to the API.

curry756 commented 4 years ago

+1 for a fix. I was hoping to get this working too.

barcar commented 4 years ago

I based the API request on https://github.com/barcar/visonic_control. If someone knows how the new API works, I can update this package. However this API is not documented by Tyco / Visonic so someone has to sniff the request from the app to the API.

That's my project. I think they switched to SSL pinning so I couldn't sniff the traffic.

I couldn't figure out what changed by myself but I think this person has... https://github.com/And3rsL/VisonicAlarm2. Their commits reference upgrading to API v8 which is what I see listed at https://visonic.tycomonitor.com/rest_api/version = so maybe there is hope.

tkleijkers commented 4 years ago

I updated the visonic_powerlink3 package to use the new REST API of Visonic. Please let me know if it works.

barcar commented 4 years ago

I'm getting this error when trying to install:

No matching version found for visonic-powerlink3@^1.1.0.

From what I can see I've got 1.0.0 installed and can't see 1.1.0. Not an NPM expert so could be my stupidity.

davidt94 commented 4 years ago

I'm getting this error when trying to install:

No matching version found for visonic-powerlink3@^1.1.0.

From what I can see I've got 1.0.0 installed and can't see 1.1.0. Not an NPM expert so could be my stupidity.

Experiencing the same issue. Did you manage to get it installed?

tkleijkers commented 4 years ago

The updated version is not yet on npm. I did not publish the package to npm myself and asked the publisher to give me permission to update the package. You can however clone the git repository and link the package yourself for now.

barcar commented 4 years ago

The updated version is not yet on npm. I did not publish the package to npm myself and asked the publisher to give me permission to update the package. You can however clone the git repository and link the package yourself for now.

I’m confused... when I look at https://github.com/tkleijkers/visonic-powerlink3 I don’t see any commits after v1.0.1 in July. Is there another repository?

davidt94 commented 4 years ago

Thanks. I have managed to get it installed, but get the follow error once the config has been added.

https://pastebin.pl/view/16aae3c3

barcar commented 4 years ago

I have managed to get it installed, but get the follow error

Me too.

davidt94 commented 4 years ago

Seems as though 'homebridge-visonic-powerlink3' was updated, 'but visonic-powerlink3' wasn't. @tkleijkers Is this correct?

tkleijkers commented 4 years ago

My fault. Pushing the update to github failed and I didn't notice. https://github.com/tkleijkers/visonic-powerlink3 is now updated with the code to connect to the new API. Please notice to add your username and password in the config. I didn't test it myself in homebridge yet (didn't have the time).

davidt94 commented 4 years ago

Many thanks! Successfully installed and no longer crashing homebridge.

Added config including my username and password but then get the following error.

[Burglar Alarm] Executing request https://visonic.tycomonitor.com/rest_api/8.0/status [Burglar Alarm] Updating status (1) [Burglar Alarm] Error polling: Error: Error getting raw status: Error: Failed to get authentication session-token: Bad Request Params

tkleijkers commented 4 years ago

Looks like the user login succeeded but the login to the panel fails. Are the setting (panelWebName and userCode etc) correct? Maybe you can turn on debug:true to get some more logging.

tkleijkers commented 4 years ago

I missed the params in this package. They are added. I see now some other things which should be updated in the package. I will look into it when I have more time available.

davidt94 commented 4 years ago

I missed the params in this package. They are added. I see now some other things which should be updated in the package. I will look into it when I have more time available.

No problem. Many thanks for your time on this. Double checked all settings in the config and they are correct.

barcar commented 4 years ago

I checked my config and all looks ok. I'm seeing this in debug mode:

[10/21/2020, 10:20:54 PM] [Visonic] Initializing PowerLink3 accessory... [10/21/2020, 10:20:54 PM] [Visonic] getCurrentState [10/21/2020, 10:20:54 PM] [Visonic] Response from getUserToken HTTP call: [10/21/2020, 10:20:54 PM] [Visonic] error: null [10/21/2020, 10:20:54 PM] [Visonic] response: {"statusCode":400,"body":{"error":10001,"error_message":"Bad Request Params","error_reason_code":"BadRequestParams","extras":[{"key":"email","value":"required"},{"key":"password","value":"required"}]},"headers":{"server":"nginx","date":"Wed, 21 Oct 2020 21:20:54 GMT","content-type":"application/json; charset=utf-8","transfer-encoding":"chunked","connection":"close","x-frame-options":"SAMEORIGIN","x-xss-protection":"1; mode=block","x-content-type-options":"nosniff"},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"visonic.tycomonitor.com","port":443,"hostname":"visonic.tycomonitor.com","hash":null,"search":null,"query":null,"pathname":"/rest_api/8.0/auth","path":"/rest_api/8.0/auth","href":"https://visonic.tycomonitor.com/rest_api/8.0/auth"},"method":"POST","headers":{"Content-Type":"application/json","accept":"application/json","content-length":49}}} [10/21/2020, 10:20:54 PM] [Visonic] body: {"error":10001,"error_message":"Bad Request Params","error_reason_code":"BadRequestParams","extras":[{"key":"email","value":"required"},{"key":"password","value":"required"}]} [10/21/2020, 10:20:54 PM] [Visonic] Executing request https://visonic.tycomonitor.com/rest_api/8.0/status [10/21/2020, 10:20:54 PM] [Visonic] Updating status (1) [10/21/2020, 10:20:54 PM] [Visonic] Error polling: Error: Error getting raw status: Error: Failed to get authentication session-token: Bad Request Params`

barcar commented 4 years ago

I see now some other things which should be updated in the package. I will look into it when I have more time available.

Thanks for your help.

JSVarga commented 4 years ago

I recently updated to the latest version, wasn't in a hurry as everything working apart from one small issue on automations getting fired on both Arm and Disarm despite conditions set in HomeKit. Updated and now it is crashing home bridge with the following message: [11/3/2020, 7:11:05 AM] [Visonic Home Alarm] Updating status (1) [11/3/2020, 7:11:05 AM] SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse () at /homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/visonic-powerlink3/index.js:88:20 at Request._callback (/homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/visonic-powerlink3/index.js:309:5) at Request.self.callback (/homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/request/request.js:185:22) at Request.emit (events.js:315:20) at Request. (/homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/request/request.js:1154:10) at Request.emit (events.js:315:20) at IncomingMessage. (/homebridge/node_modules/homebridge-visonic-powerlink3/node_modules/request/request.js:1076:12) at Object.onceWrapper (events.js:421:28) at IncomingMessage.emit (events.js:327:22) [11/3/2020, 7:11:05 AM] Got SIGTERM, shutting down Homebridge...

Is this the same issue? I there any way to install the previous version as these do not seem to be versioned in GitHub?

UPDATE: I've rolled back to V1.1 and V1 and still have the same problem. If I empty the config entries to minimum (accessory and name) then it runs but this is in the log (as above): [11/3/2020, 8:57:25 AM] [Visonic Home Alarm] Executing request https://undefined/rest_api/8.0/status [11/3/2020, 8:57:25 AM] [Visonic Home Alarm] Updating status (1) [11/3/2020, 8:57:25 AM] [Visonic Home Alarm] Error polling: Error: Error getting raw status: Error: Failed to get authentication session-token: Error: ETIMEDOUT

This is my config details: "accessory": "PowerLink3",             "name": "Visonic Home Alarm",             "host": "logonmysecurity.com",             "userCode": "XXXX",             "appType": "com.visonic.PowerMaxApp",             "userId": "89b14b39-dbe1-4364-b3d8-6303b026b397",             "panelWebName": "148e29”

Note this is running in Homebridge within a Docker container on a Synology NAS. The host does not provide userEmail our userPassword, only four digit code. Frustrating as was working fine until update.

StuFull commented 3 years ago

Has anyone had any success in getting this to work?

Thanks for your effort so far tkleijkers but I think we are still missing something.

xEzeit commented 3 years ago

Has anyone had any success in getting this to work?

Thanks for your effort so far tkleijkers but I think we are still missing something.

Yes don't work for me as well :/

JSVarga commented 3 years ago

Keep trying by putting the entries back into the config file and restart. Every time Homebridge fails and won't run, then delete from config and everything runs. Lots of other updates to other plugins without issue. Just frustrated because it was working.

xEzeit commented 3 years ago

Keep trying by putting the entries back into the config file and restart. Every time Homebridge fails and won't run, then delete from config and everything runs. Lots of other updates to other plugins without issue. Just frustrated because it was working.

Ok but in Userid, i can put random guid ?

tkleijkers commented 3 years ago

I will have to look into it but don't have the time currently.

xEzeit commented 3 years ago

I will have to look into it but don't have the time currently.

Ok i wait the update, i look forward :)

nitaybz commented 3 years ago

@tkleijkers it seems like you are not passing the user ID and email to the powerlink3 lib...

EDIT: you've only added those to GitHub but not pushed to NPM.... no chance it will work

nitaybz commented 3 years ago

I created a pull request for both this plugin and it's visonic-powerlink3 library to fix what's caused it to break + small improvement.

JSVarga commented 3 years ago

I created a pull request for both this plugin and it's visonic-powerlink3 library to fix what's caused it to break + small improvement.

Sounds promising, apologies if not up to speed but how do I install this update? Running Homebridge in Docker on Synology NAS but this does not show an update version. Does it need to be merged with main package?

nitaybz commented 3 years ago

yes it does

StuFull commented 3 years ago

Do you have this working now?

JSVarga commented 3 years ago

I am not sure how to install the pull request on my setup, through Homebridge UI I usually have an Update option.

nitaybz commented 3 years ago

you can't at the moment... the fix is both in this plugin and in the library it uses... the plugin owner will have to merge both my pull requests and push to NPM before you can use it

JSVarga commented 3 years ago

Understood, thanks for the update and what you have done.

nitaybz commented 3 years ago

I'm working now on setting one last improvement to improve the speed of the loading... at the moment getting the state will delay the entire homebridge until it is returned... fixing

tkleijkers commented 3 years ago

I will look at it today! 👍🏻 Thanks for the PR

tkleijkers commented 3 years ago

I published version 1.2.0 on NPM. If @nitaybz pushes an update I will publish this one as well. Many thanks to @nitaybz!

nitaybz commented 3 years ago

I already made all the changes needed... should be ok now, faster loading and no night mode in Home app

tkleijkers commented 3 years ago

Okay, it seems to work at my side. I will close this issue. Thanks again.

JSVarga commented 3 years ago

Sorry, still not working for me on my Synology NAS Docker installation. I tried uninstalling and reinstalling and did notice these errors: USER: root DIR: /homebridge CMD: npm install --save homebridge-visonic-powerlink3@latest

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported

Homebridge runs until I update the config with my details then it crashes Homebridge which won't run until I remove my config details.

nitaybz commented 3 years ago

can you post the logs? this warning is not the issue

JSVarga commented 3 years ago

Sure, here is the log from the most recent attempt. You will see the SyntacError message just the the rest api all to the website. homebridge.log.txt

nitaybz commented 3 years ago

I believe your configuration is wrong... probably the "host" part as it can't be reached... it should be left as in the example on the readme... don't change it to the device IP or anything like that...

tkleijkers commented 3 years ago

Indeed as @nitaybz mentions the host should be as in the example. Powerlink3 cannot be reached directly.