HomeAssistant0.83版本中小米无线开关等设备无法使用解决办法

在最新的HomeAssistant0.83版本中,对小米无线开关、Aqara墙壁无线开关及魔方的自动化触发语句做了修改,大家可以按照下面的示例来进行相应的修改。

小米无线开关

- alias: Toggle dining light on single press
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.switch_158d000xxxxxc2
      click_type: single
  action:
    service: switch.toggle
    entity_id: switch.wall_switch_left_158d000xxxxx01
- alias: Toggle couch light on double click
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.switch_158d000xxxxxc2
      click_type: double
  action:
    service: switch.toggle
    entity_id: switch.wall_switch_right_158d000xxxxx01
- alias: Let a dog bark on long press
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.switch_158d000xxxxxc2
      click_type: long_click_press
  action:
    service: xiaomi_aqara.play_ringtone
    data:
      gw_mac: xxxxxxxxxxxx
      ringtone_id: 8
      ringtone_vol: 8

Aqara墙壁无线开关

- alias: Decrease brightness of the gateway light
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.wall_switch_left_158xxxxxxxxx12
      click_type: single
  action:
    service: light.turn_on
    entity_id: light.gateway_light_34xxxxxxxx13
    data_template:
      brightness: >-
        {% if states.light.gateway_light_34xxxxxxxx13.attributes.brightness %}
              {% if states.light.gateway_light_34xxxxxxxx13.attributes.brightness - 60 >= 10 %}
                {{states.light.gateway_light_34xxxxxxxx13.attributes.brightness - 60}}
              {% else %}
                {{states.light.gateway_light_34xxxxxxxx13.attributes.brightness}}
              {% endif %}
        {% else %}
          10
        {% endif %}

- alias: Increase brightness of the gateway light
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.wall_switch_right_158xxxxxxxxx12
      click_type: single
  action:
    service: light.turn_on
    entity_id: light.gateway_light_34xxxxxxxx13
    data_template:
      brightness: >-
        {% if states.light.gateway_light_34xxxxxxxx13.attributes.brightness %}
              {% if states.light.gateway_light_34xxxxxxxx13.attributes.brightness + 60 <= 255 %}
                {{states.light.gateway_light_34xxxxxxxx13.attributes.brightness + 60}}
              {% else %}
                {{states.light.gateway_light_34xxxxxxxx13.attributes.brightness}}
              {% endif %}
        {% else %}
          10
        {% endif %}

- alias: Turn off the gateway light
  trigger:
    platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.wall_switch_both_158xxxxxxxxx12
      click_type: both
  action:
    service: light.turn_off
    entity_id: light.gateway_light_34xxxxxxxx13

小米魔方

- alias: Cube event flip90
  trigger:
    platform: event
    event_type: xiaomi_aqara.cube_action
    event_data:
      entity_id: binary_sensor.cube_15xxxxxxxxxxxx
      action_type: flip90
  action:
    - service: light.turn_on
      entity_id: light.gateway_light_28xxxxxxxxxx
      data:
        color_name: "springgreen"
- alias: Cube event flip180
  trigger:
    platform: event
    event_type: xiaomi_aqara.cube_action
    event_data:
      entity_id: binary_sensor.cube_15xxxxxxxxxxxx
      action_type: flip180
  action:
    - service: light.turn_on
      entity_id: light.gateway_light_28xxxxxxxxxx
      data:
        color_name: "darkviolet"
- alias: Cube event move
  trigger:
    platform: event
    event_type: xiaomi_aqara.cube_action
    event_data:
      entity_id: binary_sensor.cube_15xxxxxxxxxxxx
      action_type: move
  action:
    - service: light.turn_on
      entity_id: light.gateway_light_28xxxxxxxxxx
      data:
        color_name: "gold"
- alias: Cube event tap_twice
  trigger:
    platform: event
    event_type: xiaomi_aqara.cube_action
    event_data:
      entity_id: binary_sensor.cube_15xxxxxxxxxxxx
      action_type: tap_twice
  action:
    - service: light.turn_on
      entity_id: light.gateway_light_28xxxxxxxxxx
      data:
        color_name: "deepskyblue"
- alias: Cube event shake_air
  trigger:
    platform: event
    event_type: xiaomi_aqara.cube_action
    event_data:
      entity_id: binary_sensor.cube_15xxxxxxxxxxxx
      action_type: shake_air
  action:
    - service: light.turn_on
      entity_id: light.gateway_light_28xxxxxxxxxx
      data:
        color_name: "blue"

Aqara震动传感器

- alias: Turn on Living Room Lamp on vibration
  trigger:
    platform: event
    event_type: xiaomi_aqara.movement
    event_data:
      entity_id: binary_sensor.vibration_xxxx000000
      movement_type: vibrate
  action:
    service: light.toggle
    data:
      entity_id: light.living_room_lamp
- alias: Turn on Living Room Lamp on tilt
  trigger:
    platform: event
    event_type: xiaomi_aqara.movement
    event_data:
      entity_id: binary_sensor.vibration_xxxx000000
      movement_type: tilt
  action:
    service: light.toggle
    data:
      entity_id: light.living_room_lamp