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
69.86k stars 28.96k forks source link

Honeywell TCC device unavailable #98763

Closed deepschiff closed 10 months ago

deepschiff commented 10 months ago

The problem

Using Honeywell TCC (US), the integration successfully adds the thermostat, but then the thermostat device becomes unavailable after a few seconds. When I go to https://www.mytotalconnectcomfort.com/portal/ and login, I can sometimes login, other times it gives an "unexpected error processing request" or "Too many attempts, You have exceeded the maximum number of attempts. Please try again in a few minutes."

When I turn off the integration, the error on the website goes away and I am able to login 100% of the time without error.

I am able to add and manage the thermostat directly into Google Assistant with the works with Google integration. Obviously direct integration to HA would be preferable.

The errors in the logs repeat every 30 seconds that the integration is setup.

What version of Home Assistant Core has the issue?

core-2023.8.3

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

Honeywell Total Connect Comfort (US)

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-08-21 11:44:25.287 ERROR (MainThread) [somecomfort] 401 Error at update (Key expired?).
2023-08-21 11:44:25.445 ERROR (MainThread) [somecomfort] Login null cookie - site may be down
2023-08-21 11:44:55.299 ERROR (MainThread) [somecomfort] 401 Error at update (Key expired?).
2023-08-21 11:45:25.276 ERROR (MainThread) [somecomfort] 401 Error at update (Key expired?).

Additional information

No response

home-assistant[bot] commented 10 months ago

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

Code owner commands Code owners of `honeywell` 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 honeywell` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


honeywell documentation honeywell source (message by IssueLinks)

mkmer commented 10 months ago

Please share a debug log. Also, how many T-stats on your account?

I believe this is related or similar to https://github.com/home-assistant/core/issues/98035

deepschiff commented 10 months ago

home-assistant_honeywell_2023-08-21T16-16-20.749Z.log

I enabled debug logging, removed the entry and readded the entry but all that shows in the logs is the same errors posted above.

There is only 1 thermostat in the account.

It does look like a similar issue to #98035

mkmer commented 10 months ago

I did find a bug in the API code where it would attempt to log in for each mismatch thermostat, exceeding the rate limit. I don't see the full debug information - maybe you could turn on logging for the API? That would help me see the first event that gets it into the re-login state. Add the line somecomfort: debug in the configuration.yaml under the logger: logs: and restart.

FYI: I'm running the integration myself with 1 Tstat - haven't been having the issue :( I'll need the feedback/logs to help figure it out.

deepschiff commented 10 months ago

I enabled debugging in the logs in the configuration.yaml but don't get any actual debug logs. I still only get the statements above. I tried removing the integration and re-adding it with debug logging enabled and see zero somecomfort logs until the errors.

mkmer commented 10 months ago

I should have said: AIOSomecomfort: debug - please give it a try

deepschiff commented 10 months ago

Same issue. First log is: 2023-08-22 13:34:48.654 ERROR (MainThread) [somecomfort] 401 Error at update (Key expired?).

mkmer commented 10 months ago

Well that stinks (logs).
I did notice in my log files that it goes unavailable a few times / day but recovers automatically within 3 minutes. I believe that the API decides you have tried to log in to many times and HA keeps trying, not allowing the 5 minute login "timeout"/rate limit to expire. I released the API version 0.0.16 that limits login attempts to 5 minutes after 3 tries, and it has been merged. If you know how, you can change the manifest file to use 0.0.16 for Honeywell in your current install, restart, and try it out (that would be great!). Otherwise it should be available in 2023.9 (it wasn't tagged for 2023.8.4).

Going unavailable is not something I can fix, but recovery should be automatic :)

mydevpeeps commented 10 months ago

I am seeing this as well on my system. I have one Thermostat on my account and configured in HA. I am able to login to the portal also and HA does seem to be working so I am not sure where these log entries are coming from.


2023-08-22 15:52:54.867 ERROR (MainThread) [somecomfort] API returned 200 from /portal/Device/CheckDataSession/7781659 request
2023-08-22 15:52:57.368 ERROR (MainThread) [somecomfort] Login as first.last@redacted.com failed
2023-08-22 15:53:22.255 ERROR (MainThread) [somecomfort] 401 Error at update (Key expired?).
mkmer commented 10 months ago

The 401 error is "normal" when the key expires, or when the host decides to log you out. The integration attempts to login when this happens. If it fails to login, it will mark the entity as unavailable. Since we are scanning at 30 second intervals, when/if the host decides we have tried to login to many times, it would lock you out. For this situation, I've limited logins to a 5 minute period after 3 tries. This should keep the integration from getting "stuck" at the API rate limit.

@deepschiff - are you having an issue or just seeing this log entry?

mkmer commented 10 months ago

I am seeing this as well on my system. I have one Thermostat on my account and configured in HA. I am able to login to the portal also and HA does seem to be working so I am not sure where these log entries are coming from.

2023-08-22 15:52:54.867 ERROR (MainThread) [somecomfort] API returned 200 from /portal/Device/CheckDataSession/7781659 request
2023-08-22 15:52:57.368 ERROR (MainThread) [somecomfort] Login as first.last@redacted.com failed
2023-08-22 15:53:22.255 ERROR (MainThread) [somecomfort] 401 Error at update (Key expired?).

This too is "normal" The 200 is the web site returning a NON JSON response when it should have been JSON. Usually this is an expired key as well. What I don't like is marking the entity as unavailable when it's just doing a refresh on the login. @mydevpeeps: are you seeing unavailability for 2 - 3 minutes in your entity log a couple times/day?

mkmer commented 10 months ago

It appears that honeywell is now reporting "unexpected error" as the non JSON body when an update is requested. This must be fairly new behavior as I had not noticed it. I have something in the works, testing for a bit yet today. Hopefully we can get it in for 2023.9.