JohNan / homeassistant-wellbeing

Get the status from your Electrolux devices connected to Wellbeing
MIT License
76 stars 20 forks source link

Integration doesn't work for too long #112

Open forgenator opened 1 month ago

forgenator commented 1 month ago

I think the integration has problems with the refresh token handling stuff. If i add the integration, everything works fine, and then about 12h later it breaks and i get this error:

Logger: homeassistant
Source: custom_components/wellbeing/__init__.py:99
integration: Electrolux Wellbeing ([documentation](https://github.com/JohNan/homeassistant-wellbeing), [issues](https://github.com/JohNan/homeassistant-wellbeing/issues))
First occurred: 11:48:49 (1 occurrences)
Last logged: 11:48:49
Error doing job: Task exception was never retrieved (None)

Traceback (most recent call last):
  File "/config/custom_components/wellbeing/__init__.py", line 117, in async_reload_entry
    await async_unload_entry(hass, entry)
  File "/config/custom_components/wellbeing/__init__.py", line 99, in async_unload_entry
    coordinator = hass.data[DOMAIN][entry.entry_id]
                  ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: '01J52NP3R0H186FZ64SNZ2BBDJ'
forgenator commented 1 month ago

And yes, after poking a bit, if i reload home assistant, it says that the integration isn't working and i need to relogin again with the credentials.

So something is a miss with the usage of refresh token? :thinking:

thoompje commented 1 month ago

I have the same issue, this is because the authorization tokens are expiring every 12 hours...

image

I don't know how we can fix that... Because the value we cannot change.

forgenator commented 1 month ago

Well we have the refresh token to get new access token, but the integration isnt fetching it.

JohNan commented 1 month ago

Try the beta version 1.2.2. I have changed how to save the updated token in that release. I can promote it to a non-beta if it works better.

yazz007 commented 1 month ago

Try the beta version 1.2.2. I have changed how to save the updated token in that release. I can promote it to a non-beta if it works better.

Same issue with 1.2.2

jswetzen commented 1 month ago

I've have the same issue, updated to 1.2.2 now and will know tomorrow if it works for me 🤞

JohNan commented 1 month ago

I just release 1.2.3 as a public version. Try it out and let me know how it works!

andrebcunha commented 1 month ago

Still a problem here. Can provide logs later.

jswetzen commented 1 month ago

I'm on the 1.2.2 beta and it didn't disconnect the same way as before, I've got new data coming in over 12 hours later.

olanystrom commented 1 month ago

1.2.2 failed after 2 days. 1.2.3 gets this logs [custom_components.wellbeing] Validating credentials failed - 429, message='', url='https://api.developer.electrolux.one/api/v1/appliances'

429 = Too many requests

andrecunha-sb commented 1 month ago

Yes. Same problem for me.

indi81 commented 4 weeks ago

Same here. On 1.2.3.

I am seeing log error related to exceptions for FanEntityFeature.TURN_OFF

'FanEntityFeature' has no attribute 'TURN_OFF'

JohNan commented 4 weeks ago

Error 429 can be avoided by increasing the update interval. It can be changed by configuring the integration.

Please add logs with the FanEntityFeature not found.

indi81 commented 4 weeks ago

Adding the section, removed some API info (keys and ID's),

2024-08-17 00:54:24.487 DEBUG (MainThread) [custom_components.wellbeing] Tokens updated
2024-08-17 00:54:24.780 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues
2024-08-17 00:54:24.989 DEBUG (MainThread) [pyelectroluxgroup.appliance] Appliance info {'serialNumber': '', 'pnc': '950011384', 'brand': 'ELECTROLUX', 'deviceType': 'AIR_PURIFIER', 'model': 'A9', 'variant': 'CADR400', 'colour': 'DARKGREY'}
2024-08-17 00:54:24.989 DEBUG (MainThread) [pyelectroluxgroup.appliance] Appliance state {'applianceId': '', 'connectionState': 'Connected', 'status': 'enabled', 'properties': {'reported': {'FrmVer_NIU': '3.0.1', 'Workmode': 'Manual', 'FilterRFID': '', 'FilterLife': 37, 'Fanspeed': 3, 'UILight': True, 'SafetyLock': False, 'Ionizer': True, 'FilterType': 64, 'DspIcoTVOC': True, 'ErrPM2_5': False, 'ErrTVOC': False, 'ErrTempHumidity': False, 'ErrFanMtr': False, 'ErrCommSensorDisplayBrd': False, 'DoorOpen': False, 'ErrRFID': False, 'SignalStrength': 'FAIR', 'logE': 3103, 'logW': 454, 'InterfaceVer': 20230110, 'VmNo_NIU': 'VM185_A_03.00.01_ELYSIAN', 'TVOCBrand': 'AMS', 'capabilities': {'tasks': {}}, 'tasks': {}, 'DspIcoPM2_5': True, 'DspIcoPM1': True, 'DspIcoPM10': True, '$version': 7896, 'deviceId': '', 'PM1': 0, 'PM2_5': 0, 'PM10': 0, 'CO2': 614, 'Temp': 22, 'Humidity': 54, 'RSSI': -67, 'TVOC': 0, 'ECO2': 403}}}
2024-08-17 00:54:24.989 DEBUG (MainThread) [pyelectroluxgroup.appliance] Appliance capabilities {'PM1': {'access': 'read', 'max': 65535, 'min': 0, 'step': 1, 'type': 'number'}, 'PM10': {'access': 'read', 'max': 65535, 'min': 0, 'step': 1, 'type': 'number'}, 'PM2_5': {'access': 'read', 'max': 65535, 'min': 0, 'step': 1, 'type': 'number'}, 'TVOC': {'access': 'read', 'max': 4295, 'min': 0, 'step': 1, 'type': 'number'}, 'Fanspeed': {'access': 'readwrite', 'max': 9, 'min': 1, 'schedulable': True, 'step': 1, 'type': 'int'}, 'Workmode': {'access': 'readwrite', 'schedulable': True, 'triggers': [{'action': {'Fanspeed': {'access': 'readwrite', 'disabled': True, 'max': 9, 'min': 1, 'step': 1, 'type': 'int'}}, 'condition': {'operand_1': 'value', 'operand_2': 'Auto', 'operator': 'eq'}}, {'action': {'Fanspeed': {'access': 'readwrite', 'max': 9, 'min': 1, 'step': 1, 'type': 'int'}}, 'condition': {'operand_1': 'value', 'operand_2': 'Manual', 'operator': 'eq'}}, {'action': {'Fanspeed': {'access': 'readwrite', 'disabled': True, 'type': 'int'}}, 'condition': {'operand_1': 'value', 'operand_2': 'PowerOff', 'operator': 'eq'}}], 'type': 'string', 'values': {'Manual': {}, 'PowerOff': {}, 'Auto': {}}}}
2024-08-17 00:54:24.989 DEBUG (MainThread) [custom_components.wellbeing] Appliance initial: {'applianceId': '', 'applianceName': 'Luftrenare', 'applianceType': 'PUREA9', 'created': '2023-06-22T15:08:57.276+00:00'}
2024-08-17 00:54:24.989 DEBUG (MainThread) [custom_components.wellbeing] Appliance state: {'FrmVer_NIU': '3.0.1', 'Workmode': 'Manual', 'FilterRFID': '', 'FilterLife': 37, 'Fanspeed': 3, 'UILight': True, 'SafetyLock': False, 'Ionizer': True, 'FilterType': 64, 'DspIcoTVOC': True, 'ErrPM2_5': False, 'ErrTVOC': False, 'ErrTempHumidity': False, 'ErrFanMtr': False, 'ErrCommSensorDisplayBrd': False, 'DoorOpen': False, 'ErrRFID': False, 'SignalStrength': 'FAIR', 'logE': 3103, 'logW': 454, 'InterfaceVer': 20230110, 'VmNo_NIU': 'VM185_A_03.00.01_ELYSIAN', 'TVOCBrand': 'AMS', 'capabilities': {'tasks': {}}, 'tasks': {}, 'DspIcoPM2_5': True, 'DspIcoPM1': True, 'DspIcoPM10': True, '$version': 7896, 'deviceId': '', 'PM1': 0, 'PM2_5': 0, 'PM10': 0, 'CO2': 614, 'Temp': 22, 'Humidity': 54, 'RSSI': -67, 'TVOC': 0, 'ECO2': 403}
2024-08-17 00:54:24.990 DEBUG (MainThread) [custom_components.wellbeing] Finished fetching wellbeing data in 0.502 seconds (success: True)
2024-08-17 00:54:25.651 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'dwains_dashboard' accesses hass.components.websocket_api. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from websocket_api directly at custom_components/dwains_dashboard/notifications.py, line 220: hass.components.websocket_api.async_register_command(websocket_get_notifications), please create a bug report at https://github.com/dwainscheeren/dwains-lovelace-dashboard/issues
2024-08-17 00:54:25.664 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'dwains_dashboard' calls `async_add_job`, which is deprecated and will be removed in Home Assistant 2025.4; Please review https://developers.home-assistant.io/blog/2024/03/13/deprecate_add_run_job for replacement options at custom_components/dwains_dashboard/__init__.py, line 1590: hass.async_add_job(, please create a bug report at https://github.com/dwainscheeren/dwains-lovelace-dashboard/issues
2024-08-17 00:54:26.105 WARNING (MainThread) [pysensibo] Device Uterum not correctly registered with remote on Sensibo cloud.
2024-08-17 00:54:29.987 ERROR (ImportExecutor_0) [homeassistant.loader] Unexpected exception importing platform custom_components.wellbeing.fan
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1249, in _load_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1281, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 131, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/wellbeing/fan.py", line 18, in <module>
    FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE | FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'FanEntityFeature' has no attribute 'TURN_OFF'
2024-08-17 00:54:30.014 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to import_module inside the event loop by custom integration 'wellbeing' at custom_components/wellbeing/__init__.py, line 56: await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) (offender: /usr/src/homeassistant/homeassistant/loader.py, line 1281: return importlib.import_module(f"{self.pkg_path}.{platform_name}")), please create a bug report at https://github.com/JohNan/homeassistant-wellbeing/issues
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 742, in async_setup_locked
    await self.async_setup(hass, integration=integration)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/config/custom_components/wellbeing/__init__.py", line 56, in async_setup_entry
    await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)

2024-08-17 00:54:30.017 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.wellbeing.fan
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1249, in _load_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1281, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 131, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/wellbeing/fan.py", line 18, in <module>
    FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE | FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'FanEntityFeature' has no attribute 'TURN_OFF'
2024-08-17 00:54:30.025 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Electrolux Wellbeing for wellbeing
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1249, in _load_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1281, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 131, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/wellbeing/fan.py", line 18, in <module>
    FanEntityFeature.SET_SPEED | FanEntityFeature.PRESET_MODE | FanEntityFeature.TURN_OFF | FanEntityFeature.TURN_ON
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'FanEntityFeature' has no attribute 'TURN_OFF'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/wellbeing/__init__.py", line 56, in async_setup_entry
    await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2031, in async_forward_entry_setups
    await integration.async_get_platforms(platforms)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1162, in async_get_platforms
    import_future.result()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1162, in async_get_platforms
    import_future.result()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1162, in async_get_platforms
    import_future.result()
  [Previous line repeated 1 more time]
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1150, in async_get_platforms
    platforms.update(self._load_platforms(platform_names))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1075, in _load_platforms
    platform_name: self._load_platform(platform_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1269, in _load_platform
    raise ImportError(
ImportError: Exception importing custom_components.wellbeing.fan
JohNan commented 4 weeks ago

What version of Home Assistant are you running?

The feature should be available since a while back https://github.com/home-assistant/core/blob/dev/homeassistant%2Fcomponents%2Ffan%2F__init__.py#L58

indi81 commented 4 weeks ago

What version of Home Assistant are you running?

The feature should be available since a while back https://github.com/home-assistant/core/blob/dev/homeassistant%2Fcomponents%2Ffan%2F__init__.py#L58

Core 2024.6.3

Supervisor 2024.08.0

Operating System 12.2

Frontend 20240610.1

I'll try updating to latest. The reason its a little old is because we saw docker issues after the core updates in 2024.7.

indi81 commented 4 weeks ago

What version of Home Assistant are you running? The feature should be available since a while back https://github.com/home-assistant/core/blob/dev/homeassistant%2Fcomponents%2Ffan%2F__init__.py#L58

Core 2024.6.3

Supervisor 2024.08.0

Operating System 12.2

Frontend 20240610.1

I'll try updating to latest. The reason its a little old is because we saw docker issues after the core updates in 2024.7.

Seems to be working again after update to 2024.8 core. Thanks!

JohNan commented 4 weeks ago

The flag was added in this PR https://github.com/home-assistant/core/pull/121447 which was included in HA 2024.08

If it's an issue to upgrade, I can remove it and disable the backward compatibility flag mentioned in the PR. But I rather go forward than backwards 😊

indi81 commented 4 weeks ago

The flag was added in this PR home-assistant/core#121447 which was included in HA 2024.08

If it's an issue to upgrade, I can remove it and disable the backward compatibility flag mentioned in the PR. But I rather go forward than backwards 😊

Nah, I'm happy as the core update didn't break anything but for the future maybe don't expect users to patch every month 😉

jaku2019 commented 3 weeks ago

Hello, I've got the same problems as @olanystrom and @andrecunha-sb. Is there any workaround for this?

JohNan commented 3 weeks ago

Hello, I've got the same problems as @olanystrom and @andrecunha-sb. Is there any workaround for this?

See my message here https://github.com/JohNan/homeassistant-wellbeing/issues/112#issuecomment-2294717281

In the next update I will force the interval to be higher by default

jaku2019 commented 3 weeks ago

Hello, I've got the same problems as @olanystrom and @andrecunha-sb. Is there any workaround for this?

See my message here #112 (comment)

In the next update I will force the interval to be higher by default

Thank you for the information. I wasn't aware that you're going to apply this globally.

andrebcunha commented 3 weeks ago

Hello, I've got the same problems as @olanystrom and @andrecunha-sb. Is there any workaround for this?

See my message here #112 (comment)

In the next update I will force the interval to be higher by default

Thank you for the information. I wasn't aware that you're going to apply this globally.

300s instead of 30 works great for my 4 devices.

jaku2019 commented 3 weeks ago

@andrebcunha Thank you, I'll check that out.

magdogg commented 3 weeks ago

60s seems to work here!

Shiu commented 4 days ago

There is a limit of 5000 API calls per day, so technically we should be able to set the rate to 18s