Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home Assistant Daikin Integration failing in 2024.8.x - BRP069 based devices #22

Open
martingruening opened this issue Aug 26, 2024 · 5 comments · May be fixed by #32
Open

Home Assistant Daikin Integration failing in 2024.8.x - BRP069 based devices #22

martingruening opened this issue Aug 26, 2024 · 5 comments · May be fixed by #32
Labels
BRP069 Devices with the BRP069 - module

Comments

@martingruening
Copy link

I have a Daikin unit with a BRP069B42 controller unit that also stopped working with 2024.8.x.

This is what I see in the logs

    Logger: pydaikin.daikin_base
    Quelle: components/daikin/init.py:88
    Erstmals aufgetreten: 06:25:37 (2 Vorkommnisse)
    Zuletzt protokolliert: 07:18:41
    Exception in TaskGroup: 0, message='', url='http://192.168.181.125/common/get_holiday'
    Exception in TaskGroup: 0, message='', url='http://192.168.181.125/aircon/get_sensor_info'

    Logger: homeassistant.components.daikin
    Quelle: components/daikin/init.py:99
    Integration: Daikin AC (Dokumentation, Probleme)
    Erstmals aufgetreten: 06:25:37 (2 Vorkommnisse)
    Zuletzt protokolliert: 07:18:41
    Unexpected error creating device 192.168.181.125

Let me know if further debug level logging would be helpful.

@fredrike
Copy link
Owner

Thanks for reporting this. Yes, more debugging is needed please enable debugging for pydaikin and add some more info here.

@martingruening
Copy link
Author

Logger: homeassistant.config_entries
Quelle: config_entries.py:604
Erstmals aufgetreten: 22:20:09 (1 Vorkommnisse)
Zuletzt protokolliert: 22:20:09

Error setting up entry 192.168.181.125 for daikin
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/daikin/init.py", line 49, in async_setup_entry
daikin_api = await daikin_api_setup(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/daikin/init.py", line 88, in daikin_api_setup
device: Appliance = await DaikinFactory(
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pydaikin/factory.py", line 26, in new
await instance.init(*a, **kw)
File "/usr/local/lib/python3.12/site-packages/pydaikin/factory.py", line 61, in init
await self._generated_object.init()
File "/usr/local/lib/python3.12/site-packages/pydaikin/daikin_brp069.py", line 124, in init
await self.update_status(self.HTTP_RESOURCES[1:])
File "/usr/local/lib/python3.12/site-packages/pydaikin/daikin_base.py", line 187, in update_status
self.values.update_by_resource(resource, task.result())
^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 189, in async_wrapped
return await copy(fn, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 111, in call
do = await self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 153, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 99, in inner
return call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/init.py", line 398, in
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 114, in call
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pydaikin/daikin_base.py", line 145, in _get_resource
async with self.session.get(
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1353, in aenter
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 684, in _request
await resp.start(conn)
File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 999, in start
message, payload = await protocol.read() # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
await self._waiter
asyncio.exceptions.CancelledError

@fredrike
Copy link
Owner

Thank you for the exception log.

To troubleshoot this I need more information, can you please enable debug logging for pydaikin, https://www.home-assistant.io/integrations/logger/

logger:
  logs:
    homeassistant.components.daikin: debug
    pydaikin: notset

Please enclose the new output in code tags (```).

@fredrike fredrike changed the title Home Assistant Daikin Integration failing in 2024.8.x Home Assistant Daikin Integration failing in 2024.8.x - BRP069 based devices Aug 28, 2024
@fredrike fredrike added the BRP069 Devices with the BRP069 - module label Aug 28, 2024
@weltall
Copy link

weltall commented Sep 8, 2024

seems to be actually the same problem i've reported in home assistant core home-assistant/core#125350

I did some additional tests since then and it seems the problem is actually a change in the underlying component (this project).

First of all i tried to use the version of the component in home assistant before this commit and it started working again:

home-assistant/core@9b4e64a , in practice a downgrade from 2.13.1 to 2.11.1 of this library.

Going over some additional test, using directly the library from my linux pc, i noticed that the exception is raised randomly, comes from aiohttp and seems to have random exception messages, including a weird one saying that it received some additional data after the connection was closed (which is a really weird message). Posted under.

Considering the random situation of the message (some times it worked sometimes it didn't) I tried to make the calls sequential and that pretty much fixed the problem, making it entirely 100% reliable again like before.

The change i did was in daikin_base MAX_CONCURRENT_REQUEST from 4 to 1: weltall@94fbecd.

So in practice this commit introduced the problem 3f6a98a and, only recently, due to the bump of the library in home assistant, this problem has appeared in there.

Of course, i can image it cannot be a cookie cutter solution like this, as I'm sure other device models don't have issues with it, but that's pratically the cause of the issue on these controllers: they don't seem to answer properly if "spammed" of requests. I've tried also 2 and 3 as values for the concurrent requests, but they seems to be as unreliable. Only 1 at a time seems to work.

DEBUG:pydaikin.factory:Trying connection to BRP069
DEBUG:pydaikin.daikin_base:Updating ['common/basic_info']
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/common/basic_info {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/common/get_datetime {'cur': ''}
DEBUG:pydaikin.daikin_base:Updating ['common/get_remote_method', 'aircon/get_sensor_info', 'aircon/get_model_info', 'aircon/get_control_info', 'aircon/get_target', 'aircon/get_price', 'common/get_holiday', 'common/get_notify', 'aircon/get_day_power_ex', 'aircon/get_week_power', 'aircon/get_year_power', 'common/get_datetime']
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/common/get_remote_method {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/aircon/get_sensor_info {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/aircon/get_model_info {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/aircon/get_control_info {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/aircon/get_target {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/aircon/get_price {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/common/get_holiday {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/common/get_notify {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/aircon/get_day_power_ex {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/aircon/get_week_power {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/aircon/get_year_power {}
DEBUG:pydaikin.daikin_base:Calling: http://192.168.1.5/common/get_datetime {}
ERROR:pydaikin.daikin_base:Exception in TaskGroup: 0, message='', url='http://192.168.1.5/common/get_remote_method'
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/aiohttp/client_proto.py", line 264, in data_received
    messages, upgraded, tail = self._parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 563, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadHttpMessage: 400, message:
  Data after `Connection: close`:

    b'ret=OK,model=0000,type=N,pv=3.20,cpv=3,cpv_minor=20,mid=NA,humd=0,s_humd=0,acled=0,land=0,elec=1,temp=1,temp_rng=0,m_dtct=1,ac_dst=--,disp_dry=0,dmnd=1,en_scdltmr=1,en_frate=1,en_fdir=1,s_fdir=3,en_rtemp_a=0,en_spmode=7,en_ipw_sep=1,en_mompow=0,hmlmt_l=10.0'
                                                           ^

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

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 999, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
    await self._waiter
aiohttp.http_exceptions.HttpProcessingError: 0, message:


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

Traceback (most recent call last):
  File "/home/weltall/pydaikin/bin/pydaikin", line 162, in <module>
    run(main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/weltall/pydaikin/bin/pydaikin", line 138, in main
    daikin = await DaikinFactory(args.device, key=args.key, password=args.password)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/weltall/pydaikin/pydaikin/factory.py", line 26, in __new__
    await instance.__init__(*a, **kw)
  File "/home/weltall/pydaikin/pydaikin/factory.py", line 61, in __init__
    await self._generated_object.init()
  File "/home/weltall/pydaikin/pydaikin/daikin_brp069.py", line 125, in init
    await self.update_status(self.HTTP_RESOURCES[1:])
  File "/home/weltall/pydaikin/pydaikin/daikin_base.py", line 179, in update_status
    self.values.update_by_resource(resource, task.result())
                                             ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 189, in async_wrapped
    return await copy(fn, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 111, in __call__
    do = await self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 153, in iter
    result = await action(retry_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/tenacity/_utils.py", line 99, in inner
    return call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/tenacity/__init__.py", line 398, in <lambda>
    self._add_action_func(lambda rs: rs.outcome.result())
                                     ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 114, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/weltall/pydaikin/pydaikin/daikin_base.py", line 140, in _get_resource
    async with self.session.get(
  File "/usr/lib/python3.12/site-packages/aiohttp/client.py", line 1353, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/aiohttp/client.py", line 684, in _request
    await resp.start(conn)
  File "/usr/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1001, in start
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 0, message='', url='http://192.168.1.5/common/get_remote_method'
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x77b0c43c3470>

@fredrike
Copy link
Owner

Great find @weltall !

Can you test setting MAX_CONCURRENT_REQUEST on class-level and decrease it for the BRP069 class. I would happily merge this from a pr.

@weltall weltall linked a pull request Sep 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BRP069 Devices with the BRP069 - module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants