yeelight亮度,色温,颜色ha里可以直接拿到的
我以前是用色温做的中转,现在用蓝牙转ttl了
以前的代码
sensor:
- platform: template
sensors:
rgb:
friendly_name: '灯光颜色'
value_template: "{{ state_attr('light.ru_hu_guo_dao_cai_guang_deng_dai','brightness') }}"
lockstatus:
friendly_name: '门锁状态'
value_template: "{{ '门开着' if is_state('input_boolean.lockopen','on') }} {{ '门关了' if is_state('input_boolean.locklocked','on') }} {{ '反锁了' if is_state('input_boolean.lockdoublelock','on') }} {{ '门没有锁' if is_state('input_boolean.lockunlock','on') }}"
automation:
- alias: 'lockopen' #门开着
trigger:
platform: numeric_state
entity_id: sensor.rgb
above: 251
below: 253
action: #行动
- service: input_boolean.turn_on
entity_id: input_boolean.lockopen
- service: input_boolean.turn_off
entity_id: input_boolean.locklocked
- service: input_boolean.turn_off
entity_id: input_boolean.lockdoublelock
- service: input_boolean.turn_off
entity_id: input_boolean.lockunlock
- alias: 'locklocked' #门关了
trigger:
platform: numeric_state
entity_id: sensor.rgb
# At least one of the following required
above: 254
below: 256
action: #行动
- service: input_boolean.turn_off
entity_id: input_boolean.lockopen
- service: input_boolean.turn_on
entity_id: input_boolean.locklocked
- service: input_boolean.turn_off
entity_id: input_boolean.lockdoublelock
- service: input_boolean.turn_off
entity_id: input_boolean.lockunlock
- alias: 'lockdoublelock' #反锁了
trigger:
platform: numeric_state
entity_id: sensor.rgb
# At least one of the following required
above: 249
below: 251
action: #行动
- service: input_boolean.turn_off
entity_id: input_boolean.lockopen
- service: input_boolean.turn_off
entity_id: input_boolean.locklocked
- service: input_boolean.turn_on
entity_id: input_boolean.lockdoublelock
- service: input_boolean.turn_off
entity_id: input_boolean.lockunlock
- alias: 'lockunlock' #门没有锁
trigger:
platform: numeric_state
entity_id: sensor.rgb
# At least one of the following required
above: 241
below: 243
action: #行动
- service: input_boolean.turn_off
entity_id: input_boolean.lockopen
- service: input_boolean.turn_off
entity_id: input_boolean.locklocked
- service: input_boolean.turn_off
entity_id: input_boolean.lockdoublelock
- service: input_boolean.turn_on
entity_id: input_boolean.lockunlock
|