template:
- trigger:
- platform: state
entity_id: sensor.c2xxx_action
to: door
binary_sensor:
- name: xiaomidoor_door_status
unique_id: xiaomidoor_door_status
state: "{{ is_state_attr('sensor.c2xxx_action', 'action_id',0) or is_state_attr('sensor.c2xxx_action', 'action_id',2) }}"
- trigger:
- platform: state
entity_id: sensor.c2xxx_action
to: lock
sensor:
- name: xiaomidoor_lock_status
unique_id: xiaomidoor_lock_status
state: >
{% if is_state_attr('sensor.c2xxx_action','action_id',0) %}
门外开锁
{% elif is_state_attr('sensor.c2xxx_action','action_id',1) %}
上提把手上锁
{% elif is_state_attr('sensor.c2xxx_action','action_id',2) %}
反锁
{% elif is_state_attr('sensor.c2xxx_action','action_id',3) %}
解除锁
{% elif is_state_attr('sensor.c2xxx_action','action_id',4) %}
门内开锁
{% elif is_state_attr('sensor.c2xxx_action','action_id',5) %}
门内上锁
{% elif is_state_attr('sensor.c2xxx_action','action_id',6) %}
开启童锁
{% elif is_state_attr('sensor.c2xxx_action','action_id',7) %}
关闭童锁
{% else %}
其他
{% endif %}
- trigger:
- platform: template
value_template: "{% if is_state_attr('sensor.c2xxx_action','action_id',0) and is_state_attr('sensor.c2xxx_action', 'action', 'lock') %}true{% endif %}"
sensor:
- name: xiaomidoor_lock_method
unique_id: xiaomidoor_lock_method
state: >
{% if is_state_attr('sensor.c2xxx_action','method_id',0) %}
蓝牙
{% elif is_state_attr('sensor.c2xxx_action','method_id',1) %}
密码
{% elif is_state_attr('sensor.c2xxx_action','method_id',2) %}
指纹
{% elif is_state_attr('sensor.c2xxx_action','method_id',3) %}
钥匙
{% elif is_state_attr('sensor.c2xxx_action','method_id',4) %}
转盘
{% elif is_state_attr('sensor.c2cxxx_action','method_id',5) %}
NFC
{% elif is_state_attr('sensor.c2xxx_action','method_id',6) %}
一次性密码
{% elif is_state_attr('sensor.c2xxx_action','method_id',7) %}
双重验证
{% elif is_state_attr('sensor.c2xxx_action','method_id',10) %}
人工
{% elif is_state_attr('sensor.c2xxx_action','method_id',11) %}
自动
{% else %}
其他
{% endif %}
- name: xiaomidoor_lock_user
unique_id: xiaomidoor_lock_user
state: >
{% if is_state_attr('sensor.c2xxxx_action','key_id',0) %}
管理员
{% elif is_state_attr('sensor.c2cxxx_action','key_id',1) %}
我的密码
{% elif is_state_attr('sensor.c2cxxx_action','key_id',2) %}
我的指纹
{% elif is_state_attr('sensor.c2cxxx_action','key_id',3) %}
老婆的密码
{% elif is_state_attr('sensor.c2cxxx_action','key_id',4) %}
老婆的指纹
{% else %}
其他
{% endif %}
复制代码