xiaomi_airconditioningcompanion icon indicating copy to clipboard operation
xiaomi_airconditioningcompanion copied to clipboard

automatic turn off AC when operating within homekit

Open KangKai1982 opened this issue 6 years ago • 28 comments

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

KangKai1982 avatar Aug 22 '18 14:08 KangKai1982

If you don't use homekit does it work properly?

syssi avatar Aug 22 '18 14:08 syssi

Yes, it works fine with home-assistant itself.

KangKai1982 avatar Aug 22 '18 16:08 KangKai1982

Please enable the debug output of the custom component and python-miio, too:

logger:
  default: warn
  logs:
    custom_components.climate.xiaomi_miio: debug
    miio: debug

Please reproduce the issue and provide the log again. Thanks!

syssi avatar Aug 22 '18 18:08 syssi

OK, here it is.

2018-08-23 07:38:18 DEBUG (Thread-6) [homeassistant.components.homekit.type_thermostats] climate.mi_acpartner4: Set heat-cool to 2
2018-08-23 07:38:18 DEBUG (SyncWorker_7) [miio.device] 192.168.1.231:54321 >>: {'id': 315, 'method': 'set_power', 'params': ['on']}
2018-08-23 07:38:18 DEBUG (SyncWorker_6) [miio.device] 192.168.1.231:54321 >>: {'id': 316, 'method': 'send_cmd', 'params': ['018022222101011BA2']}
2018-08-23 07:38:18 DEBUG (SyncWorker_7) [miio.device] 192.168.1.231:54321 (ts: 1970-01-12 17:34:32, id: 315) << {'result': ['ok'], 'id': 315}
2018-08-23 07:38:18 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Response received: ['ok']
2018-08-23 07:38:18 DEBUG (SyncWorker_1) [miio.device] 192.168.1.231:54321 >>: {'id': 316, 'method': 'get_model_and_state', 'params': []}
2018-08-23 07:38:18 DEBUG (SyncWorker_6) [miio.device] 192.168.1.231:54321 (ts: 1970-01-12 17:34:32, id: 316) << {'result': ['ok'], 'id': 316}
2018-08-23 07:38:18 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Response received: ['ok']
2018-08-23 07:38:18 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=1, fan_speed=Low, led=False, unit_of_measurement=°C, friendly_name=书房空调, supported_features=4801 @ 2018-08-23T07:38:18.717809+08:00>
2018-08-23 07:38:23 DEBUG (SyncWorker_1) [miio.device] Retrying with incremented id, retries left: 3
2018-08-23 07:38:23 DEBUG (SyncWorker_1) [miio.protocol] Unable to decrypt, returning raw bytes: b''
2018-08-23 07:38:23 DEBUG (SyncWorker_1) [miio.device] Got a response: Container:
    data = Container:
        data = b'' (total 0)
        value = b'' (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        data = b'!1\x00 \x00\x00\x00\x00\x03\x90\xe4\x15\x00\x0fw\xad' (total 16)
        value = Container:
            length = 32
            unknown = 0
            device_id = b'\x03\x90\xe4\x15' (total 4)
            ts = 1970-01-12 17:34:37
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = b')\n&\xc2\xb6\xa4XF0\xb7\x8c\xc0l\x1d\xe4\x0e' (total 16)
2018-08-23 07:38:23 DEBUG (SyncWorker_1) [miio.device] Discovered 0390e415 with ts: 1970-01-12 17:34:37, token: b'token---token'
2018-08-23 07:38:23 DEBUG (SyncWorker_1) [miio.device] 192.168.1.231:54321 >>: {'id': 417, 'method': 'get_model_and_state', 'params': []}
2018-08-23 07:38:23 DEBUG (SyncWorker_1) [miio.device] 192.168.1.231:54321 (ts: 1970-01-12 17:34:37, id: 417) << {'result': ['010500978022222102', '0101011BA280222221', '1'], 'id': 417}
2018-08-23 07:38:23 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Got new state: <AirConditioningCompanionStatus power=off, load_power=1, air_condition_model=010500978022222102, model_format=1, device_type=5,air_condition_brand=97,air_condition_remote=80222221,state_format=2,air_condition_configuration=01011BA2,led=False, target_temperature=27, swing_mode=SwingMode.Off, fan_speed=FanSpeed.Low, mode=OperationMode.Cool>
2018-08-23 07:38:23 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state climate.mi_acpartner4=off; 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=1, fan_speed=Low, led=False, unit_of_measurement=°C, friendly_name=书房空调, supported_features=4801 @ 2018-08-23T07:38:23.706849+08:00>

KangKai1982 avatar Aug 22 '18 23:08 KangKai1982

I commented the log message:

[homeassistant.components.homekit.type_thermostats] climate.mi_acpartner4: Set heat-cool to 2
[miio.device] 192.168.1.231:54321 >>: {'id': 315, 'method': 'set_power', 'params': ['on']}  # turn the device on
[miio.device] 192.168.1.231:54321 >>: {'id': 316, 'method': 'send_cmd', 'params': ['018022222101011BA2']}  # send new configuration
[miio.device] 192.168.1.231:54321 >>: {'id': 316, 'method': 'get_model_and_state', 'params': []}  # retrieve the new state
[miio.device] 192.168.1.231:54321 (ts: 1970-01-12 17:34:37, id: 417) << {'result': ['010500978022222102', '0101011BA280222221', '1'], 'id': 417} # the new state
[custom_components.climate.xiaomi_miio] Got new state: <AirConditioningCompanionStatus power=off, load_power=1, air_condition_model=010500978022222102, model_format=1, device_type=5,air_condition_brand=97,air_condition_remote=80222221,state_format=2,air_condition_configuration=01011BA2,led=False, target_temperature=27, swing_mode=SwingMode.Off, fan_speed=FanSpeed.Low, mode=OperationMode.Cool>  # the device is turned off

I assume the target temperature is the problem:

2018-08-23 07:38:18 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=1, fan_speed=Low, led=False, unit_of_measurement=°C, friendly_name=书房空调, supported_features=4801 @ 2018-08-23T07:38:18.717809+08:00>
2018-08-23 07:38:23 DEBUG (SyncWorker_1) [miio.device] 192.168.1.231:54321 >>: {'id': 417, 'method': 'get_model_and_state', 'params': []}

The current temperature (27.3 degree) and the target temperature (27 degree) is more or less equal. I assume if you change the target temperature to 22 degree the AC won't turn off immediately.

syssi avatar Aug 23 '18 06:08 syssi

just tried with target temperature set to 17/19/20, it does not help.

KangKai1982 avatar Aug 23 '18 07:08 KangKai1982

Could you provide additional logs with updated target temperature? Thanks!

syssi avatar Aug 23 '18 07:08 syssi

sure, here it is with target temperature set to 20

2018-08-23 15:28:45 DEBUG (Thread-7) [homeassistant.components.homekit.type_thermostats] climate.mi_acpartner4: Set heat-cool to 2 2018-08-23 15:28:45 DEBUG (SyncWorker_2) [miio.device] 192.168.1.231:54321 >>: {'id': 3, 'method': 'set_power', 'params': ['on']} 2018-08-23 15:28:45 DEBUG (SyncWorker_7) [miio.device] 192.168.1.231:54321 >>: {'id': 4, 'method': 'send_cmd', 'params': ['0100002970013014A1']} 2018-08-23 15:28:46 DEBUG (SyncWorker_2) [miio.device] 192.168.1.231:54321 (ts: 1970-01-13 01:25:43, id: 3) << {'result': ['ok'], 'id': 3} 2018-08-23 15:28:46 DEBUG (SyncWorker_7) [miio.device] 192.168.1.231:54321 (ts: 1970-01-13 01:25:44, id: 4) << {'result': ['ok'], 'id': 4} 2018-08-23 15:28:46 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Response received: ['ok'] 2018-08-23 15:28:46 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Response received: ['ok'] 2018-08-23 15:28:46 DEBUG (SyncWorker_9) [miio.device] 192.168.1.231:54321 >>: {'id': 5, 'method': 'get_model_and_state', 'params': []} 2018-08-23 15:28:46 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state climate.mi_acpartner4=Cool; current_temperature=26.9, min_temp=16, max_temp=30, temperature=20, 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=010500970000297001, load_power=2, fan_speed=Auto, led=False, unit_of_measurement=°C, friendly_name=书房空调, supported_features=4801 @ 2018-08-23T15:28:46.840549+08:00> 2018-08-23 15:28:46 DEBUG (SyncWorker_9) [miio.device] 192.168.1.231:54321 (ts: 1970-01-13 01:25:44, id: 5) << {'result': ['010500970000297001', '01013014A100002970', '1'], 'id': 5} 2018-08-23 15:28:46 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Got new state: <AirConditioningCompanionStatus power=off, load_power=1, air_condition_model=010500970000297001, model_format=1, device_type=5,air_condition_brand=97,air_condition_remote=2970,state_format=1,air_condition_configuration=013014A1,led=False, target_temperature=20, swing_mode=SwingMode.On, fan_speed=FanSpeed.Auto, mode=OperationMode.Cool> 2018-08-23 15:28:46 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state climate.mi_acpartner4=off; current_temperature=26.9, min_temp=16, max_temp=30, temperature=20, 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=010500970000297001, load_power=1, fan_speed=Auto, led=False, unit_of_measurement=°C, friendly_name=书房空调, supported_features=4801 @ 2018-08-23T15:28:46.868992+08:00>

KangKai1982 avatar Aug 23 '18 07:08 KangKai1982

I noticed if I operate in home-assistant webui, which works fine, the miio compontent only send 1 "set power" command instead of 2 "set power"&"send cmd"

below is the log when operating within webui, there is no "send_cmd" event for miio

2018-08-23 15:30:55 DEBUG (SyncWorker_2) [miio.device] 192.168.1.231:54321 >>: {'id': 8, 'method': 'set_power', 'params': ['on']} 2018-08-23 15:30:56 DEBUG (SyncWorker_2) [miio.device] 192.168.1.231:54321 (ts: 1970-01-13 01:27:53, id: 8) << {'result': ['ok'], 'id': 8} 2018-08-23 15:30:56 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Response received: ['ok'] 2018-08-23 15:30:56 DEBUG (SyncWorker_7) [miio.device] 192.168.1.231:54321 >>: {'id': 9, 'method': 'get_model_and_state', 'params': []} 2018-08-23 15:30:56 DEBUG (SyncWorker_7) [miio.device] 192.168.1.231:54321 (ts: 1970-01-13 01:27:53, id: 9) << {'result': ['010500970000297001', '0111301A0100002970', '2'], 'id': 9} 2018-08-23 15:30:56 DEBUG (MainThread) [custom_components.climate.xiaomi_miio] Got new state: <AirConditioningCompanionStatus power=on, load_power=2, air_condition_model=010500970000297001, model_format=1, device_type=5,air_condition_brand=97,air_condition_remote=2970,state_format=1,air_condition_configuration=11301A01,led=True, target_temperature=26, swing_mode=SwingMode.On, fan_speed=FanSpeed.Auto, mode=OperationMode.Cool> 2018-08-23 15:30:56 DEBUG (MainThread) [homeassistant.components.homekit.accessories] New_state: <state climate.mi_acpartner4=Cool; current_temperature=26.9, min_temp=16, max_temp=30, temperature=26, 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=010500970000297001, load_power=2, fan_speed=Auto, led=True, unit_of_measurement=°C, friendly_name=书房空调, supported_features=4801 @ 2018-08-23T15:30:56.148352+08:00>

KangKai1982 avatar Aug 23 '18 07:08 KangKai1982

Good catch! In this case we have to identify the services called by homekit.

syssi avatar Aug 23 '18 08:08 syssi

Hi, I noticed this same issue, I'm on latest HA 0.83.3 with lumi.acpartner.v3 on the latest firmware. every comand sent from homekit also sends a power off command

flexyneat avatar Dec 06 '18 09:12 flexyneat

I also notice the same power off issue when i try to control the AC from Home assistant

flexyneat avatar Dec 12 '18 10:12 flexyneat

Could somebody provide the configuration.yaml for a simple homekit setup? I would like to reproduce the issue.

syssi avatar Dec 20 '18 06:12 syssi

There is only a homekit: for setup Homekit in my configuration.yaml.

mgbaozi avatar Dec 20 '18 08:12 mgbaozi

same here. Issue exists with home assistant native HomeKit .

KangKai1982 avatar Dec 21 '18 02:12 KangKai1982

same issue, automatic turn off :(

anhnvme avatar Dec 21 '18 02:12 anhnvme

Just tried on the Dec. 31 version, sent 3 commands instead of 1 when change state in homekit.

KangKai1982 avatar Jan 04 '19 08:01 KangKai1982

Just tried the newest version that was updated as of 5 days ago, even within home assistant, it sends a power off command when changing the temperature.

This was previously the case with homekit, but now it affects controls from within HA. I also noticed the error below:

File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/homekit/type_thermostats.py", line 250, in update_state if isinstance(target_temp, float) and current_temp > target_temp: TypeError: unorderable types: NoneType() > float()

flexyneat avatar Jan 05 '19 18:01 flexyneat

Issue still open, even temperature changes or any form of operation from lovelace turn off the AC

flexyneat avatar May 16 '19 05:05 flexyneat

same problem,my AC is hisence and i control AC flawlessly in MiHome App but i can't control my AC in hass

tzm112 avatar Jun 02 '19 05:06 tzm112

same problem,my AC is hisence and i control AC flawlessly in MiHome App but i can't control my AC in hass

yea, me too. My AC is Hisense. I'm now running hass 0.93.2

flexyneat avatar Jun 02 '19 07:06 flexyneat

Are we still talking about Homekit here?

syssi avatar Jun 02 '19 07:06 syssi

Are we still talking about Homekit here?

I believe originally the problem was only occurring in Homekit, but now any controls /commands issued from HA interface also turns off the AC

flexyneat avatar Jun 02 '19 07:06 flexyneat

Could you enable the debug log again and provide some commented logs?

syssi avatar Jun 02 '19 08:06 syssi

ofcourse image

tzm112 avatar Jun 02 '19 08:06 tzm112

my ac's ip is 192.168.50.40

tzm112 avatar Jun 02 '19 09:06 tzm112

I need a log which illustrates the issue. For example: Turn the AC on, wait a few seconds and change the target temperature. The Status object should indicate power=off afterwards.

syssi avatar Jun 02 '19 17:06 syssi

i will give it to you on tomorrow。

tzm112 avatar Jun 02 '19 17:06 tzm112