EugeneLiu / xiaomi_airconditioningcompanionMCN02

Model lumi.acpartner.mcn02 Xiaomi air conditioning companion access HomeAssistent.
89 stars 23 forks source link

[Help Wanted] 实体的状态不可靠 #6

Open Vizards opened 3 years ago

Vizards commented 3 years ago

我在尝试使用 xiaomi_airconditioningcompanionMCN02 构建一个类型为 Generic Thermostat 的 climate 实体。发现在调用 turn_on 或者 turn_off 之后,climate.xiaomi_air_conditioning_companion_2.hvac_mode 不能被检测到立即改变,所以就会出现调用 turn_on 后无法调用 turn_off

configuration.yaml 如下:

- platform: xiaomi_miio_airconditioningcompanion #小米空调伴侣2
  name: xiaomi Air Conditioning Companion 2
  host: IP
  token: TOKEN
  target_sensor: sensor.temperature_158d0001f53706
  scan_interval: 60
- platform: generic_thermostat #通用恒温器,真实空调实体
  name: Bedroom Air Conditioner
  heater: switch.bedroom_ac
  target_sensor: sensor.climate_bedroom_ac
  min_temp: 16
  max_temp: 31
  precision: 1

switch:
  - platform: template #通用恒温器所需模板开关
    switches:
      bedroom_ac:
        friendly_name: 卧室空调
        value_template: "{{ not is_state('climate.xiaomi_air_conditioning_companion_2.hvac_mode', 'off') }}"
        turn_on:
          - service: climate.turn_on
            data:
              entity_id: climate.xiaomi_air_conditioning_companion_2
        turn_off:
          - service: climate.turn_off
            data:
              entity_id: climate.xiaomi_air_conditioning_companion_2

所以想咨询下有无可靠的方案去检测当前空调的状态,让 switch 实体可以将它作为 value_template 使用?