安装miio_raw 插件https://github.com/syssi/xiaomi_raw,如下我的参考一下,自定义一个开关。
sensor:
- platform: xiaomi_miio_raw
name: mijia_Bat_Heater
host: x.x.x.x
token:xxx
switch:
# 卫生间浴霸的灯单独控制一下
- platform: template
switches:
mijia_yuba:
friendly_name: '卫生间灯'
value_template: "{%if states.sensor.mijia_bat_heater.attributes.power == 'on' %}on{%else%}off{%endif%}"
turn_on:
service: sensor.xiaomi_miio_raw_turn_on
data:
entity_id: sensor.mijia_bat_heater
turn_off:
service: sensor.xiaomi_miio_raw_turn_off
data:
entity_id: sensor.mijia_bat_heater
|