Code Monkey home page Code Monkey logo

xiaomi_airconditioningcompanion's Introduction

Xiaomi Mi and Aqara Air Conditioning Companion

GitHub actions GitHub stars GitHub forks GitHub watchers "Buy Me A Coffee"

This is a custom component for home assistant to integrate the Xiaomi Mi and Aqara Air Conditioning Companion:

Model ID Model number Product name Shape
acpartner.v1 KTBL01LM Aqara Air Conditioning Companion square
acaprtner.v2 KTBL02LM Xiaomi Mi Air Conditioner Companion round
acpartner.v3 KTBL11LM Aqara Air Conditioning Companion square

Unsupported devices: lumi.acpartner.mcn02

Please follow the instructions on Retrieving the Access Token to get the API token to use in the configuration.yaml file.

Credits: Thanks to Rytilahti for all the work.

Features

  • Power (on, off)
  • Operation Mode (Heat, Cool, Auto, Dehumidify, Ventilate)
  • Fan Speed (Low, Medium, High, Auto)
  • Swing Mode (On, Off)
  • Target Temperature
  • Capture and replay infrared commands
  • Attributes
    • ac_model
    • ac_power (on, off)
    • load_power (Wh)
    • operation_mode
    • fan_speed
    • swing_mode

Install

You can install this custom component by adding this repository (https://github.com/syssi/xiaomi_airconditioningcompanion) to HACS in the settings menu of HACS first. You will find the custom component in the integration menu afterwards, look for 'Xiaomi Mi and Aqara Air Conditioning Companion Integration'. Alternatively, you can install it manually by copying the custom_component folder to your Home Assistant configuration folder.

Setup

# configuration.yaml

climate:
  - platform: xiaomi_miio_airconditioningcompanion
    name: Aqara Air Conditioning Companion
    host: 192.168.130.71
    token: b7c4a758c251955d2c24b1d9e41ce47d
    target_sensor: sensor.temperature_158d0001f53706
    scan_interval: 60

climate entity

Debugging

If the custom component doesn't work out of the box for your device please update your configuration to enable a higher log level:

# configuration.yaml

logger:
  default: warn
  logs:
    custom_components.xiaomi_miio_airconditioningcompanion: debug
    miio: debug

Platform services

Service xiaomi_miio_airconditioningcompanion.climate_learn_command

Capture an infrared command.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
slot yes Storage slot. Defaults to slot ID 30.
timeout yes Capturing timeout. Defaults to 10 seconds.

Service xiaomi_miio_airconditioningcompanion.climate_send_command

Send captured infrared command or device configuration.

Service data attribute Optional Description
entity_id no Only act on a specific Xiaomi miIO fan entity.
command no Infrared command. Must start with FE or 01.

xiaomi_airconditioningcompanion's People

Contributors

anhnvme avatar befantasy avatar ilarrain avatar ktibow avatar neotf avatar ntcong avatar nurikk avatar saury avatar syssi avatar tiandeyu avatar toraidl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xiaomi_airconditioningcompanion's Issues

Update fails with ValueError: invalid literal for int() with base 10: 'A'

2018-05-08 12:13:31 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.aqara_air_conditioning_companion fails
Traceback (most recent call last):
File "/home/hass/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
yield from self.async_device_update()
File "/home/hass/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 325, in async_device_update
yield from self.async_update()
File "/home/hass/.homeassistant/custom_components/climate/xiaomi_miio.py", line 212, in async_update
ATTR_LED: state.led,
File "/home/hass/homeassistant/lib/python3.6/site-packages/miio/airconditioningcompanion.py", line 106, in led
return 'on' if (int(self.data[1][8:9]) == Led.On.value) else 'off'
ValueError: invalid literal for int() with base 10: 'A'

Swing Mode Definition

As far as I know, actually Swing Mode here doesn't represent for direction up and down. It should be recognized as boolean value for on and off. Is it defined by Home Assistant's climate component? If so maybe we can add another 2 modes for on and off?

Error on HA 0.66

Hi,

upgraded to HA 0.66 and i get the following error:

xiaomi_miio: Error on device update!
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 188, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 325, in async_device_update
    yield from self.async_update()
  File "/config/custom_components/climate/xiaomi_miio.py", line 205, in async_update
    ATTR_TEMPERATURE: state.temperature,
AttributeError: 'AirConditioningCompanionStatus' object has no attribute 'temperature'

My configuration:

climate:
  - platform: xiaomi_miio
    name: Aqara Air Conditioning Companion
    host: 192.168.x.xx
    token: aefec50f7xxxxxxxxxxxxxxxxxxx
    target_sensor: sensor.temperature_158d0001f53706
    scan_interval: 60

I do not have a sensor connected to my Air Condition companion.

ValueError: 7 is not a valid SwingMode

xiaomi_miio: Error on device update!
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/local/lib/python3.6/dist-packages/homeassistant/helpers/entity.py", line 347, in async_device_update
await self.async_update()
File "/root/.homeassistant/custom_components/climate/xiaomi_miio.py", line 270, in async_update
ATTR_SWING_MODE: state.swing_mode.name,
File "/root/.homeassistant/deps/lib/python3.6/site-packages/miio/airconditioningcompanion.py", line 215, in swing_mode
return SwingMode(mode)
File "/usr/lib/python3.6/enum.py", line 291, in call
return cls.new(cls, value)
File "/usr/lib/python3.6/enum.py", line 533, in new
return cls.missing(value)
File "/usr/lib/python3.6/enum.py", line 546, in missing
raise ValueError("%r is not a valid %s" % (value, cls.name))
ValueError: 7 is not a valid SwingMode

Cannot capture infrared command

Hass version 0.77.3
when i was calling climate.xiaomi_miio_learn_command without any arguments,
i could only get an error: [custom_components.climate.xiaomi_miio] Timeout. No infrared command captured, although i pressed the remote control for several times

Can not connect acpartner

After update xiaomi_miio.py(ae8e2e8),Can not connect acpartner.
Model ID:acaprtner.v2
Log:

2018-08-22 19:55:21 INFO (MainThread) [custom_components.climate.xiaomi_miio] Initializing with host 192.168.11.178 (token 2ae89...)
2018-08-22 19:55:21 INFO (MainThread) [custom_components.climate.xiaomi_miio] lumi.acpartner.v2 1.4.1_144 MW300 detected
2018-08-22 19:55:21 ERROR (MainThread) [homeassistant.components.climate] xiaomi_miio: Error on device update!
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
await entity.async_device_update(warning=False)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 320, in async_device_update
yield from self.async_update()
File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 268, in async_update
ATTR_AIR_CONDITION_MODEL: state.air_condition_model.hex(),
AttributeError: 'str' object has no attribute 'hex'

Error on updating Operation Mode

At startup, i faced the error of retrieving Operation Mode.

def async_update(self):
...
    self._state_attrs = {
        ATTR_AIR_CONDITION_MODEL: state.air_condition_model,
        ATTR_AIR_CONDITION_POWER: state.air_condition_power,
        ATTR_TEMPERATURE: state.temperature,
        ATTR_SWING_MODE: state.swing_mode,
        ATTR_FAN_SPEED: state.fan_speed.name,
        ATTR_OPERATION_MODE: state.operation_mode.name,
    }
...

Error in the last operation_mode.name property

    state.operation_mode is bool, undefined name property

Turn off the AC without any action

I found it always turn off the AC without any action.

e.g I turn on the AC with RC, about 1 hr, the AC seems turned off by the HASS without any action.

error message in home-assistant 0.66

Home-assistant 0.66 release
python-miio updated to 0.39

config:

- platform: xiaomi_miio
      name: mi_acpartner
      host: 192.168.1.107
      token: 53dxxxxxxxxxxxxxxxxxxxx
      target_sensor: sensor.temperature_xxxxxxxxxxxx
      scan_interval: 60

error log message:

xiaomi_miio: Error on device update!
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 188, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/app/homeassistant/helpers/entity.py", line 325, in async_device_update
    yield from self.async_update()
  File "/config/custom_components/climate/xiaomi_miio.py", line 206, in async_update
    ATTR_SWING_MODE: state.swing_mode.name,
AttributeError: 'bool' object has no attribute 'name'

Error executing service <ServiceCall climate.set_operation_mode: entity_id=['climate.aqara_air_conditioning_companion'], operation_mode=auto>

Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1021, in _event_to_service_call
await service_handler.func(service_call)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/climate/init.py", line 400, in async_operation_set_service
await climate.async_set_operation_mode(operation_mode)
File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 342, in async_set_operation_mode
yield from self._send_configuration()
File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 366, in _send_configuration
OperationMode[self._current_operation],
File "/usr/lib/python3.5/enum.py", line 277, in getitem
return cls.member_map[name]
KeyError: 'auto'

homeassistant 0.72,python-miio 0.4.0 ,got error.

Thanks for your great job,recently I update the new homeassistant version and got an error when i control the airconditon:
Error executing service <ServiceCall climate.set_temperature: temperature=24.0, entity_id=['climate.ac1']>
Traceback (most recent call last):
File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/core.py", line 1007, in _event_to_service_call
await service_handler.func(service_call)
File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/homeassistant/components/climate/init.py", line 339, in async_temperature_set_service
await climate.async_set_temperature(**kwargs)
File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 324, in async_set_temperature
yield from self._send_configuration()
File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 370, in _send_configuration
Led.Off,
File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 165, in _try_command
partial(func, *args, **kwargs))
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.6/site-packages/miio/airconditioningcompanion.py", line 395, in send_configuration
configuration = configuration.replace('[tt]', format(target_temperature, 'X'))
ValueError: Unknown format code 'X' for object of type 'float'

automatic turn off AC when operating within homekit

Successfully added my acpartner.v2 device to the homekit.app with homeassistant native homekit component
but when operate the climate, it always send off signal right after any signal, so the ac can not be turned on
homekit component log as below

2018-08-22 22:34:34 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state climate.mi_acpartner4=Cool; current_temperature=27.3, min_temp=16, max_temp=30, temperature=27, target_temp_step=1, fan_mode=Low, fan_list=['Low', 'Medium', 'High', 'Auto'], operation_mode=Cool, operation_list=['Heat', 'Cool', 'Auto', 'Dehumidify', 'Ventilate'], swing_mode=Off, swing_list=['On', 'Off', 'Unknown'], ac_model=010500978022222102, load_power=407, fan_speed=Low, led=False, unit_of_measurement=°C, friendly_name=书房空调, supported_features=4801 @ 2018-08-22T22:34:34.021713+08:00>
2018-08-22 22:34:34 DEBUG (SyncWorker_8) [pyhap.characteristic] set_value: CurrentTemperature to 27.3
2018-08-22 22:34:34 DEBUG (SyncWorker_8) [pyhap.characteristic] set_value: TargetTemperature to 27
2018-08-22 22:34:34 DEBUG (SyncWorker_8) [pyhap.characteristic] set_value: TemperatureDisplayUnits to 0
2018-08-22 22:34:34 DEBUG (SyncWorker_8) [pyhap.characteristic] set_value: CurrentHeatingCoolingState to 0

The following components and platforms could not be set up

Hello, I got error message like this:

"The following components and platforms could not be set up

  • climate.xiaomi_miio
    Please check your config."

Here's my config.yaml

climate:

  • platform: xiaomi_miio
    name: Aqara Air Conditioning Companion
    host: 192.168.1.107
    token: mytoken
    target_sensor: sensor.temperature_158d0001f53706
    scan_interval: 60

I'm very beginner with this so please help me :(
Thanks

Bug with Home Assistant 0.69.1 version

1

Update for climate.xiaomi_air_conditioner fails

Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
yield from self.async_device_update()
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 325, in async_device_update
yield from self.async_update()
File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 212, in async_update
ATTR_LED: state.led,
File "/srv/homeassistant/lib/python3.5/site-packages/miio/airconditioningcompanion.py", line 106, in led
return 'on' if (int(self.data[1][8:9]) == Led.On.value) else 'off'
ValueError: invalid literal for int() with base 10: 'A'

2

Error executing service <ServiceCall climate.set_temperature: entity_id=['climate.xiaomi_air_conditioner'], temperature=26.0>

Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1002, in _event_to_service_call
await service_handler.func(service_call)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/climate/init.py", line 332, in async_temperature_set_service
await climate.async_set_temperature(**kwargs)
File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 324, in async_set_temperature
yield from self._send_configuration()
File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 366, in _send_configuration
OperationMode[self._current_operation],
File "/usr/lib/python3.5/enum.py", line 277, in getitem
return cls.member_map[name]
KeyError: 'cool'

[Question] Not able to retrieve Token

I'm not able to retrieve the token anymore from the MiHome app, I did it in the past, but I'm not able to do it following the instructions from HomeAssistant page, I'm using China Mainland and English, I select the gateway, click on the three dots up right, but the "about" button is not there, so I'm not able to enable/disable lan_mode nor to see the password and token. I tried with IOS and with Android.

Is there any other way to get it?

Cheers

'Unknown' swing mode seems to be accepted(?)

Steps to reproduce:

  1. Open UI of custom component
  2. Select 'Unknown' in drop down of 'Swing Mode' value
  3. Expected behavior: Air condition unit should produce noise to acknowledge acceptance
    3a. Current behavior: Air condition unit produced no noise
  4. Changed 'Heat' value from 23 to 24 degrees and confirmed
  5. Expected behavior: Air condition unit should produce noise to acknowledge acceptance
    5a. Current behavior: Air condition unit produced no noise
  6. Waited 60 seconds
  7. Expected behavior: If the unknown value hadn't been accepted swing mode and heat should've reverted back.
    7a. Current behavior: The swing mode remained to unknown and the heat value remained to 24 degrees.
  8. Restarting home-assistant also retained the values.

Log from trying to set temperature while Swing Mode set to 'Unknown':

2018-12-03 21:10:52 DEBUG (SyncWorker_1) [miio.device] 192.168.1.168:54321 >>: {'id': 4, 'method': 'send_cmd', 'params': ['0100004666101217A1']}
2018-12-03 21:10:52 DEBUG (SyncWorker_1) [miio.device] 192.168.1.168:54321 (ts: 1970-01-01 00:22:48, id: 4) << {'result': ['ok'], 'id': 4}
2018-12-03 21:10:52 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Response received: ['ok']
2018-12-03 21:10:52 DEBUG (SyncWorker_11) [miio.device] 192.168.1.168:54321 >>: {'id': 5, 'method': 'get_model_and_state', 'params': []}
2018-12-03 21:10:52 DEBUG (SyncWorker_11) [miio.device] 192.168.1.168:54321 (ts: 1970-01-01 00:22:48, id: 5) << {'result': ['010504870000466601', '01101217A100004666', '0'], 'id': 5}
2018-12-03 21:10:52 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Got new state: <AirConditioningCompanionStatus power=on, load_power=0, air_condition_model=010504870000466601, model_format=1, device_type=5, air_condition_brand=487, air_condition_remote=4666, state_format=1, air_condition_configuration=101217A1, led=False, target_temperature=23, swing_mode=SwingMode.Unknown, fan_speed=FanSpeed.Medium, mode=OperationMode.Heat>

Update for climate.aqara_air_conditioning_companion fails

HI,
got some error when try to change values.
Update for climate.aqara_air_conditioning_companion fails Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 204, in async_update_ha_state yield from self.async_device_update() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 325, in async_device_update yield from self.async_update() File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 212, in async_update ATTR_LED: state.led, File "/srv/homeassistant/lib/python3.5/site-packages/miio/airconditioningcompanion.py", line 106, in led def air_condition_model(self) -> bytes: ValueError: invalid literal for int() with base 10: 'A'

Hitachi AC support

Hi all. I just ordered two of v2 xiaomi devices but couldn't find a supported ac list. Is there a list available somewhere? I have Hitachi ac at hone and wanna use this component for it

Swing mode throws attribute error

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 197, in _async_add_entity
    yield from entity.async_device_update(warning=False)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 325, in async_device_update
    yield from self.async_update()
  File "/Users/cxlwill/.homeassistant/custom_components/climate/xiaomi_miio.py", line 208, in async_update
    ATTR_SWING_MODE: state.swing_mode.name,
AttributeError: 'bool' object has no attribute 'name'

Improve/Fix Daikin 10502 support

Dir sir.
I installed as a guide, HA can synchronize with Mihome, but can't control AC Daikin.
I tried to control it with MiHome when I was suspended again, and after a few minutes I could control it with MiHome.
Can you help me with the setting?
I used acpartner.v3.
Thanks

Gateway function support

One more issue that needs further digging, AC partner has Gateway function. Actually LAN mode can be turned on at the latest version of firmware (2.49.3).

But unlike normal gateway, it seems follow new Aqara protocol and didn't open TCP/UDP port we know for communication with sub-devices. Without knowledge of protocol, we can't do anything now.

Generally speaking, this issue should be assigned to Pyxiaomigateway repository. But if we do so then this device actually would be divided into 3 parts. One - gateway, two - climate, three - IR Remote. Even we followed this method, maybe use this place to make intensive discussion is better.

Component doesn't work

Hi,
i have an Aqara Air Conditioning Companion (Air condition partner) which i believe is the one relevant for this component.
I can ping the gateway and i get no errors while hassio boots but for some reason i get the following error when i click the on/off button in the dashboard:

Error executing service <ServiceCall climate.turn_off: entity_id=['climate.aqara_air_conditioning_companion']>
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
yield from service_handler.func(service_call)
File "/usr/lib/python3.6/site-packages/homeassistant/components/climate/init.py", line 443, in async_on_off_service
yield from climate.async_turn_off()
File "/usr/lib/python3.6/asyncio/futures.py", line 332, in iter
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
future.result()
File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
raise self._exception
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3.6/site-packages/homeassistant/components/climate/init.py", line 773, in turn_off
raise NotImplementedError()
NotImplementedError

The FW version is:
1.41_145.0143

needless to say that i see no response from my ac.

I have some basic linux and coding (mainly python) skills.
I would like to help testing this component.

love your work,
Lior.

async_set_fan_mode() got an unexpected keyword argument 'fan_mode'

Changing fan mode from "high" to "medium" - didn't seem to get accepted neither through a beepbeep sound neither through the unit itself it still blows in high:

2018-12-02 12:22:25 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 277, in _handle_service_platform_call
    await getattr(entity, func)(**data)
TypeError: async_set_fan_mode() got an unexpected keyword argument 'fan_mode'

EDIT: Went back to "heat" from "ventilate" tried changing fan mode to "medium" from "high" again same log as above.

cp. #40 (comment)

@gsotiriou

set temp/operation_mode error

Sorry, my English is very poor.
Use Google Translate to write questions completely.

Use your component in ha 0.72.1, but the following error will occur.
The air conditioner switch can be used, but the set temperature, operation mode and wind speed cannot be used.

Use the previous version of your component at 0.71.0, set the operating mode and wind speed without errors, the air conditioner can receive the signal, but it does not actually take effect. The operation in the mi home app can take effect normally.

Seeing that your component is updated, and then updating the component and HA to the latest, the problem is now. Please take a look at it.

Error executing service <ServiceCall climate.set_operation_mode: entity_id=['climate.sub_room_air_conditioning_companion'], operation_mode=Ventilate> Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1007, in _event_to_service_call await service_handler.func(service_call) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/climate/__init__.py", line 400, in async_operation_set_service await climate.async_set_operation_mode(operation_mode) File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 342, in async_set_operation_mode yield from self._send_configuration() File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 370, in _send_configuration Led.Off, File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 165, in _try_command partial(func, *args, **kwargs)) File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/miio/airconditioningcompanion.py", line 395, in send_configuration configuration = configuration.replace('[tt]', format(target_temperature, 'X')) ValueError: Unknown format code 'X' for object of type 'float'

I can't setup my acpartner v2

My configuration.yaml
xiaomi_aqara:
discovery_retry: 5
gateways:
- mac: 7C49EB18D6C7
key: mq1wjw8epj7kr85j
host: 192.168.0.33
- mac: 7C49EB84540D
key: 036tj7xlk9c3s55m
host: 192.168.0.29
logger:
default: warn
logs:
homeassistant.components.xiaomi_aqara.binary_sensor: debug
homeassistant.components.xiaomi_aqara: debug
xiaomi_gateway: debug
climate:

  • platform: xiaomi_miio
    name: Aqara Air Conditioning Companion
    host: 192.168.0.29
    token: 4b70a67082968a1bc723127832e92921
    target_sensor: sensor.temperature_158d000254dc5e <--- it not show in state panel
    scan_interval: 60

When i check status:
climate.aqara_air_conditioning_companion

current_temperature: null
min_temp: 16
max_temp: 30
temperature: 255 <--- wrong temp
target_temp_step: 1
fan_mode: auto
fan_list: low,medium,high,auto
operation_mode: Heat
operation_list: heat,cool,auto,dehumidify,ventilate
swing_mode: On
swing_list: on,off,unknown
ac_model: 010500000000000000
load_power: 0
fan_speed: Auto
led: true
friendly_name: Aqara Air Conditioning Companion
supported_features: 4801
What can i now? Please help me

Provide Custom Updater support

Not an issue as such but rather feature request? But can't find any other way to communicate.

I started using customer updater / tracker card and I noticed they have an option for customer python scripts. I was wondering if you guys had seen it or considered incorporating it in xiaomi_airconditioningcompanion and xiaomiplug?

No AirConditioningCompanionStatus.air_condition_power and _device

The latest version of miio replace air_condition_power with load_power, currently, climate is using both results in an error
AttributeError: 'XiaomiAirConditioningCompanion' object has no attribute 'air_condition_power'

Same problem with turn_on and turn_off:
AttributeError: 'XiaomiAirConditioningCompanion' object has no attribute '_device'

Also when I tried to set temp:

  File "/config/custom_components/climate/xiaomi_miio.py", line 385, in async_set_temperature
    if self._target_temperature < self._target_temperature_low:
TypeError: '<' not supported between instances of 'NoneType' and 'float'

I'm trying to set the ac companion with a Mitsubishi Heavy AC, should it work right out the box with the generic template, or do I need to record the IR command?

I'm thinking about getting some debugging, is there any way to run the custom_component headless (without hass.io running)

Home Assistant 0.74.2 miio-4.0 get an error

File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 311, in _async_add_entity
'Invalid entity id: {}'.format(entity.entity_id))
homeassistant.exceptions.HomeAssistantError: Invalid entity id: climate.

Error loading custom_components.xiaomi_miio.climate in HA 0.89

When I update HA to 0.89 and put the latest climate.py and init.py into xiaomi_miio folder ,
xiaomi_miio dosen't worked and display the error like this
Error loading custom_components.xiaomi_miio_climate.climate. Make sure all dependencies are installed
Traceback (most recent call last):
File "/usr/src/app/homeassistant/loader.py", line 166, in _load_file
module = importlib.import_module(path)
File "/usr/local/lib/python3.7/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/custom_components/xiaomi_miio/climate.py", line 14, in
from homeassistant.components.climate import (
ImportError: cannot import name 'SUPPORT_ON_OFF' from 'homeassistant.components.climate' (/usr/src/app/homeassistant/components/climate/init.py)

ValueError: 2 is not a valid SwingMode

INFO:homeassistant.core:Bus:Handling <Event system_log_event[L]: level=ERROR, exception=Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_platform.py", line 188, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity.py", line 325, in async_device_update
    yield from self.async_update()
  File "/var/opt/homeassistant/custom_components/climate/xiaomi_miio.py", line 205, in async_update
    ATTR_SWING_MODE: state.swing_mode.name,
  File "/var/opt/homeassistant/deps/lib/python3.5/site-packages/miio/airconditioningcompanion.py", line 126, in swing_mode
    return SwingMode(mode)
  File "/usr/lib/python3.5/enum.py", line 241, in __call__
    return cls.__new__(cls, value)
  File "/usr/lib/python3.5/enum.py", line 476, in __new__
    raise ValueError("%r is not a valid %s" % (value, cls.__name__))
ValueError: 2 is not a valid SwingMode
, timestamp=1522652863.6614914, message=xiaomi_miio: Error on device update!, source=deps/lib/python3.5/site-packages/miio/airconditioningcompanion.py>

@nutinshell I think I have an idea what's going on. The format of the state property depends on the hardware version of the acpartner. :-( Could you provide the output of some

mirobo --ip <ip> --token <token> raw_command get_state_and_mode '[]'

calls? The output of

mirobo --ip <ip> --token <token> -d info

would be interesting, too.

Unable to find platform xiaomi_miio

After upgrading to 390faa9 , HA 0.89 cannot find other xiaomi_miio devices (switches, vacuums, etc).

Error log:
ERROR (MainThread) [homeassistant.loader] Unable to find platform xiaomi_miio. Search path was limited to path of component: custom_components

snipaste_2019-03-07_16-38-15

There is an error,homeassistant==0.69.1,and xiaomi_airconditioningcompanion Latest commit 04f8640

2018-07-07 12:37:12 INFO (MainThread) [homeassistant.components.climate] Setting up climate.xiaomi_miio
2018-07-07 12:37:12 INFO (MainThread) [custom_components.climate.xiaomi_miio] Initializing with host lumi-acpartner-v3_miio78476440 (token d8154...)
2018-07-07 12:37:12 INFO (MainThread) [custom_components.climate.xiaomi_miio] lumi.acpartner.v3 1.4.1_150 MW300 detected
2018-07-07 12:37:12 ERROR (MainThread) [custom_components.climate.xiaomi_miio] name:空调伴侣, device:<miio.airconditioningcompanion.AirConditioningCompanion object at 0x110b83748>, unique_id:lumi.acpartner.v3-78:11:DC:B2:A0:3E, sensor_entity_id:sensor.temperature_158d00020ef39b, min_temp:16, max_temp:30
2018-07-07 12:37:12 ERROR (MainThread) [custom_components.climate.xiaomi_miio] Got new state:
2018-07-07 12:37:12 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/anaconda3/lib/python3.6/asyncio/tasks.py", line 179, in _step
result = coro.send(None)
File "/usr/local/anaconda3/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 301, in _async_add_entity
'Invalid entity id: {}'.format(entity.entity_id))
homeassistant.exceptions.HomeAssistantError: Invalid entity id: climate.

Understanding the custom_component shenanigans

Hi, I have installed your component and I can see the information in my user interface. Previously I had used the companion with MiHome where I had registered my air-condition through a list of registered devices that Xiaomi has pre-selected settings (I assume).

Finging A) What has confused me is that your custom_component initialised already with some settings and it could control my air-condition out of the box (no training occurred).

Finding B) What I realised it "seems" as if the custom_component uses the last settings I used for my registered air-condition through MiHome when I used it through MiHome.

Finding C) Looking in of home assistant I see that my climate component has a value of "ac_model: 010504870000466601" which I suspect is inside the companion's memory now and forces it to use the necessary IR commands for this particular model.

Finding D) It is very unusual that the companion uses these specific settings only and refuses to change anything through the UI (like mode, fan speed, or temperature) - but the ON/OFF functionality works.

Do I need to somehow make it "forget" the ac_model variable and re-train the companion only through your custom_component?

Do I need to just "train" it for the rest commands that it cannot issue besides the ON/OFF that already works?

In terms of training how do slots exactly work? What is the philosophy? Based on the documentation I cannot understand right now, but if you help me understand, I am willing to put all this knowledge into examples and extend the existing documentation.

That is all for now in a nutshell! I will appreciate the effort and time you take to reply. And I already thank you and appreciate your hard work on this!

Regards,
George

Unable to serialize to JSON: Object of type 'bytes' is not JSON serializable

I run xiaomi_airconditioningcompanion with home assistant 0.72.1, and got this error.

2018-06-29 14:58:44 ERROR (MainThread) [homeassistant.components.websocket_api] Unable to serialize to JSON: Object of type 'bytes' is not JSON serializable
{'id': 2, 'type': 'event', 'event': {'event_type': 'state_changed', 'data': {'entity_id': 'climate.aqara_air_conditioning_companion', 'old_state': <state climate.aqara_air_conditioning_companion=Cool; current_temperature=23.4, min_temp=16, max_temp=30, temperature=23, target_temp_step=1, fan_mode=Auto, fan_list=['Low', 'Medium', 'High', 'Auto'], operation_mode=Cool, operation_list=['Heat', 'Cool', 'Auto', 'Dehumidify', 'Ventilate'], swing_mode=On, swing_list=['On', 'Off', 'Unknown'], ac_model=b'\x01\x05\'\x82\x00\x01"U\x01', load_power=245, fan_speed=Auto, led=True, unit_of_measurement=°C, friendly_name=空调遥控(桃桃), supported_features=4801 @ 2018-06-29T22:57:44.226084+08:00>, 'new_state': <state climate.aqara_air_conditioning_companion=Cool; current_temperature=23.4, min_temp=16, max_temp=30, temperature=23, target_temp_step=1, fan_mode=Auto, fan_list=['Low', 'Medium', 'High', 'Auto'], operation_mode=Cool, operation_list=['Heat', 'Cool', 'Auto', 'Dehumidify', 'Ventilate'], swing_mode=On, swing_list=['On', 'Off', 'Unknown'], ac_model=b'\x01\x05\'\x82\x00\x01"U\x01', load_power=237, fan_speed=Auto, led=True, unit_of_measurement=°C, friendly_name=空调遥控(桃桃), supported_features=4801 @ 2018-06-29T22:57:44.226084+08:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2018, 6, 29, 14, 58, 44, 268796, tzinfo=<UTC>)}}

I think the 'bytes' part is "ac_model=b'\x01\x05'\x82\x00\x01"U\x01'".

I don't know what is it.

home assistant configuration.yaml

climate:
  - platform: xiaomi_miio
    name: Aqara Air Conditioning Companion
    host: 192.168.1.254
    token: xxxxxxxxxxxxxx
    target_sensor: sensor.temperature_158d0001fa3b1a
    scan_interval: 60

using the newest version of xiaomi_airconditioningcompanion.

my device is acpartner.v3, firmware 1.4.1_150.0149.

If you need other informations, I will provide them.

Thank you.

IR Remote function support

Another issue, AC partner has IR remote learner inside which supply Air Conditioner IR codes for partner when some AC models unsupported naturally. So we can make use of chuangmi_ir component. Should we add this function into this component or add AC partner support for IR Remote component?

Missing attribute `load_power`

Home Assistant 0.65.4 with miio 0.3.8

2018-03-13 12:52:48 ERROR (MainThread) [homeassistant.components.climate] xiaomi_miio: Error on device update!
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 188, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 325, in async_device_update
    yield from self.async_update()
  File "/home/homeassistant/.homeassistant/custom_components/climate/xiaomi_miio.py", line 235, in async_update
    ATTR_LOAD_POWER: state.load_power,
AttributeError: 'AirConditioningCompanionStatus' object has no attribute 'load_power'

Google home speaker responds 'that mode isn't available for the bedroom AC' when told to turn on the thermostat

I set up a xiaomi_miio entity for my AC and I can use the web front end to control the On/Off of the AC. I named the entity 'bedroom AC'. I also have google home connected to my home assistant via the google_assistant component. I can say things like 'okay google, turn on the light' to the google home speaker and it can control the lights via home assistant. However, when I say 'okay google, turn on the bedroom AC', google speaker will reply 'Sorry, I don't know how to help with that'. If I say 'okay google, turn on the thermostat', google speaker replies 'Sorry, that mode isn't available for the bedroom AC'.

So it seems home assistant is able to control the AC. And google home is able to control devices on home assistant, but not the AC. Is there some issue with xiaomi_airconditioningcompanion that prevents google home from doing the voice control?

The device I use to control the AC is a lumi.acpartner.v2. My AC is not physically plugged to the power socket on the acpartner. So in Mi Home, I turned off the option 'Aircon On / off auto detection' (translated from Chinese, it's an option for the acpartner in Mi Home App). My google home is connected to home assistant using the setup described in https://www.home-assistant.io/components/google_assistant/

The on/off button sometimes doesn't work

Hello,
I'm very happy with your component. I installed it in Hassio for LG AC. My hardware is acpartner.v3.
I found a problem that sometimes the on/off button doesn't work, after using mi home application or the original ac's remote and trying several times then the on/off button do work again, and this often happens. The first time it's turned on then the operation menu always becomes "ventilate".

I also use Google Home and this component can be connected properly but there is no on/off function

I'm still new to Github, and thank you very much.

Should support new Climate interface

At startup of HASS, i faced this error

2018-02-20 08:57:07 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 222, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/lib/python3.6/site-packages/homeassistant/components/climate/__init__.py", line 502, in state_attributes
    supported_features = self.supported_features
  File "/usr/lib/python3.6/site-packages/homeassistant/components/climate/__init__.py", line 785, in supported_features
    raise NotImplementedError()
NotImplementedError
2018-02-20 08:57:07 INFO (MainThread) [homeassistant.core] Bus:Handling <Event system_log_event[L]: timestamp=1519091827.0205953, level=ERROR, message=Error doing job: Task exception was never retrieved, exception=Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 180, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 222, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/lib/python3.6/site-packages/homeassistant/components/climate/__init__.py", line 502, in state_attributes
    supported_features = self.supported_features
  File "/usr/lib/python3.6/site-packages/homeassistant/components/climate/__init__.py", line 785, in supported_features
    raise NotImplementedError()
NotImplementedError
, source=components/climate/__init__.py>

seems your custom component has not adapted new interface, the property supported_features should be implemented.
I suggest to change the xiaomi_miio.py as follow:

from homeassistant.components.climate import (
    PLATFORM_SCHEMA, ClimateDevice, ATTR_TARGET_TEMP_HIGH,
    ATTR_TARGET_TEMP_LOW, ATTR_OPERATION_MODE,
    SUPPORT_TARGET_TEMPERATURE,
    SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW,
    SUPPORT_OPERATION_MODE, SUPPORT_FAN_MODE, )
SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_TARGET_TEMPERATURE_HIGH |
                 SUPPORT_TARGET_TEMPERATURE_LOW | SUPPORT_OPERATION_MODE |
                 SUPPORT_FAN_MODE)
    @property
    def supported_features(self):
        """Return the list of supported features."""
        return SUPPORT_FLAGS

Fit KTBL11LM

Aqara Air has a new product model of KTBL11LM, The appearance is the same as KTBL01LM plugin support?

Zigbee thermostat device "lumi.airrtc.tcpecn01"

Sorry if I post at wrong Github project page. Not sure if I should report this under gateway issue or here since it's a Zigbee product.

I just bought this EigenStone thermostat recently, and it's manufactured by same company as Lumi / Aqara. Wonder how I can contribute miiocli of python-miio data with it. Since it's a zigbee product.

Thanks in advance.

Improve Gree 10727 support

Temperature incorrect: No Matter What temperature I set it to, it always stays at 17 °C.
Mode incorrect: Always stays in Ey mode (Ey mode: The AC automatically adjusts the work mode and temperature according to the environment. In this mode, neither temperature nor work mode can be set manually).
Turn off/on action correct.
HA ver: 0.89.1
AC: Gree (RC: Gree 10727)
Hardware: Aqara Air conditioning partner (square, acpartner.v3).

_20190308211746

_20190308211808

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.