hass-smartthinq
hass-smartthinq copied to clipboard
smartthinq: Error on device update! (self._ac.get_power())
Seems like latest update broke integration with my AC. I'm getting the following in the logs:
Traceback (most recent call last):
File "/config/custom_components/smartthinq/climate.py", line 252, in check_power
power = self._ac.get_power()
File "/usr/local/lib/python3.7/site-packages/wideq/ac.py", line 299, in get_power
value = self._get_config('InOutInstantPower')
File "/usr/local/lib/python3.7/site-packages/wideq/client.py", line 433, in _get_config
key,
File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 492, in get_device_config
'data': '',
File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 394, in post
return lgedm_post(url, data, self.auth.access_token, self.session_id)
File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 213, in lgedm_post
raise APIError(code, message)
wideq.core.APIError: ('0111', '제품 응답 지연')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 319, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
self.update # type: ignore
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/smartthinq/climate.py", line 283, in update
self.check_power()
File "/config/custom_components/smartthinq/climate.py", line 256, in check_power
except wideq.InvalidRequestError:
NameError: name 'wideq' is not defined
Looks like import wideq
is missing in that method.
BTW, my AC do support power consumption through the official app.
Seems like just adding import wideq
doesn't fix the problem, I had to add another exception handler for APIError.
Oops!! I added the import wideq
you mentioned (see above commit). For the APIError
exception: any chance you have an old version of the wideq library? Can you try upgrading and see if the above commit suffices?
I have the same error.
smartthinq: Error on device update! Traceback (most recent call last): File "/config/custom_components/smartthinq/climate.py", line 252, in check_power power = self._ac.get_power() File "/usr/local/lib/python3.7/site-packages/wideq/ac.py", line 299, in get_power value = self._get_config('InOutInstantPower') File "/usr/local/lib/python3.7/site-packages/wideq/client.py", line 433, in _get_config key, File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 492, in get_device_config 'data': '', File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 394, in post return lgedm_post(url, data, self.auth.access_token, self.session_id) File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 213, in lgedm_post raise APIError(code, message) wideq.core.APIError: ('0111', '제품 응답 지연')
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 319, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update self.update # type: ignore File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/smartthinq/climate.py", line 283, in update self.check_power() File "/config/custom_components/smartthinq/climate.py", line 256, in check_power except wideq.InvalidRequestError: NameError: name 'wideq' is not defined
Recieved a new refresh token. Now it works. But after ~24 hours it stops working.
UPD I have not noticed. I used not the latest version. Updtaing now. Will see if it works (24 hours to wait).
@sampsyo I believe that version is sticked to 1.0.1 within manifest.json. I've also tried to update it to 1.4.0 within the same manifest, but I got another strange error, something about fan speeds.
PS. Getting a new refresh token doesn't help me
Hm, I've tried to set version to 1.4.0 in manifest.json and also to remove my APIError handler and today it works. I have this integration installed through HACS.
2 days gone
Error wideq.core.APIError: ('0111', '제품 응답 지연') now Renamed the AC (to english) in LG App. Rebooted Home Asisstant. The error is gone.
Hm, I've tried to set version to 1.4.0 in manifest.json and also to remove my APIError handler and today it works. I have this integration installed through HACS.
Can you please describe me in details what did you do to fix your error?
It seems that somtimes HA cant reach the AC after some time or a restart. Maybe the answer is bad lg servers.
Should I install wideq to make this work? I tried to (with pip), but it says there is no setup file.
@divanikus: Thanks!! I bumped the required version here on master.
@mihail4anov: Errors like that typically indicate that your version of pip is old—newer ones should work.
@divanikus: Thanks!! I bumped the required version here on master.
@mihail4anov: Errors like that typically indicate that your version of pip is old—newer ones should work.
pip3 install wideq
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting wideq Downloading https://files.pythonhosted.org/packages/e8/ad/ed9d507097f628afec4097cc4d0ed2c8b4834274f5abe98aa470a1e767ec/wideq-1.4.0-py3-none-any.whl (65kB) 100% |████████████████████████████████| 71kB 1.1MB/s Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from wideq) (2.21.0) Installing collected packages: wideq Successfully installed wideq-1.4.0
But still I have the wideq.core.NotConnectedError: ('0106', '장치가 접속중이 아닙니다.'). Copied example.py to /home/pi/.local/lib/python3.7/site-packages Now I have wideq_state.json Will see if it works in a day or two...
@mihail4anov if you have installed it through HACS, all you need is to update to the latest component version and just restart HA. No need to install anything on the host system.
Hm, I've tried to set version to 1.4.0 in manifest.json and also to remove my APIError handler and today it works. I have this integration installed through HACS.
@divanikus Can you explain for noob like me, how to remove this APIError handler in details? I installed this component through hacs and it is updated.
@mihail4anov you don't need to do that, I just made a hack for my installation and removed it later. Did you installed the component from HACS? Have you tried to update it?
@mihail4anov you don't need to do that, I just made a hack for my installation and removed it later. Did you installed the component from HACS? Have you tried to update it?
@divanikus Yes from HACS. Latest version
@mihail4anov Last error code you've shown says that your device is not connected, maybe it has lost WiFi connection. Try to restart it and check if it is accessible through the official app.
@sampsyo I got error 0111 after HA reboot again and component is not working anymore. As far as i can see, it's not handled within wideq anywhere: https://github.com/sampsyo/wideq/blob/master/wideq/core.py#L172-L177
Traceback:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 319, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
self.update # type: ignore
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/smartthinq/climate.py", line 284, in update
self.check_power()
File "/config/custom_components/smartthinq/climate.py", line 253, in check_power
power = self._ac.get_power()
File "/usr/local/lib/python3.7/site-packages/wideq/ac.py", line 299, in get_power
value = self._get_config('InOutInstantPower')
File "/usr/local/lib/python3.7/site-packages/wideq/client.py", line 433, in _get_config
key,
File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 492, in get_device_config
'data': '',
File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 394, in post
return lgedm_post(url, data, self.auth.access_token, self.session_id)
File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 213, in lgedm_post
raise APIError(code, message)
wideq.core.APIError: ('0111', '제품 응답 지연')
I think I know what is happening. LG servers does not work as it should all the time. Sometimes the connection is very bad. At this time I can see this error in the HA log:
Update for climate.konditsioner fails
Logger: homeassistant.helpers.entity Source: custom_components/smartthinq/climate.py:253 First occurred: 11:20:08 (27 occurrences) Last logged: 12:09:56
Update for climate.konditsioner fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 272, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update self.update # type: ignore File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/smartthinq/climate.py", line 284, in update self.check_power() File "/config/custom_components/smartthinq/climate.py", line 253, in check_power power = self._ac.get_power() File "/usr/local/lib/python3.7/site-packages/wideq/ac.py", line 299, in get_power value = self._get_config('InOutInstantPower') File "/usr/local/lib/python3.7/site-packages/wideq/client.py", line 433, in _get_config key, File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 492, in get_device_config 'data': '', File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 394, in post return lgedm_post(url, data, self.auth.access_token, self.session_id) File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 213, in lgedm_post raise APIError(code, message) wideq.core.APIError: ('0111', '제품 응답 지연')
BUT if I press the buttons in lovelace, my AC seems to be responding (very slow). And if do a reboot of HA, the entity climate.konditsioner is gone from HA.
As a temporary workaround you may try this. Open climate.py and find the function called check_power
(aprox. line 244).
After the following lines:
except wideq.InvalidRequestError:
LOGGER.info('Power consumption not available.')
self._has_power = False
Add this:
except wideq.APIError:
LOGGER.info('Power consumption not available.')
self._has_power = False
Save the file and reboot HA. Mind the intendation! Use spaces only, not tabs. This edit will mute all APIErrors in that function. But I guess things should be fixed somewhere in wideq. Also, I'm not sure what this 0111 "Product response delay" error actually means. My AC should report power consumption afair.
Oh, speaking of that trace with something about fans
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 451, in _async_add_entity
entity.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 290, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 316, in _async_write_ha_state
attr.update(self.state_attributes or {})
File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 256, in state_attributes
data[ATTR_FAN_MODE] = self.fan_mode
File "/config/custom_components/smartthinq/climate.py", line 199, in fan_mode
mode = self._state.fan_speed
AttributeError: 'NoneType' object has no attribute 'fan_speed'
After I have added this except wideq.APIError: LOGGER.info('Power consumption not available.') self._has_power = False
I have this
Logger: homeassistant.components.climate Source: custom_components/smartthinq/climate.py:199 Integration: Климат (documentation, issues) First occurred: 15:48:36 (1 occurrences) Last logged: 15:48:36
Error while setting up smartthinq platform for climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 186, in _async_setup_platform await asyncio.gather(*pending) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 451, in _async_add_entity entity.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 290, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 316, in _async_write_ha_state attr.update(self.state_attributes or {}) File "/usr/src/homeassistant/homeassistant/components/climate/init.py", line 256, in state_attributes data[ATTR_FAN_MODE] = self.fan_mode File "/config/custom_components/smartthinq/climate.py", line 199, in fan_mode mode = self._state.fan_speed AttributeError: 'NoneType' object has no attribute 'fan_speed'
@mihail4anov, thanks, this was missing a check. (A bug introduced in #21.)
Have just apdated the component and rebooted. AC entity become avalable again.
The same problem with wideq.core.APIError: ('0111', '제품 응답 지연') but climate.ac_name may work or not.
I use 2 identical LG ACs and could not understand the reason for the error. After restart HA/wifi/AC this problem can be solved... or not.
Full log: 2020-07-21 20:56:54 WARNING (MainThread) [homeassistant.helpers.entity] Update of climate.spalnia is taking over 10 seconds 2020-07-21 20:56:55 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.spalnia fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 472, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/smartthinq/climate.py", line 285, in update self.check_power() File "/config/custom_components/smartthinq/climate.py", line 254, in check_power power = self._ac.get_power() File "/usr/local/lib/python3.7/site-packages/wideq/ac.py", line 299, in get_power value = self._get_config('InOutInstantPower') File "/usr/local/lib/python3.7/site-packages/wideq/client.py", line 433, in _get_config key, File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 492, in get_device_config 'data': '', File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 394, in post return lgedm_post(url, data, self.auth.access_token, self.session_id) File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 213, in lgedm_post raise APIError(code, message) wideq.core.APIError: ('0111', '제품 응답 지연')
The same problem with wideq.core.APIError: ('0111', '제품 응답 지연') but climate.ac_name may work or not.
I use 2 identical LG ACs and could not understand the reason for the error. After restart HA/wifi/AC this problem can be solved... or not.
Full log: 2020-07-21 20:56:54 WARNING (MainThread) [homeassistant.helpers.entity] Update of climate.spalnia is taking over 10 seconds 2020-07-21 20:56:55 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.spalnia fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 472, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/smartthinq/climate.py", line 285, in update self.check_power() File "/config/custom_components/smartthinq/climate.py", line 254, in check_power power = self._ac.get_power() File "/usr/local/lib/python3.7/site-packages/wideq/ac.py", line 299, in get_power value = self._get_config('InOutInstantPower') File "/usr/local/lib/python3.7/site-packages/wideq/client.py", line 433, in _get_config key, File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 492, in get_device_config 'data': '', File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 394, in post return lgedm_post(url, data, self.auth.access_token, self.session_id) File "/usr/local/lib/python3.7/site-packages/wideq/core.py", line 213, in lgedm_post raise APIError(code, message) wideq.core.APIError: ('0111', '제품 응답 지연')
I am from Butovo too) The reason of the problem is terrible ping to LG servers. Do this (https://github.com/sampsyo/hass-smartthinq/issues/70#issuecomment-660617040) to solve the problem. It helps me)
Hey folks. Did you tried official LG app when you got this message? In my case seems like official app can't connect to AC too, so it might be because AC lost the WiFi connection.
Hey folks. Did you tried official LG app when you got this message? In my case seems like official app can't connect to AC too, so it might be because AC lost the WiFi connection.
Yes, official app can't too. I don't have a problem with downtime WiFi AC connection