小米无线开关可以实现单机双击长按等触发操作,本教程我们会把小米无线开关接入到Home Assitant里不需要小米网关支持,使用我们之前介绍的CC2531方案通过zigbee2mqtt接入Home Assistant。
接入之后支持单机,双击,三击,四击,多击和长按,一共六个触发对象,可以定义六个开关类型,完美替代手动开关按钮。

自制ZigBee网关教程参考下面链接:
树莓派刷cc2531固件传送门:https://sumju.net/?p=1862
NodeMCU刷cc2531固件传送门:https://sumju.net/?p=1818

视频教程:

Home Assistant配置如下:

sensor:
  - platform: mqtt
    name: 按钮电量
    state_topic: "zigbee2mqtt/0x00158d00033ec7b8"  #替换你自己设备ID,并删掉这句注释。
    value_template: "{{ value_json.battery }}"
    unit_of_measurement: "%"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_available: "online"
    payload_not_available: "offline"
    qos: 0
    device_class: battery

  - platform: mqtt
    name: 按钮信号强度
    state_topic: "zigbee2mqtt/0x00158d00033ec7b8"  #替换你自己设备ID,并删掉这句注释。
    value_template: "{{ value_json.linkquality }}"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_available: "online"
    payload_not_available: "offline"
    qos: 0
    device_class: signal_strength

  - platform: mqtt
    name: 小米按钮
    state_topic: "zigbee2mqtt/0x00158d00033ec7b8"  #替换你自己设备ID,并删掉这句注释。
    value_template: "{{ value_json.click }}"
    availability_topic: "zigbee2mqtt/bridge/state"
    payload_available: "online"
    payload_not_available: "offline"

自动化配置三击举例(automations.yaml):

- id: '1591171037764'
  alias: 小米按钮_三击_开大电视
  description: ''
  trigger:
  - entity_id: sensor.xiao_mi_an_niu  #替换你自己小米按钮传感器ID,并删掉这句注释。
    platform: state
    to: triple
  condition: []
  action:
  - data: {}
    entity_id: switch.da_dian_shi   #替换你要控制的开关ID,并删掉这句注释。
    service: switch.toggle
  - data:
      payload: '{"click":"none"}'
      topic: zigbee2mqtt/0x00158d00033ec7b8  #替换你自己设备ID,并删掉这句注释。
    service: mqtt.publish

2 对 “小米无线开关接入Home Assistant 无需小米网关 (CC2531方案)”的想法;

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据