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.58k stars 30.75k forks source link

Home Connect not updating states properly #66063

Closed stomko11 closed 1 year ago

stomko11 commented 2 years ago

The problem

I am using core integration Home Connect with my Bosch Dryer. Issue is - when dryer goes off, so does wifi. However state of some entities remain. For instance door state, remaining program time, etc. Which makes it difficult to use states in automations. When I open Home Connect app on my android phone, it reports correctly that it could not connect to the device. Thus I would expect entities to become unavailable for instance, and not remember the last state, or time since program finished.

At this moment, dryer is turned off (wifi off), yet it shows power as "on". In addition, entitities like "Duration" or "Program Progress" are never available.

image image

What version of Home Assistant Core has the issue?

core-2022.2.3

What was the last working version of Home Assistant Core?

N/A

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Home Connect

Link to integration documentation on our website

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

Diagnostics information

N/A

Example YAML snippet

N/A

Anything in the logs that might be useful for us?

N/A

Additional information

I would expect for these entities to be "unavailable" once appliance is turned off.

probot-home-assistant[bot] commented 2 years ago

home_connect documentation home_connect source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @davidmstraub, mind taking a look at this issue as it has been labeled with an integration (home_connect) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

Vabis1010 commented 2 years ago

had the same thing here. Then when i restartet home assistant everything was ok. All status wenty to not availibale. Will try andf look again tomorrow. Will report it back here.

stomko11 commented 2 years ago

The problem is broader. As I was in the middle of drying process, I restarted the HA. Most of entities went to unavailable state, despite they should reflect some state (like timer left on program). So the responsiveness is really poor. When my drying cycle is completed, I get the notification from Android Home Connect app that it is finished, but states of entities do not reflect that at all. According to the HA/Home Connect integration, it is still in progress, switch associated with "power" and drying program are still "on", timer just switches from "XX minutes" and starts counting how much time passed since it last reported it, but program is still in "Run". So basically any automations I tied to state (Run, Idle, ...) are pointless.

stomko11 commented 2 years ago

For instance, today, the operation state did not change to "Run" at all, during whole drying process. It just stayed at "Idle" since last cycle. Android app, on the other hand reflected that and also sent notification upon completition.

Vabis1010 commented 2 years ago

Today heren everything went well until program finished. Automation for finishen went well but program all statussen where still active.

Outlook voor Androidhttps://aka.ms/AAb9ysg downloaden


From: stomko11 @.> Sent: Saturday, February 12, 2022 3:14:10 PM To: home-assistant/core @.> Cc: Vabis1010 @.>; Comment @.> Subject: Re: [home-assistant/core] Home Connect not updating states properly (Issue #66063)

For instance, today, the operation state did not change to "Run" at all, during whole drying process. It just stayed at "Idle" since last cycle. Android app, on the other hand reflected that and also sent notification upon completition.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/66063#issuecomment-1037237056, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUUBXGWIVGLF746EVTDR42TU2ZTLFANCNFSM5NZ55CNQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***>

Vabis1010 commented 2 years ago

After reload integration everything was o.k. again.

Outlook voor Androidhttps://aka.ms/AAb9ysg downloaden


From: Bammens Kruf @.> Sent: Saturday, February 12, 2022 3:16:56 PM To: home-assistant/core @.>; home-assistant/core @.> Cc: Comment @.> Subject: Re: [home-assistant/core] Home Connect not updating states properly (Issue #66063)

Today heren everything went well until program finished. Automation for finishen went well but program all statussen where still active.

Outlook voor Androidhttps://aka.ms/AAb9ysg downloaden


From: stomko11 @.> Sent: Saturday, February 12, 2022 3:14:10 PM To: home-assistant/core @.> Cc: Vabis1010 @.>; Comment @.> Subject: Re: [home-assistant/core] Home Connect not updating states properly (Issue #66063)

For instance, today, the operation state did not change to "Run" at all, during whole drying process. It just stayed at "Idle" since last cycle. Android app, on the other hand reflected that and also sent notification upon completition.

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/66063#issuecomment-1037237056, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUUBXGWIVGLF746EVTDR42TU2ZTLFANCNFSM5NZ55CNQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***>

slecram commented 2 years ago

maybe the same issue? #65310

bernji commented 2 years ago

I can confirm the issue. At 1 AM I use the knx plugin to turn off the power in my dishwasher (SBV6ZCX49E) and oven (HSG636XS6) to save stand by power. I then turn on the power at 7 am. I noticed that home assistant is a) not showing states of my dishwasher and oven or b) show the old states before I turned off the power UNTIL I reload the integration. After the reload all properties are shown (once new values are there). This is strange and indicates that there is something wrong with the integration.

I also observed that after the reload that e.g. the property "door" is "unavailable" until I open or close the door (whatever comes first) - then the values are shown. I think this is fine as it is cloud push. Values can only be shown until they are send by home connect and could be related to https://github.com/home-assistant/core/issues/65310. That values are only shown after the integration is reloaded is probably not related

stomko11 commented 2 years ago

Can anyone actually look into integration and fix it, or is this thread only about summarizing issues? Basically, it is useless. I can't build any automation based on reported states.

slecram commented 2 years ago

@DavidMStraub?

marconr9 commented 2 years ago

any news ?

DavidMStraub commented 2 years ago

@DavidMStraub?

I don't have time to support.

Patrick-UK commented 2 years ago

Unfortunately this is becoming a common theme across HA, integrations go into CORE then the original maintainers don't have time to maintain or they no longer have the item in their homes to help update. I have two different integrations in this state currently. I am currently looking at the Home Connect integration in Node-Red now.

BraveChicken1 commented 2 years ago

I recently made some changes to this integration. In the HomeConnect library repository is a PR to improve event stream reading, I think that PR could fix some issues with wrong entity states.

DavidMStraub commented 2 years ago

Unfortunately this is becoming a common theme across HA, integrations go into CORE then the original maintainers don't have time to maintain or they no longer have the item in their homes to help update. I have two different integrations in this state currently. I am currently looking at the Home Connect integration in Node-Red now.

So what? There have already been several merged PRs by several different contributors this year as you can check here. It's perfectly alive and well. I developed this integration in my free time, now others are improving it. That's how open source works.

marconr9 commented 2 years ago

Ok thanks for the information. In any case thanks for your contribution @DavidMStraub Is it known if the problems occur only with Home assistant or also with other intergrations like Node red. Now i just altered my automation to work with homebridge. I hope someone can solve the problem soon

Vabis1010 commented 2 years ago

Stil after switching on washer no entity availible. Reloading integration breng them back on.

Outlook voor Androidhttps://aka.ms/AAb9ysg downloaden


From: marconr9 @.> Sent: Monday, March 7, 2022 9:05:29 AM To: home-assistant/core @.> Cc: Vabis1010 @.>; Comment @.> Subject: Re: [home-assistant/core] Home Connect not updating states properly (Issue #66063)

Ok thanks for the information. In any case thanks for your contribution @DavidMStraubhttps://github.com/DavidMStraub Is it known if the problems occur only with Home assistant or also with other intergrations like Node red. Now i just altered my automation to work with homebridge. I hope someone can solve the problem soon

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/66063#issuecomment-1060293755, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUUBXGXT2LUUZ5JF5UAXPIDU6W2ETANCNFSM5NZ55CNQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***>

slecram commented 2 years ago

I recently made some changes to this integration. In the HomeConnect library repository is a PR to improve event stream reading, I think that PR could fix some issues with wrong entity states.

@BraveChicken1 Hi, is there the possibility to test your changes?

Patrick-UK commented 2 years ago

Ok thanks for the information. In any case thanks for your contribution @DavidMStraub Is it known if the problems occur only with Home assistant or also with other intergrations like Node red. Now i just altered my automation to work with homebridge. I hope someone can solve the problem soon

I am seeing the issue in HA, if I reload the integration it works until the appliance is switched off. Then it goes unavailable, reload and then works. The Home Connect app works fine, as I wondered if the appliance was dropping off the network.

Patrick-UK commented 2 years ago

Unfortunately this is becoming a common theme across HA, integrations go into CORE then the original maintainers don't have time to maintain or they no longer have the item in their homes to help update. I have two different integrations in this state currently. I am currently looking at the Home Connect integration in Node-Red now.

So what? There have already been several merged PRs by several different contributors this year as you can check here. It's perfectly alive and well. I developed this integration in my free time, now others are improving it. That's how open source works.

I think you may have misunderstood my comment. I have been coding for the past 30yrs so I am fully aware of how open source works.... with all its benefits and risks.

yolani commented 2 years ago

Sorry if this is a little off-topic, but I actually tried starting to look into this, but failed to setup a useful test bench. My first idea was to test the underlying library (https://github.com/DavidMStraub/homeconnect) individually since this might be easier to just implement a few lines of python using this. Unfortunately I failed to setup this up because I was not able to to a proper OAuth handshake which I have to admit I don't know too much about.

Do you have any hints on how to set this up?

DavidMStraub commented 2 years ago

This is how I use it in a Jupyter notebook

from homeconnect import HomeConnect
import webbrowser

hc = HomeConnect(client_id, client_secret, redirect_uri)
webbrowser.open(hc.get_authurl())
auth_result = input("Paste URL here")
hc.get_token(auth_result)
yolani commented 2 years ago

This is how I use it in a Jupyter notebook

from homeconnect import HomeConnect
import webbrowser

hc = HomeConnect(client_id, client_secret, redirect_uri)
webbrowser.open(hc.get_authurl())
auth_result = input("Paste URL here")
hc.get_token(auth_result)

What do you use for redirect_uri, how do you set this up locally without too much effort?

DavidMStraub commented 2 years ago

It must match what you put in the HC dev portal, but otherwise doesn't matter, i.e. it doesn't have to exist. You just need to copy the URL which works even if the page is not found.

yolani commented 2 years ago

'it doesn't have to exist' was definitely a valuable hint ;-)

Here is some sample output in different states from my oven. Apparently the JSON response contains quite different information in different machine states. Wouldn't the obvious solution be to set the "remaining_time_xxx" sensors to "00:00:00" if the oven is not running?

# Standby
Backofen {
    'BSH.Common.Status.DoorState': {
        'value': 'BSH.Common.EnumType.DoorState.Closed'
    },
    'BSH.Common.Status.LocalControlActive': {
        'value': False
    },
    'BSH.Common.Status.RemoteControlStartAllowed': {
        'value': False
    },
    'BSH.Common.Status.RemoteControlActive': {
        'value': True
    },
    'BSH.Common.Status.OperationState': {
        'value': 'BSH.Common.EnumType.OperationState.Inactive'
    }, 
    'Cooking.Oven.Status.CurrentCavityTemperature': {
        'value': 22.999999999999996, 
        'unit': '°C'
    }
}

# Ready
Backofen {
    'BSH.Common.Status.DoorState': {
        'value': 'BSH.Common.EnumType.DoorState.Closed'
    }, 
    'BSH.Common.Status.LocalControlActive': {
        'value': False
    }, 
    'BSH.Common.Status.RemoteControlStartAllowed': {
        'value': False
    }, 
    'BSH.Common.Status.RemoteControlActive': {
        'value': True
    }, 
    'BSH.Common.Status.OperationState': {
        'timestamp': 1646725558, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/status/BSH.Common.Status.OperationState', 
        'value': 'BSH.Common.EnumType.OperationState.Ready', 
        'level': 'hint'
    }, 
    'Cooking.Oven.Status.CurrentCavityTemperature': {
        'value': 45, 
        'unit': '°C'
    },
    'BSH.Common.Setting.PowerState': {
        'timestamp': 1646725558, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/settings/BSH.Common.Setting.PowerState', 
        'value': 'BSH.Common.EnumType.PowerState.On', 
        'level': 'hint'
    }
}

# Running
Backofen {
    'BSH.Common.Status.DoorState': {
        'value': 'BSH.Common.EnumType.DoorState.Closed'
    }, 
    'BSH.Common.Status.LocalControlActive': {
        'timestamp': 1646735600, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/status/BSH.Common.Status.LocalControlActive', 
        'value': True, 'level': 'hint'
    }, 
    'BSH.Common.Status.RemoteControlStartAllowed': {
        'timestamp': 1646735602, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/status/BSH.Common.Status.RemoteControlStartAllowed', 
        'value': True, 
        'level': 'hint'
    }, 
    'BSH.Common.Status.RemoteControlActive': {
        'value': True
    }, 
    'BSH.Common.Status.OperationState': {
        'timestamp': 1646735602, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/status/BSH.Common.Status.OperationState', 
        'value': 'BSH.Common.EnumType.OperationState.Run', 
        'level': 'hint'
    }, 
    'Cooking.Oven.Status.CurrentCavityTemperature': {
        'timestamp': 1646735602, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/status/Cooking.Oven.Status.CurrentCavityTemperature', 
        'unit': '°C', 
        'value': 24.0, 
        'level': 'hint'
    }, 
    'BSH.Common.Setting.PowerState': {
        'timestamp': 1646735600, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/settings/BSH.Common.Setting.PowerState', 
        'value': 'BSH.Common.EnumType.PowerState.On', 
        'level': 'hint'
    }, 
    'BSH.Common.Root.ActiveProgram': {
        'timestamp': 1646735602, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/programs/active', 
        'value': 'Cooking.Oven.Program.Microwave.600Watt', 
        'level': 'hint'
    }, 
    'BSH.Common.Option.Duration': {
        'timestamp': 1646735602, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/programs/active/options/BSH.Common.Option.Duration', 
        'unit': 'seconds', 
        'value': 60, 
        'level': 'hint'
    }, 
    'BSH.Common.Option.StartInRelative': {
        'timestamp': 1646735602, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/programs/active/options/BSH.Common.Option.StartInRelative', 
        'unit': 'seconds', 
        'value': 0, 
        'level': 'hint'
    }, 
    'BSH.Common.Option.RemainingProgramTime': {
        'timestamp': 1646735602, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/programs/active/options/BSH.Common.Option.RemainingProgramTime', 
        'unit': 'seconds',
        'value': 60, 
        'level': 'hint'
    }, 
    'BSH.Common.Option.ElapsedProgramTime': {
        'timestamp': 1646735602, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/programs/active/options/BSH.Common.Option.ElapsedProgramTime', 
        'unit': 'seconds', 
        'value': 0, 
        'level': 'hint'
    }, 
    'BSH.Common.Option.ProgramProgress': {
        'timestamp': 1646735602, 
        'handling': 'none', 
        'uri': '/api/homeappliances/SIEMENS-HM876G2B6-68A40E6796F9/programs/active/options/BSH.Common.Option.ProgramProgress', 
        'unit': '%', 
        'value': 0, 
        'level': 'hint'
    }
}
barryhartman commented 2 years ago

I got the same isssue. Looking at the HA log I see the following warning:

Logger: homeconnect.sseclient Source: /usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py:89 First occurred: 12:28:19 (2 occurrences) Last logged: 12:28:19

Exception while reading event: Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in next next_chunk = next(self.resp_iterator) StopIteration

Perhaps it’s related?

DavidMStraub commented 2 years ago

No, not related

https://github.com/home-assistant/core/issues/61620#issuecomment-1012931725

Alex-joomla commented 2 years ago

Same Issue here, Home Assistant doesn't update sensor states in realtime or not at all. iOS App works well so the API seems to be up and running but my HA Sensors are offline or reacting very slow/delayed.

Nothing in the logs unfortunately. How can I help to look deeper into the problem?

Cafun commented 2 years ago

Same issue here. I also have this problem within Node-Red (with https://flows.nodered.org/node/node-red-contrib-homeconnect).

andrewjswan commented 2 years ago

Same issue here.

Patrick-UK commented 2 years ago

Same issue here. I also have this problem within Node-Red (with https://flows.nodered.org/node/node-red-contrib-homeconnect).

That is interesting as I find the Node-Red one to be stable (never have to re-auth) vs the HA one. Do you use Node-Red as an add-on or stand alone? I run mine stand alone as I did have some issues with it as an add-on.

Cafun commented 2 years ago

That is interesting as I find the Node-Red one to be stable (never have to re-auth) vs the HA one. Do you use Node-Red as an add-on or stand alone? I run mine stand alone as I did have some issues with it as an add-on.

I do use Node-Red as an add-on. I now have a stand alone Node-Red to check if it acts differently.

HardcoreWR commented 2 years ago

I added a comment earlier where I thought I found the relevant errors. This time, I do believe this is related for entities not being updated anymore;

2022-05-10 02:13:31 ERROR (Thread-4) [root] Uncaught thread exception
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
    url, headers, data = self._client.add_token(
  File "/usr/local/lib/python3.9/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 441, in _error_catcher
    yield
  File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 767, in read_chunked
    self._update_chunk_length()
  File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 697, in _update_chunk_length
    line = self._fp.fp.readline()
  File "/usr/local/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.9/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 760, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 575, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 796, in read_chunked
    self._original_response.close()
  File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 446, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.home-connect.com', port=443): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in __next__
    next_chunk = next(self.resp_iterator)
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 767, in generate
    raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.home-connect.com', port=443): Read timed out.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.9/site-packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.9/socket.py", line 954, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1040, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
    self.sock = conn = self._new_conn()
  File "/usr/local/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f41bd0d2340>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 440, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 785, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.home-connect.com', port=443): Max retries exceeded with url: /api/homeappliances/events (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f41bd0d2340>: Failed to establish a new connection: [Errno -3] Try again'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 181, in _listen
    self._listen(sse)
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 181, in _listen
    self._listen(sse)
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 181, in _listen
    self._listen(sse)
  [Previous line repeated 7 more times]
  File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen
    for event in sse:
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in __next__
    self._connect()
  File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect
    self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests_oauthlib/oauth2_session.py", line 521, in request
    return super(OAuth2Session, self).request(
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.home-connect.com', port=443): Max retries exceeded with url: /api/homeappliances/events (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f41bd0d2340>: Failed to establish a new connection: [Errno -3] Try again'))

I'm not aware of any network glitches at the time that may have triggered this.

DavidMStraub commented 2 years ago

Looks like an API issue...

HardcoreWR commented 2 years ago

Looks like an API issue...

Agreed, but maybe it's the retry mechanism (if it exists at all). The last message is from 3days ago and I haven't seen anything since then (also no updates). As if the component is stuck because of maybe not having a valid token or something.

iceymanz commented 2 years ago

Just adding my plus one. I am experiencing the same symptom as the OP of states just lingering and I believe the root cause to be token expiry. Expected behavior would be for some kind of timeout or 'unavailable' state for data that's no longer current.

Reloading the integration simply returns "Token expired." However restarting HA as a whole returns it to working normally.

mark007 commented 2 years ago

I also daily see the 'Read timed out' errors in my logs. Not sure if its any help, but today I restarted my HA at 21:19:30 and the first homeconnect timed out error was almost exactly 2 hours later, at 23:20:42. Could be a coincidence but does the integration try to keep a long running connection open. If so does the connection get timed out by the server after say 2 hours of no data, are some sort of regular keepalives required if that's the case.

iceymanz commented 2 years ago

Since upgrading to 2022.6 I'm still experiencing the sensors going 'unavailable' and now recieve the following errors: Logger: homeconnect.sseclient Source: /usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py:89 First occurred: June 3, 2022, 1:09:24 PM (4 occurrences) Last logged: June 4, 2022, 1:09:26 PM

Exception while reading event: Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in next next_chunk = next(self.resp_iterator) StopIteration

2022-06-04 18:34:55 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [548002030112] Connection closed by client 2022-06-05 05:19:20 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [548000411952] Connection closed by client 2022-06-05 05:19:20 INFO (MainThread) [homeassistant.components.websocket_api.http.connection] [548135318624] Connection closed by client File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in next File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in next self._connect() File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in next File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in next self._connect() File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 181, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 181, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 172, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 189, in handle_event File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in next File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in next self._connect() File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 81, in next File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 168, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 91, in next self._connect() File "/usr/local/lib/python3.9/site-packages/homeconnect/sseclient.py", line 56, in _connect File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 181, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 181, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 172, in _listen File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 189, in handle_event

joakimjalden commented 2 years ago

Edit: Saw that essentially the same error had already been addressed in #72187.

Adding my +1 to this thread. I will, with my comparatively limited HA programming skills, try to help because I believe I have a rather minimal example to reliably recreate these errors (on HA Core 2022.6.6, Supervisor 2022.05.3, OS 8.2).

I have a Washing Machine (WAXH2KB0SN) and a Dryer (WTX8HKL9SN) by Bosch. Turning both on and then restarting HA make the Home Connect integration accurately and reliably report the state of the door on both machines. However, turning either machine off via the physical power button on the machine immediately causes the uncaught exception

2022-06-21 11:53:37 ERROR (Thread-11) [root] Uncaught thread exception Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 172, in _listen self.handle_event(event, appliance) File "/usr/local/lib/python3.9/site-packages/homeconnect/api.py", line 189, in handle_event d = self.json2dict(event_data["items"]) KeyError: 'items'

similar to what was reported by @HardcoreWR (although not identical). After this, the integration becomes unresponsive, and also the machine that was not turned off stops reporting updates to the state of the door.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Adze1502 commented 2 years ago

Issue still persits in Home Assistant 2022.10.4 with homeconnect to 0.7.2. My washer and dryer state is not updating. Only when i reload the integration i get the new current correct values. I also have a microwave and steam oven. These devices do update correctly, without reloading integration.

Robbe-B commented 1 year ago

Same problem here for the dishwasher

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.