home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.38k stars 30.64k forks source link

Verisure integration #47397

Closed renejorissen closed 3 years ago

renejorissen commented 3 years ago

The problem

I upgraded to 2021.3.0 and the Verisure alarm integration doesn’t work anymore. I posted the logs below. Anybody an idea?

What is version of Home Assistant Core has the issue?

2021.3.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Verisure

Link to integration documentation on our website

https://www.home-assistant.io/integrations/verisure/

Example YAML snippet

# Put your YAML below this line

Anything in the logs that might be useful for us?

# Put your logs below this line

Logger: homeassistant.setup
Source: components/verisure/__init__.py:183 
First occurred: 18:54:10 (1 occurrences) 
Last logged: 18:54:10

Error during setup of component verisure
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/verisure/session.py", line 147, in get_overview
    response = requests.get(
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 528, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 456, in prepare_request
    p.prepare(
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 316, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 390, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'None/xbn/2/installation/None/overview': No schema supplied. Perhaps you meant http://None/xbn/2/installation/None/overview?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/verisure/__init__.py", line 82, in setup
    HUB.update_overview()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 285, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/verisure/__init__.py", line 183, in update_overview
    self.overview = self.session.get_overview()
  File "/usr/local/lib/python3.8/site-packages/verisure/session.py", line 152, in get_overview
    raise RequestError(ex)
verisure.session.RequestError: Invalid URL 'None/xbn/2/installation/None/overview': No schema supplied. Perhaps you meant http://None/xbn/2/installation/None/overview?
probot-home-assistant[bot] commented 3 years ago

Hey there @frenck, mind taking a look at this issue as its been labeled with an integration (verisure) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

br4tt3 commented 3 years ago

Hi - can confirm what @renejorissen is listing above on my side as well. Integration for Verisure working as a charm until update to: 2021.3.0 of HA. Reverting back to previous snapshot.

frenck commented 3 years ago

I have seen this error as well past days, but is has also disappeared again. At this point, it looks like an issue upstream.

salty-p commented 3 years ago

Hi! I can also confirm the same error as @renejorissen. I updated yesterday to 2021.3.1 and the problem persists today after updating to 2021.3.2 and rebooting a couple of times.

EDIT: Problem solved for me by changing password to something without special characters (in my case 'ä')

renejorissen commented 3 years ago

Hi - can confirm what @renejorissen is listing above on my side as well. Integration for Verisure working as a charm until update to: 2021.3.0 of HA. Reverting back to previous snapshot.

@br4tt3: to which version did you revert back?? I forgot to create a snapshot and I will try to downgrade via CLI. 2021.3.1 and 3.2 don't seem to solve the issue.

frenck commented 3 years ago

There is no use in reverting, as there has not been a change in this part; it is an upstream issue.

renejorissen commented 3 years ago

Strange thing is, that I don't see any traffic to Verisure / Securitas IP addresses in my firewall since the upgrade.

renejorissen commented 3 years ago

@frenck maybe you are right. I tried a simple Python script to get some info via the API.

Invalid response, status code: 401 - Data: <response><status><errorGroup>UNAUTHORIZED</errorGroup><errorCode>ACC_00002</errorCode><errorMessage>Too many step up tokens sent.</errorMessage><tooManyStepUpTokens>true</tooManyStepUpTokens></status></response> Invalid response, status code: 401 - Data: <response><status><errorGroup>UNAUTHORIZED</errorGroup><errorCode>ACC_00002</errorCode><errorMessage>Too many step up tokens sent.</errorMessage><tooManyStepUpTokens>true</tooManyStepUpTokens></status></response>

I will try and see if I can contact Verisure to get some more information. I also disabled the integration and maybe the "timer" is automatically reset after some time.

br4tt3 commented 3 years ago

Hi - can confirm what @renejorissen is listing above on my side as well. Integration for Verisure working as a charm until update to: 2021.3.0 of HA. Reverting back to previous snapshot.

@br4tt3: to which version did you revert back?? I forgot to create a snapshot and I will try to downgrade via CLI. 2021.3.1 and 3.2 don't seem to solve the issue.

Hi - I had a snapshot of 2021.2.3 which i reverted back to. Bom, started working again and have not been a problem since.

renejorissen commented 3 years ago

I downgraded to 2021.2.3 and you are right. Verisure connection is working straight away, so there seems to be some kind of change in the HA version 2021.3.x.

robinostlund commented 3 years ago

i also got the same issue today, and saw a new news from verisure, they are forcing 2 factor authentication for login to mypages. Guess this is causing the error?

robinostlund commented 3 years ago

You can login to your account in the web browser and disable 2 factor authentication, that solved it for me.

lazyoldbear commented 3 years ago

How do you disable it? Can't find any settings neither in a dedicated HA profile, nor in admin user pages.

eddysteurs commented 3 years ago

have exactly the same problem, today after going to 2021.3.3 it gave the errors mentioned above, converted back to 2021.2.3 (restoring intermediate snapshots did not solve the problem, although it worked for a number of days on 2021.3.2) The 2 factor authentication I had to disable already last week. Can anyone confirm if it is now a password problem, upstream (verisure) or can we upgrade HA to 2021.3.3?

frenck commented 3 years ago

I run 2021.4.0dev, which does not have any problems with authentication (but requires 2FA to be disabled at this point).

lazyoldbear commented 3 years ago

I am sorry to repeat a silly trivial question, but can someone give a hint on disabling 2FA with Verisure? Is it even possible in Norway?

eddysteurs commented 3 years ago

I am sorry to repeat a silly trivial question, but can someone give a hint on disabling 2FA with Verisure? Is it even possible in Norway?

It is in Belgium: go to mypages website, then account and services => Log-in => look for 2 factor authentication

lazyoldbear commented 3 years ago

Ah. Then I guess they just don't let it here, for I obviously started around there...

fnordpojk commented 3 years ago

Ah. Then I guess they just don't let it here, for I obviously started around there...

They do in Sweden at least. Log into MyPages, then go to Konto och avtalsinformation -> Konto -> Inloggningsuppgifter -> Avaktivera tvåstegsverifiering. I'm guessing the labels would be almost the same in Norwegian.

However, my problem is that I'm getting the "No schema supplied" error even after I've disabled the 2FA..

martycochrane commented 3 years ago

Just this week verisure seem to have forced text message 2FA and then i got this email today. Seems there's no way to generate an access key or anything like that instead 😞

Information to users with a third-party integration to Verisure

Our system indicates that you are using a third-party integration to connect to Verisure functionality. If this is not the case, you can ignore this email. Otherwise, please continue reading. Third-party integrations are not an officially sanctioned way to connect to Verisure. However, we hope that you are happy with the functionality provided through MyPages and Verisure app and will continue to use it. This email contains instructions for how to use third-party integrations together with 2-step verification. Our goal is to keep our customers safe and secure. This includes maintaining a high security level for your Verisure account and reduce the risk of unauthorized access.In the next couple of weeks, we will therefor introduce 2-step verification for all logins to MyPages and the Verisure app. Once 2-step verification is enabled for your account, you will need a one-time code in addition to your username and password.

Preparation for 2-step verification

Please complete the following steps to prepare for 2-step verification.Go to Account in MyPages to check that your registered phone number is correct.Make sure that all users with access to your Verisure system have their own Verisure account.If there are users who share accounts, please ask the system owner or administrators to create individual accounts for them. This is done under Users in My Pages. It is very important to have individual accounts with the correct phone number for each user. It ensures that the verification code is sent to the correct user and device at login. If your alarm system is connected to the Verisure Monitoring Center, it also makes sure that the Verisure first responders can reach you in case of an emergency. This is especially important if you use mobile SOS services such as Verisure Guardian.

How does 2-step verification affect third-party integrations with Verisure?

When 2-step verification is enabled, your connection through the third-party integration might stop working. Please note that if you disable 2-step verification, the risk of unauthorized access to your account is increased. Follow these steps to restore the connection:Log in to MyPages with your username and password. Enter the verification code when you receive it.Go to Account and Subscription > Account > Login credentials > Disable 2-step verificationFollow the instructions to disable 2-step verification. In order for us to get valuable input for potential future improvements for users that have a 3rd party integration to Verisure, we have created a short survey as part of the Disable 2-step verification steps. Best regardsVerisure

tubalainen commented 3 years ago

Just a thought - Would it be feasible as part of a future configuration flow making the Home Assistant instance a "Verisure trusted device" and that way keep the 2FA setting intact?

I can confirm that after disabling the 2FA via the web browser for the account used with the Verisure component works again.

lazyoldbear commented 3 years ago

I got it. When I try to reach ...no/logincredentials, I get back to the status page with any user. Probably a trouble on their side. Reached support (but it is usually completely useless), and hope it will fix itself when they reboot something. Verisure is, indeed, consistent in embarrassing themselves. I am angry.

timbba80 commented 3 years ago

I'm also facing this issue since today (after I had to reboot. HA). 2fa has been disabled, but not fixing the issue.

frenck commented 3 years ago

@timutta Could you a bit more specific? Like, error in the logs? There is nothing in your last comment that could help towards fixing an issue.

timbba80 commented 3 years ago

It's basically same situation than in the first post in this discussion.

Logger: homeassistant.setup Source: components/verisure/init.py:183 First occurred: 10:16:25 PM (1 occurrences) Last logged: 10:16:25 PM

Error during setup of component verisure Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/verisure/session.py", line 147, in get_overview response = requests.get( File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 76, in get return request('get', url, params=params, kwargs) File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request return session.request(method=method, url=url, kwargs) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 528, in request prep = self.prepare_request(req) File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 456, in prepare_request p.prepare( File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 316, in prepare self.prepare_url(url, params) File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 390, in prepare_url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL 'None/xbn/2/installation/None/overview': No schema supplied. Perhaps you meant http://None/xbn/2/installation/None/overview?

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component result = await task File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, *self.kwargs) File "/usr/src/homeassistant/homeassistant/components/verisure/init.py", line 82, in setup HUB.update_overview() File "/usr/src/homeassistant/homeassistant/util/init.py", line 285, in wrapper result = method(args, **kwargs) File "/usr/src/homeassistant/homeassistant/components/verisure/init.py", line 183, in update_overview self.overview = self.session.get_overview() File "/usr/local/lib/python3.8/site-packages/verisure/session.py", line 152, in get_overview raise RequestError(ex) verisure.session.RequestError: Invalid URL 'None/xbn/2/installation/None/overview': No schema supplied. Perhaps you meant http://None/xbn/2/installation/None/overview?

frenck commented 3 years ago

Thanks! 👍

fnordpojk commented 3 years ago

Update: Never mind, I'm apparently stupid.

I interpreted the email wrong when it said that disabling 2FA would disable it for my account, which I interpreted as all users on my system (since they can't make up their mind and mix the terms account, user and login interchangeably), when they actually meant my particular user login.

When I logged into the separate Home Assistant user I have on my system and disabled 2FA there, everything started working..

timbba80 commented 3 years ago

This is weird...yesterday I did log in to Verisure mypages and did disable 2FA by using mobile phone (also did fill in the survey they ask you to fill in if you disable 2FA and did confirm with my password + SMS confirmation).

I did check later on in the evening from my mobile phone that the 2FA was really disabled. What was weird was that I had either no option to enable 2FA again (the option was completely gone).

Today, when I did use my laptop to login to mypages (with same account), it again asked for 2FA, and in settings I was able to see that 2FA was enabled. After disabling it again from my laptop (and again filling the same survey), and after reboot of Home Assistant, Verisure integration in Home Assistant started to work again.

I am not sure what has caused this, maybe the fact that when I did log in with my mobile, I defined the device as a trusted device (when as with my laptop I did not do this), or then Verisure themself have still some challenges with enabling/disabling this option (ref. to the statement above, where I lost completely the option last night to enable 2FA again).

All in all, it's working again. I would love to have 2FA enabled (but not by using SMS, preferably authenticator app), but the benefits of integrating verisure with HA are something I want to also keep (e.g. when everyone are leaving from home, alarm is automatically triggered, when alarm is triggered, water is cut off etc...).

renejorissen commented 3 years ago

I see a lot of people having "issues" after Verisure enabled 2FA, but what I would like know: is your Verisure integration still working after upgrading to 2021.3.0 or higher?

I tried another upgrade to 2021.3.3, but I had to revert back to the 2021.2.3 snapshot, since the integration doesn't work in my environment.

martycochrane commented 3 years ago

I see a lot of people having "issues" after Verisure enabled 2FA, but what I would like know: is your Verisure integration still working after upgrading to 2021.3.0 or higher?

I tried another upgrade to 2021.3.3, but I had to revert back to the 2021.2.3 snapshot, since the integration doesn't work in my environment.

2021.3.3 seems to be working fine for me 🤔

dodg3r commented 3 years ago

Hi.

I discovered that my restricted verisure account doesnt work with hass. Even if I disabled 2FA. If I try to login with my administrator verisure account then hassintegration works.

/Jerry

tubalainen commented 3 years ago

Hi.

I discovered that my restricted verisure account doesnt work with hass. Even if I disabled 2FA. If I try to login with my administrator verisure account then hassintegration works.

/Jerry

I have the exact same experience.

dsvens commented 3 years ago

Hi.

I discovered that my restricted verisure account doesnt work with hass. Even if I disabled 2FA. If I try to login with my administrator verisure account then hassintegration works.

/Jerry

I use a restricted account for HA. To disable 2FA I had to temporarily change it to an admin account. After reboot, everything was back to normal.

Edit: Version 2021.3.3

/Daniel

tubalainen commented 3 years ago

Hi. I discovered that my restricted verisure account doesnt work with hass. Even if I disabled 2FA. If I try to login with my administrator verisure account then hassintegration works. /Jerry

I use a restricted account for HA. To disable 2FA I had to temporarily change it to an admin account. After reboot, everything was back to normal.

/Daniel

AH! Good finding, could not find that setting for "restricted accounts" in Verisures UI. Will test that, thanks! <3

dodg3r commented 3 years ago

Yes.

I thought that if i disabled 2FA on my admin-accouns then it would affect all of my accounts.

/Jerry

martycochrane commented 3 years ago

Summary of what to do if you have this issue

Update: Based on some comments below. You don't have to create a new user for home assistant. You can simply just remove 2fa from your admin account but this is not as secure so the way below is the most secure way to do it in my eyes. Also some people report problems if their password has special characters in it but I haven't tested this myself

  1. Create a Home Assistant Specific User in verisure my pages
  2. Make sure that user is admin, you've logged in & setup 2fa
  3. Once you've done 1&2 this user should be able to disable 2fa. Login as the home assistant user, browse to Account and subscription -> Account -> Login Credentials -> Disable 2fa Note this will only be available if the user is admin and has logged in once with 2fa, logged out and in again
  4. Login as your administrator again and change the home assistant user to a restricted user
  5. Change verisure config to new user in home assistant
  6. Restart home assistant
renejorissen commented 3 years ago

@martycochrane: I have done all that, and that works. But for me only in 2021.2.3 and not for 2021.3.0 or higher.

dodg3r commented 3 years ago

It works for me in 2021.3.3

dsvens commented 3 years ago

Version 2021.3.3 here.

eddysteurs commented 3 years ago

I tried for the 3rd time to goto 2021.3.3 (from 2012.2.3) and now it seems to work.

lazyoldbear commented 3 years ago

Hi. I discovered that my restricted verisure account doesnt work with hass. Even if I disabled 2FA. If I try to login with my administrator verisure account then hassintegration works. /Jerry

I use a restricted account for HA. To disable 2FA I had to temporarily change it to an admin account. After reboot, everything was back to normal.

Edit: Version 2021.3.3

/Daniel

Ah!!!! I just came home thinking that this might help. And it did. What a spectacular embarrassment for Verisure. Good thing (enforced 2FA) done in the such an inappropriate way....

Hubszo commented 3 years ago

@martycochrane

  1. HA 2021.3.3
  2. Turning 2FA off on Verisure MyPage did the trick.
  3. No need to create new user with admin access on Verisure MyPage. As a system owner I just had necessary access to turn off 2FA.
  4. @lazyoldbear I'm in Norway :)
jacobwod commented 3 years ago

Thanks @martycochrane, works like a charm on latest (2021.3.3).

FransSorensen commented 3 years ago

Followed the instructions above, but it didn't work. Then I changed the password removing some special letters and now the integration works again.

martycochrane commented 3 years ago

@martycochrane

  1. HA 2021.3.3
  2. Turning 2FA off on Verisure MyPage did the trick.
  3. No need to create new user with admin access on Verisure MyPage. As a system owner I just had necessary access to turn off 2FA.
  4. @lazyoldbear I'm in Norway :)

The problem with this is then you don't have 2fa for your admin or system owner account essentially meaning your verisure account isn't as secure. The only reason I create a restricted user is to make sure it's only that user that doesn't have 2fa and my system owner account is as secure as possible

Knodd commented 3 years ago

I can also confirm @martycochrane solution works. I deactivated 2FA on my main user (system owner) and that did not help since I use a separate user for HA which is minimum user (only read access). I changed my HA user to administrator and then I could disable 2FA and change the user back to minimum. I now have 2FA activeated for my main user and 2FA disabled for the user with read only access so security should not be an issue.

Home the mini survey means they now consider supporting smart home systems and that we soon see push status and alerts inststead of polling via mypages

lazyoldbear commented 3 years ago

Perhaps an update of the component documentation is necessary, and possibly some logic to warn about it, like catching the failures and suggest checking for 2FA in a persistent notification.

lazyoldbear commented 3 years ago

And also maybe it is time for a futile attempt to help Verisure achieve a more sensible stance about integrations. The right way would be machine-only accounts (no web) with precise ACL. And it is not a big deal to make.

It is obvious that there is a business aspect (they want to sell cameras themselves, and don't want too much flexibility), but there is a reasonable middle ground there.

If someone is able to drive the conversations, I am happy to contribute with both technology and legal considerations on how to deal with that.

frenck commented 3 years ago

Perhaps an update of the component documentation is necessary, and possibly some logic to warn about it, like catching the failures and suggest checking for 2FA in a persistent notification.

The problem is, is that we can't at this point. The upstream library catches and suppresses all these errors at this moment in time. This makes it impossible for Home Assistant to act on any authentication issue.

I've opened a PR upstream to adjust that behavior: https://github.com/persandstrom/python-verisure/pull/129

lazyoldbear commented 3 years ago

That is good. Yet regardless of that we can shout a concern: "Look! Some shit happened! Could it be 2FA?" I would say, though, that handling broken integrations when the nature of failure is unknown is something that might benefit from improvement not only for alarm systems.