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

PATCH calls to AC Infinity API cause subsiquent requests to API to fail or timeout for a period of time. #39

Open
almighty059 opened this issue Nov 25, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@almighty059
Copy link

When changing modes I started having the following error message appear at the bottom of the screen...

Screenshot 2023-11-25 175308

This is what the log says...

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:230
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 5:39:53 PM (6 occurrences)
Last logged: 5:53:00 PM

[281473424745280] {'msg': 'Something went wrong with your request.\nPlease try again later.', 'code': 100001}
[281472154391232] {'msg': 'Something went wrong with your request.\nPlease try again later.', 'code': 100001}
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/select/__init__.py", line 106, in async_select_option
    await entity.async_select_option(option)
  File "/config/custom_components/ac_infinity/select.py", line 49, in async_select_option
    await self.set_setting_value(
  File "/config/custom_components/ac_infinity/__init__.py", line 148, in set_setting_value
    await coordinator.ac_infinity.set_device_port_setting(
  File "/config/custom_components/ac_infinity/ac_infinity.py", line 219, in set_device_port_setting
    await self.set_device_port_settings(device_id, port_id, [(setting, value)])
  File "/config/custom_components/ac_infinity/ac_infinity.py", line 228, in set_device_port_settings
    await self._client.set_device_port_settings(
  File "/config/custom_components/ac_infinity/client.py", line 105, in set_device_port_settings
    _ = await self.__post(API_URL_ADD_DEV_MODE, payload, headers)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ac_infinity/client.py", line 119, in __post
    raise ACInfinityClientRequestFailed(json)
custom_components.ac_infinity.client.ACInfinityClientRequestFailed: {'msg': 'Something went wrong with your request.\nPlease try again later.', 'code': 100001}

@almighty059
Copy link
Author

I deleted the entire integration and then re-downloaded it and installed it but I'm still getting the same error message. I have the update set to 30 seconds and when I change modes there's a long pause and then the mode changes and then the error message appears or the error message appears and then the mode changes.

@almighty059
Copy link
Author

The same error is happening when I try to change other things besides the mode such as ON SPEED and OFF SPEED. I haven't tested everything but so far it seems to be happening with everything I try to change.

@dalinicus
Copy link
Owner

looks like your requests to the API are timing out. I've noticed during development that the occasional request to the API would time out after an update operation, so I threw in some retry logic. As I can see from the logs, it attempts to make the call 3 times before giving up. Not sure why its happening more frequently for you... but that's the dangers of using a non-public API I guess :( It's essentially a black box, so how to "properly" call it has to be reverse engineered and any errors that occur are essentially invisible.

I'll convert this into a bug to investigate why patch (update) calls to the API cause it to hang on subsequent calls.

One thing you can try is remove and re-add your Controller 69 from the AC Infinity app. See if that doesn't clear any bad data on their end that may be causing issues.

@dalinicus dalinicus added the bug Something isn't working label Nov 26, 2023
@dalinicus dalinicus changed the title Log details (ERROR) PATCH calls to AC Infinity API cause subsiquent requests to API to fail or timeout for a period of time. Nov 26, 2023
@almighty059
Copy link
Author

I'll try that to see what happens. And I don't know if it matters but the App itself is lagging when changing modes and settings. I get an error that says to try again at a later time but then the error clears and the change goes through.

@almighty059
Copy link
Author

@dalinicus deleting the device from the app and the integration and adding it back worked. I'm no longer getting the error. Thanks.

@zpriddy
Copy link

zpriddy commented Dec 28, 2023

I am having the same issue - when it stops responding, if I control it from the AC Infinity app.. it will start to work again after a reload.. but it keeps happening…

I will try to delete it from the app and re-add it

@dalinicus
Copy link
Owner

Would you mind providing what device modes your using, and what settings your frequently changing? It would help me debug; I can throw a traffic spy on my phone and see if the app is sending values that the integration is missing. Some of them (like temperature in auto mode) requires multiple values be to changed for it to work properly, and I could have missed it.

@Vandewaetere
Copy link

@dalinicus I am mainly updating the 'mode' (on or off) and the 'on fan speed' from HA. See also #47

@bert-the-dog
Copy link

Nothing really new to add, just to say i'm also getting this. For me, it's the changing of the fan on power value that does it. It still seems to update in the log when i change the speed in the app. However, this last time I've not been changing any settings for the last week or so & its still started to do it.

Like zpriddy above, the app itself seems to play up when this is happening & removing & adding it seems to sort it. It seems like it could be AC app issue? there's plenty of posts about problems with it elsewhere.

Also thanks for making this integration, really makes it easier to manage everything

@almighty059
Copy link
Author

@bert-the-dog it might be an AC app issue. It occasionally happens to me too. I can't really narrow it down to what exactly it is. AC should be coming out with a new version of the app sometime soon because the current version of the app doesn't handle all of the features of the new fan. And FYI if you have an old fan they'll swap it out for the new version which has some major improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants