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
72.98k stars 30.53k forks source link

Sure Petcare Integration setup not working #107147

Closed Malaber closed 8 months ago

Malaber commented 9 months ago

The problem

When trying to setup the Sure Petcare Integration, I get the error "Failed to connect". The credentials are correct though and I would assume the error would be something else if they mismatched.

What version of Home Assistant Core has the issue?

core-2023.11.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Sure Petcare

Link to integration documentation on our website

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

Diagnostics information

I cannot provide data as I am trying to setup the device and therefore do not have it in hass yet.

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No log entry while clicking the button and getting the error message.

Additional information

No response

home-assistant[bot] commented 9 months ago

Hey there @benleb, @danielhiversen, mind taking a look at this issue as it has been labeled with an integration (surepetcare) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `surepetcare` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign surepetcare` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


surepetcare documentation surepetcare source (message by IssueLinks)

ChristophCaina commented 9 months ago

Hi, I faced similar issues with my surepet integration yesterday - and I had the feeling, that also the app was responding very slow. Right now, I think there was / is an issue with the cloud service.

You COULD cross-check this by adding the SureHA custom integration. Both, the SureHA and the SurePetcare Component are using "SurePy" - the library, which connects to the Cloud Service.

Please try the setup another time to check, if the issue is still present or not.

Malaber commented 9 months ago

The problem still exists. But I did some research, apparently the API changed recently. https://community.home-assistant.io/t/sureflap-connect-pet-door/41488/705

How do I get a newer version of surepy? Will that just be included with a newer HASS version? Or can I update manually?

You COULD cross-check this by adding the SureHA custom integration. Both, the SureHA and the SurePetcare Component are using "SurePy" - the library, which connects to the Cloud Service.

I am quite new to HASS and have not found how to install the SureHA integration. I am willing to try it of course, just did not figure out how to yet.

ChristophCaina commented 9 months ago

Hey :) I don't think that the API change, mentioned in that link is causing the issues. I am also using SurePetcare for a couple of days now - and do not face such issues at the moment.

Yesterday, there were some outages ... but either due to network issues or due to issues on the cloud service in generall.

From what I know, the SurePetcare integration is using the latest version of SurePy So there isn't much for you to update atm.

To try SureHA, you can use the HomeAssistant Community Store - but this would also depend on how you have HomeAssistant installed (OS, Core, Supervised, etc.)

Malaber commented 9 months ago

I am running HASS on docker container(s). I installed HACS and downloaded the SureHA integration from the HACS store. But now I don't know how to proceed. The installation window said after installation and restart I should visit /config/custom_components/sureha but this page is empty.

ChristophCaina commented 9 months ago

You can Just Check If it is available in your device list (Like Sure petcare)

Screenshot_20240105-123951

ChristophCaina commented 9 months ago

update: Maybe, there IS a bigger issue. The issues I've noticed yesterday evening when the cat entered the house remains today. The "home" status will not be updated - and also not the "away" status when the cat left the house again.

I switched debug level on for surepetcare and sureha and will provide updates when I see something relevant.

bobjoylove commented 9 months ago

+1 this has been broken for me for a couple of weeks. I try to log in and I get

Config entry 'Sure Petcare' for surepetcare integration could not authenticate: Invalid username/password 8:30:54 PM – (WARNING) config_entries.py - message first occurred at January 3, 2024 at 11:40:52 PM and shows up 5 times

password has been validated by logging in using the app and the password.

Here’s what I get with SureHA using HACS:

Success! Created configuration for Sure Petcare.

We found the following devices:

[my devices]

ChristophCaina commented 9 months ago

@bobjoylove can you maybe open an issue in SurePy? I bet, that you should get the same error when you are trying to use the SurePetcare core integration?

I don't really know if the login issue is related - but it might be, that there was a change when surepy reads the household information, since this is throwing an 404 (not found) error.

andersovreseth commented 9 months ago

I also have problems with my Sure Petcare integration in HA. Since January 3rd I get no response and the following errors in the logs: Logger: surepy.client Source: components/surepetcare/init.py:209 First occurred: 24. januar 2024 kl. 20:27:43 (846 occurrences) Last logged: 15:19:44

🐾 · GET app.api.surehub.io/api/me/start: 401 | <ClientResponse(https://app.api.surehub.io/api/me/start) [401 Unauthorized]> <CIMultiDictProxy('Date': 'Thu, 25 Jan 2024 14:14:20 GMT', 'Content-Length': '0', 'Connection': 'keep-alive', 'Server': 'nginx', 'Access-Control-Allow-Origin': '*', 'WWW-Authenticate': 'Bearer error="invalid_token", error_description="The token expired at \'01/03/2024 23:48:52\'"', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains; preload', 'X-Frame-Options': 'DENY', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block')>

I tried working around this by adding the SureHA through HACS, but when sending in validated user / pass combination the SureHA just exits with a blank / white message like so:

image

Malaber commented 9 months ago

It almost looks like having no local access to my own hardware is a bad idea..

andersovreseth commented 9 months ago

Yes you are right about that, but what alternatives do I really have? Vender control

benleb commented 9 months ago

what a mess -.- seems would be coolest to review all api calls and adapt to the „new“ sure petcare api… will try to find some hours this weekend ✊

On Thu, Jan 25, 2024 at 19:06 andersovreseth @.***> wrote:

Yes you are right about that, but what alternatives do I really have? Vender control

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/107147#issuecomment-1910728408, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD5HZIPJEG5FCAN6NIFFCDYQKNIVAVCNFSM6AAAAABBNGAABGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJQG4ZDQNBQHA . You are receiving this because you were mentioned.Message ID: @.***>

Malaber commented 9 months ago

Yes you are right about that, but what alternatives do I really have?

First of all I am blaming vendors, not you. Secondly; we 'just' have to reverse engineer the protocol used by the hub like pethublocal tried to.

riemers commented 9 months ago

https://github.com/benleb/surepy/issues/208 no luck on that part yet either.

andersovreseth commented 9 months ago

Yes you are right about that, but what alternatives do I really have?

First of all I am blaming vendors, not you. Secondly; we 'just' have to reverse engineer the protocol used by the hub like pethublocal tried to.

Yes, this would be excellent. For me I would stille like to be able to use the flap "standalone", so a requirement would then be that the HA integration can talk to a local API but that the hub at the same time can talk to surecares own service. I this makes sense.

Malaber commented 9 months ago

Why do you need the hub to talk to sure simultaneously?

neutronwrangler commented 9 months ago

Suddenly stopped working two days ago whilst I was away (last entry in battery monitor was 20:15 28/1/24 UT), I had not changed anything before I went away. Looks like the authentication model has changed.

2024-02-01 14:48:12.373 ERROR (MainThread) [surepy.client] 🐾 · GET app.api.surehub.io/api/me/start: 401 | <ClientResponse(https://app.api.surehub.io/api/me/start) [401 Unauthorized]> 2024-02-01 14:48:13.245 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Sure Petcare' for surepetcare integration could not authenticate: Invalid username/password

andersovreseth commented 9 months ago

Why do you need the hub to talk to sure simultaneously?

So that I can also keep the "native" app from Sure working in addition to my own setup in IOS Home app via HA.

jbruntt commented 8 months ago

I have had this Integration running for some months now. It stopped working a couple of weeks ago. I checked that I can log in using a browser at https://surepetcare.io/dashboard using the same e-mail address and password I am using when configuring the Integration. I have enabled debugging and then run the "Reconfigure" which ends up with Failed to setup. Here is som cleaned up log. One thing that stands out for me is this: The token expired at 01/22/2024 13:28:09

2024-02-07 15:19:17.596 DEBUG (MainThread) [surepy.client] initialization completed | vars(): {'self': <surepy.client.SureAPIClient object at 0x7fc86f677250>, 'email': 'hola@spamgourmet.com', 'password': 'passwordwashere', 'auth_token': None, 'api_timeout': 60, 'session': <aiohttp.client.ClientSession object at 0x7fc8b23adb50>, 'surepy_version': '0.9.0', 'token': None}
2024-02-07 15:19:17.596 DEBUG (MainThread) [surepy] initialization completed | vars(): {'self': <surepy.Surepy object at 0x7fc87b740510>, 'email': 'hola@spamgourmet.com', 'password': 'passwordwashere', 'auth_token': None, 'api_timeout': 60, 'session': <aiohttp.client.ClientSession object at 0x7fc8b23adb50>}
2024-02-07 15:19:18.096 DEBUG (MainThread) [surepy.client] initialization completed | vars(): {'self': <surepy.client.SureAPIClient object at 0x7fc8600f9050>, 'email': 'hola@spamgourmet.com', 'password': 'passwordwashere', 'auth_token': 'longtokenwashere', 'api_timeout': 60, 'session': <aiohttp.client.ClientSession object at 0x7fc8b23adb50>, 'surepy_version': '0.9.0'}
2024-02-07 15:19:18.097 DEBUG (MainThread) [surepy] initialization completed | vars(): {'self': <surepy.Surepy object at 0x7fc872090350>, 'email': 'hola@spamgourmet.com', 'password': 'passwordwashere', 'auth_token': 'longtokenwashere', 'api_timeout': 60, 'session': <aiohttp.client.ClientSession object at 0x7fc8b23adb50>}
2024-02-07 15:19:18.307 ERROR (MainThread) [surepy.client] 🐾 · GET app.api.surehub.io/api/me/start: 401 | <ClientResponse(https://app.api.surehub.io/api/me/start) [401 Unauthorized]>
<CIMultiDictProxy('Date': 'Wed, 07 Feb 2024 14:19:18 GMT', 'Content-Length': '0', 'Connection': 'keep-alive', 'Server': 'nginx', 'Access-Control-Allow-Origin': '*', 'WWW-Authenticate': 'Bearer error="invalid_token", error_description="The token expired at \'01/22/2024 13:28:09\'"', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains; preload', 'X-Frame-Options': 'DENY', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block')>

2024-02-07 15:19:18.827 DEBUG (MainThread) [surepy.client] 🐾 · GET app.api.surehub.io/api/me/start | 6
2024-02-07 15:19:18.827 DEBUG (MainThread) [homeassistant.components.surepetcare] Finished fetching surepetcare data in 0.730 seconds (success: False)
2024-02-07 15:19:18.827 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Sure Petcare' for surepetcare integration could not authenticate: Invalid username/password
andersovreseth commented 8 months ago

@benleb did you have any time to look at this at all?

dynamiccarrots commented 8 months ago

@benleb did you have any time to look at this at all?

I have just run all my updates and it is now working by the looks of things

neutronwrangler commented 8 months ago

@benleb did you have any time to look at this at all?

I have just run all my updates and it is now working by the looks of things

How did you reauthenicate, or did you not have to?

I've just updated and on restart had the same error, when clicking on the link and re-entering the password I get the same dialog with only Sure Petcare and CLOSE

Is there another way?

andersovreseth commented 8 months ago

Is the right way to update to download the dev version of the Sureha integration in HACS and then restart HA? Or is there another way to get the latest code?

Timmo3 commented 8 months ago

I had the same problem. Removing the integration and reinstalling the integration worked fine.

neutronwrangler commented 8 months ago

I can confirm that removing the integration, re-adding and authenticating fixes the problem.

All entities and history are preserved, except of course the history when it could not connect.

Mattheo1985 commented 8 months ago

Worked for me too!

jbruntt commented 8 months ago

Worked for me as well.

dirkjanvanvliet commented 8 months ago

My integration stopped working a few days ago. Can confirm removing and adding again worked for me too.

Malaber commented 8 months ago

For me it does not work, I still get "Failed to connect" (And yes, I checked my password 5 times, it is correct, also it would probably say "incorrect password" or something like that if that was the problem) and see nothing in the logfile.

Malaber commented 8 months ago

NVM; after updating to latest homeassistant it works for me too. Problem seems fixed; closing.