LG Smartthinq Air Conditioning

how do you suggest that? as it only has the access token to get to the account and a refresh token no where in the file does it show my devices

In platform configuration you can specify json file location, eg.:
image

the file does not have the device info only the account info to access the devices

Yes. But why do you think it’s a problem?
wideq_state.json has different structure for v1 and v2 api. So it is necessary to use corresponding file .

if wideq is pulling all the devices then how is it the problem? the marcio the sampsyo and all the others are what is failing to get to the credentials to even load

I’m now stuck with @marciogranzotto version of wideq and my old v1 implementation is not working anymore. The original hass-smartthinq component is trying to use marcio’s version of wideq and now nothing works. :frowning:

Maybe changing the name of marcio’s wideq version to something else? This could break peoples dependencies like mine I guess… where we still need the original component to work. And since your version is a fork of wideq make sense to not update the version number only but change the name of the fork.

But I guess that is also a fork on @no2chem v2 version. So that would need to be renamed if merged. I’m also not super sure if both wideq versions can co-exists but if anyone has some notes on how to do it please do so! (I already tried changing the manifest.json requirements url and also the climate.py REQUIREMENTS to use directly the github repo but did not work)

try deleting everything in your LG account and re adding them to see if you can gain access that way

I’ve just uploaded a new version that uses the UI Config Flow instead of adding the wideq_state.json on the yaml config.

But for anyone that was using the integration before, you have to remove the entry in configuration.yaml and redo the add process using HA’s UI. More detail instructions on the project README

2 Likes

just tried it and now I can see my A/C units in Home assistant now Thank you

Thanks for the update.
I see the following errors on the logs. I would open an issue on github but seems that they are not enabled:

#1:

2021-04-19 16:41:15 ERROR (MainThread) [homeassistant.components.climate] Error adding entities for domain climate with platform thinq_v2
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 322, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 429, in _async_add_entity
    capabilities=entity.capability_attributes,
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 190, in capability_attributes
    ATTR_HVAC_MODES: self.hvac_modes,
  File "/config/custom_components/thinq_v2/climate.py", line 221, in hvac_modes
    return [
  File "/config/custom_components/thinq_v2/climate.py", line 225, in <listcomp>
    in self._ac.model.value("airState.opMode").options.values()
  File "/usr/local/lib/python3.8/site-packages/wideq/client.py", line 347, in value
    d = self.data["Value"][name]
KeyError: 'airState.opMode'

#2

2021-04-19 16:53:56 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [1648798856] 'NoneType' object has no attribute 'is_on'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 143, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 206, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 649, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 692, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 686, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 434, in async_set_hvac_mode
    await self.hass.async_add_executor_job(self.set_hvac_mode, hvac_mode)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/thinq_v2/climate.py", line 291, in set_hvac_mode
    if not self._state.is_on:
AttributeError: 'NoneType' object has no attribute 'is_on'

I have mixed v1 and v2 devices so not sure this is the reason for those errors.

Thanks a lot for the work Marcio! I can confirm it’s been working flawlessly for a week or so. I just hope it will take some time until LG changes their API again.

@marciogranzotto, thanks for your work on this.

I’m able to successfully install the component for my LG AC unit via HACS and link my account but getting climate errors in HA now.

(Error) Climate
The thinq_v2 platform for the climate integration does not support platform setup. Please remove it from your config.

(Error) Sensor
The thinq_v2 platform for the sensor integration does not support platform setup. Please remove it from your config.

(Error) custom_components/thinq_v2/climate.py - message first occurred at 11:44:45 AM and shows up 9 times

I’m running core-2021.4.6. Anyone know why I’m seeing these errors? Am I missing something?
Thanks

@Conductor now you should use configuration from UI

(Error) custom_components/thinq_v2/climate.py - message first occurred at 11:44:45 AM and shows up 9 times

can you post the detail log of this error?
Probably there will be AC models that don’t have some of the fields that mine has. We need to experiment with different ACs and start changing the integration to be null safe

Here you go. The window AC unit is the LW1019IVSM. Thanks

Logger: homeassistant
Source: custom_components/thinq_v2/climate.py:244
First occurred: 11:44:45 AM (461 occurrences)
Last logged: 7:24:49 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 626, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 269, in state_attributes
    data[ATTR_SWING_MODE] = self.swing_mode
  File "/config/custom_components/thinq_v2/climate.py", line 244, in swing_mode
    if v[0] == self._state.horz_swing and v[1] == self._state.vert_swing:
  File "/usr/local/lib/python3.8/site-packages/wideq/ac.py", line 440, in horz_swing
    lookup_enum("airState.wDir.hStep", self.data, self.ac)
  File "/usr/local/lib/python3.8/site-packages/wideq/util.py", line 17, in lookup_enum
    return device.model.enum_name(attr, data[attr])
KeyError: 'airState.wDir.hStep'

Hello, I have AC LG PC09SQ, sensors and entities are not created either. Error log:

Logger: homeassistant.components.climate
Source: custom_components/thinq_v2/climate.py:225
Integration: Климат (documentation, issues)
First occurred: 23 апреля 2021 г., 15:17:57 (1 occurrences)
Last logged: 23 апреля 2021 г., 15:17:57

Error adding entities for domain climate with platform thinq_v2
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 322, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 429, in _async_add_entity
    capabilities=entity.capability_attributes,
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 190, in capability_attributes
    ATTR_HVAC_MODES: self.hvac_modes,
  File "/config/custom_components/thinq_v2/climate.py", line 221, in hvac_modes
    return [
  File "/config/custom_components/thinq_v2/climate.py", line 225, in <listcomp>
    in self._ac.model.value("airState.opMode").options.values()
  File "/usr/local/lib/python3.8/site-packages/wideq/client.py", line 347, in value
    d = self.data["Value"][name]
KeyError: 'airState.opMode'

Similar error with a LG LP1419IVSM. Can execute commands, but no sensor data is being returned. Error is:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 626, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 269, in state_attributes
    data[ATTR_SWING_MODE] = self.swing_mode
  File "/config/custom_components/thinq_v2/climate.py", line 244, in swing_mode
    if v[0] == self._state.horz_swing and v[1] == self._state.vert_swing:
  File "/usr/local/lib/python3.8/site-packages/wideq/ac.py", line 440, in horz_swing
    lookup_enum("airState.wDir.hStep", self.data, self.ac)
  File "/usr/local/lib/python3.8/site-packages/wideq/util.py", line 17, in lookup_enum
    return device.model.enum_name(attr, data[attr])
KeyError: 'airState.wDir.hStep'

In the entity itself, these are the values being returned with a state of unknown:

hvac_modes:
  - auto
  - auto
  - heat
  - cool
  - fan_only
  - dry
  - heat_cool
  - 'off'
min_temp: 18
max_temp: 30
fan_modes:
  - low
  - low-mid
  - medium
  - mid-high
  - high
  - power
swing_modes:
  - 'Off'
  - Vertical
  - Horizontal
  - Vertical and Horizontal
  - Up Left
  - Up Right
  - Up
current_temperature: null
temperature: null
fan_mode: null
swing_mode: Unknown
friendly_name: Air Conditioner
supported_features: 41

I ran into the same thing on my 2 window units
mine are the
Dual Inverter
Model # LW1517IVSM

after flopping around like a gut shot squirrel I finally found the solution on git hub, though not very clear

first off you need to locate your thinq_v2 folder that is located in the custom_components folder in home assistant folder

you need to edit the init.py file and the climate.py file I used notepad++ to do it

I linked to both files to make it easier

here is what I used to edit them

init.py line 218

climate.py line 43
and
climate.py line 243

line 243, change from if self._swing_mode == SWING_MODE_DEFAULT and self._state is not None:
to

if self._swing_mode != SWING_MODE_DEFAULT and self._state is not None:

once you have edited the files restart your home assistant and then power cycle the ac unit in home assistants card it should then send back the info

1 Like

This completely solved my issue, appreciate your help! Hopefully these changes will be in an upcoming update.

Thanks for sharing this info @trentjw . I tried the changes you posted (though maybe I did something incorrectly) and I am able to mostly control my window unit now but still seeing errors in the logs. I also get some errors when trying to change the fan speed even though the command seems to work. In the lovelace thermostat card I see various settings that don’t apply to my unit:

  • various fan speeds other than high, medium and low
  • Two options for auto
  • swing mode (which is greyed out)
Logger: homeassistant
Source: custom_components/thinq_v2/climate.py:245
First occurred: 12:52:38 PM (151 occurrences)
Last logged: 3:22:40 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 626, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 269, in state_attributes
    data[ATTR_SWING_MODE] = self.swing_mode
  File "/config/custom_components/thinq_v2/climate.py", line 245, in swing_mode
    if v[0] == self._state.horz_swing and v[1] == self._state.vert_swing:
  File "/usr/local/lib/python3.8/site-packages/wideq/ac.py", line 440, in horz_swing
    lookup_enum("airState.wDir.hStep", self.data, self.ac)
  File "/usr/local/lib/python3.8/site-packages/wideq/util.py", line 17, in lookup_enum
    return device.model.enum_name(attr, data[attr])
KeyError: 'airState.wDir.hStep'
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/thinq_v2/climate.py:245
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:51:48 PM (7 occurrences)
Last logged: 12:53:07 PM

[140134379861280] 'airState.wDir.hStep'
[140134351998496] 'airState.wDir.hStep'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 143, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1480, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1515, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 206, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 666, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 336, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 269, in state_attributes
    data[ATTR_SWING_MODE] = self.swing_mode
  File "/config/custom_components/thinq_v2/climate.py", line 245, in swing_mode
    if v[0] == self._state.horz_swing and v[1] == self._state.vert_swing:
  File "/usr/local/lib/python3.8/site-packages/wideq/ac.py", line 440, in horz_swing
    lookup_enum("airState.wDir.hStep", self.data, self.ac)
  File "/usr/local/lib/python3.8/site-packages/wideq/util.py", line 17, in lookup_enum
    return device.model.enum_name(attr, data[attr])
KeyError: 'airState.wDir.hStep'
Logger: homeassistant.components.climate
Source: helpers/entity_platform.py:133
Integration: Climate (documentation, issues)
First occurred: 12:46:34 PM (1 occurrences)
Last logged: 12:46:34 PM

The thinq_v2 platform for the climate integration does not support platform setup. Please remove it from your config.
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:133
Integration: Sensor (documentation, issues)
First occurred: 12:46:34 PM (1 occurrences)
Last logged: 12:46:34 PM

The thinq_v2 platform for the sensor integration does not support platform setup. Please remove it from your config.