andersonshatch / midea-ac-lib

Library for controlling Midea AC devices via their cloud
MIT License
21 stars 6 forks source link

Single request tend to fail after some inactivity #1

Open Maczuga opened 5 years ago

Maczuga commented 5 years ago

After not issuing any commands for some hours - next command fails (throwing error below). After that error - all following commands are working as intended.

Action I tried to perform was setting hvac mode from off to 'dry'. However - this also happens when switching from/to other modes, changing temp. etc.

Stack trace:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service connection.context(msg)) File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call self._execute_service(handler, service_call)) File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service await handler.func(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 194, in handle_service required_features File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 316, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 337, in _handle_service_platform_call await getattr(entity, func)(*data) File "/config/custom_components/midea/climate.py", line 276, in async_set_hvac_mode await self.apply_changes() File "/config/custom_components/midea/climate.py", line 95, in apply_changes await self.hass.async_add_executor_job(self._device.apply) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(self.args, **self.kwargs) File "/usr/local/lib/python3.7/site-packages/midea/device.py", line 165, in apply data = self._cloud_service.appliance_transparent_send(self.id, data) File "/usr/local/lib/python3.7/site-packages/midea/cloud.py", line 174, in appliance_transparent_send 'applianceId': id File "/usr/local/lib/python3.7/site-packages/midea/cloud.py", line 92, in api_request return self.api_request(endpoint, args) File "/usr/local/lib/python3.7/site-packages/midea/cloud.py", line 94, in api_request raise RecursionError() RecursionError

Maczuga commented 5 years ago

It seems that 3 concurrent API request failed throwing following error. However from what I have noticed - next execution always work. Perhaps there should be a timeout between api call retries (1sec or configurable)? Configurable retry count would be also nice.

andersonshatch commented 5 years ago

I've noticed the same. Have you tried any of your ideas? Open to PRs!

Maczuga commented 5 years ago

Will try, but kinda busy at work lately. Gonna setup my python enviroment and test it hopefully before the weekend.

Is there a way to access the dependency lib when using hass.io? The path seems to be somehow hidden behind docker.

andersonshatch commented 5 years ago

Not sure I'm afraid, I am not using hass.io

On 30 Jul 2019, at 21:03, Maczuga notifications@github.com wrote:

 I had one, but kinda busy at work lately. Gonna setup my python enviroment and test it hopefully before the weekend.

Is there a way to access the dependency lib when using hass.io? The path seems to be somehow hidden behind docker.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

andersonshatch commented 5 years ago

I guess if we could fix the fan_only issue that happens for every update on some devices, you would not notice the session timeout as it would happen for background update requests.

Or, maybe we can find a state change that will not alter the device mode, so if it's off or not in fan_only, you won't notice. Maybe turn swing on and off again? This would update the state of the device in home assistant, and log in if the session has expired.

Maczuga commented 5 years ago

Sure, this would be great, but I'll take small steps. I got the AC the same day you created the fork so I still need to figure out some stuff from the code.

Testing the timeout between calls right now, gonna report hopefully tommorow if it did anything.

andersonshatch commented 5 years ago

Sounds good! Out of interest do you have the fan_only problem and need the workaround? In the component repo I am considering making the workaround optional and have a branch here with that, could use some testers for those without the issue.

Maczuga commented 5 years ago

I think I had this one. After I am done with testing the timeout thingy - I can help with this one.

Maczuga commented 5 years ago

I did some digging with the responses I get when trying to sync state with midea servers - I guess some models needs different value readings. - nope, hex indexes and offsets seems fine, I was just looking at wrong bytearray.

Timeout solution didn't work sadly.

Gonna try the base Ruby package another day, see if that works, maybe something was skipped during the porting.

alesnav commented 5 years ago

Hello there.

I've just installed midea-ac-py for Home Assistant, from HACS. Everything worked at the first attempt but the Fan Only mode "bug". After using the published workaround use_fan_only_workaround: true, Home Assistant does not update its data if it was modified by any other method, for example, directly in the A/C using its remote.

I own two HTW Air Conditioners that works using a USB from Midea.

How can I help you with the troubleshooting?

Home Assistant version 0.97.2, inside a Docker Swarm cluster.

Thanks, Best regards

P.D.: I enabled debug mode for midea, and all HASS events are been sent to my Elasticsearch cluster.