LG Smartthinq Air Conditioning

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.

the card will show a bunch of stuff that does not apply this LG thing is clunky at best right now
just a few days ago it was not even working as good as it is now in fact I only was able to get Home assistant to see them with the marciogranzotto’s last update,

my logs suggest I should remove it as well but it is working so I ignore the error for now LOL

did you edit line 243 so the == is now a != as your log shows otherwise

Thanks @trentjw. This is what I have in my climate.py. The change is there and correct, I think.

   @property
    def swing_mode(self):
        # try to find out if the (initial) state matches a known state actually
        if self._swing_mode != SWING_MODE_DEFAULT and self._state is not None:
            for k, v in swing_modes_index().items():
                if v[0] == self._state.horz_swing and v[1] == self._state.vert_swing:
                    self._swing_mode = k
                    break
            else:
                return SWING_MODE_DEFAULT

if that is the same format as what is on your file the spacing looks to be off

I believe the spacing is correct. I will try uninstalling the component and starting over with a clean set of files.

Hi, i install the github in hacs. I install the LS SMARTHTHING V2.

Sorry but i don’t understand what to do After.

Just go to Configurations > Integrations and add the Smartthinq v2 Appliances integration and follow the instructions that will appear

image

1 Like

did you get it working?

Many thanks, all are ok !!!