智能家居之opple灯接入苹果家居

背景

21年入了opple的吸顶灯,买之前以为可以在手机控制灯光颜色,灯光亮度等参数(PS:当然确实也可以控制),然而安装后很打脸,我们是精装房,精装房的开关是可以控制灯的电源的.然后就变成了我需要把精装房的智能家居灯开关通上电才能控制opple的灯....

HA实现

原理:接入HA变相实现智能家居的开关和opple亮度组合成一个虚拟灯,具体代码如下

- platform: template
  lights:
    zhuwo_light:
      unique_id: "opple_light_zhuwo"
      friendly_name: "主卧大灯"
      level_template: "{{ state_attr('light.opple_cn_508516258_bydceiling_s_2', 'brightness') }}"
      temperature_template: "{{ state_attr('light.opple_cn_508516258_bydceiling_s_2', 'color_temp') }}"
      value_template: "{{ is_state('switch.two_switch_e_switch_02_4', 'on') }}"
      turn_on:
        service: switch.turn_on
        entity_id: switch.two_switch_e_switch_02_4
      turn_off:
        service: switch.turn_off
        entity_id: switch.two_switch_e_switch_02_4
      set_level:
          action: light.turn_on
          target:
            entity_id: light.opple_cn_508516258_bydceiling_s_2
          data:
            brightness: "{{ brightness }}"
      min_mireds_template: 176
      max_mireds_template: 333
      set_temperature:
          action: light.turn_on
          target: 
            entity_id: light.opple_cn_508516258_bydceiling_s_2
          data:
            color_temp: "{{ color_temp }}"

level_template:获取灯光亮度来源opple实体

temperature_template:获取灯光色温来源于opple的实体

turn_on/turn_off:控制灯的开关基于开发商提供的智能家居开关

set_level/set_temperature:控制的opple实体调用服务

接入HomeKit

最后基于homekit bridge组建接入“家庭”app即可~

最后附上两张效果图吧