|
楼主 |
发表于 2024-2-25 15:57:54
|
显示全部楼层
写个package下 的yaml,内容类似这样:
binary_sensor:
- platform: template
sensors:
car_windows:
friendly_name: Car Windows
value_template: >-
{% if is_state('binary_sensor.zhe_a_windows_closed', 'off')%}
on
{% else %}
off
{% endif %}
icon_template: >
mdi:car-door
car_lock:
friendly_name: Car Lock
value_template: >-
{% if is_state('sensor.zhe_a_lock', '0') %}
on
{% elif is_state('sensor.zhe_a4y98d_lock', '1') %}
off
{% elif is_state('sensor.zhe_a4y98d_lock', '2') %}
off
{% else %}
on
{% endif %}
icon_template: >
{% if is_state('sensor.zhe_a_lock', '0') %}
mdi:lock-open-variant-outline
{% elif is_state('sensor.zhe_a_lock', '3') %}
mdi:lock-open-variant-outline
{% else %}
mdi:lock-outline
{% endif %}
car_lock_front_right:
friendly_name: Lock Front Right
value_template: >-
{% if is_state_attr('sensor.zhe_a_lock', 'doorlockstatusfrontright', false)%}
off
{% else %}
on
{% endif %}
icon_template: >
{% if is_state_attr('sensor.zhe_a_lock', 'doorlockstatusfrontright', false)%}
mdi:lock-outline
{% else %}
mdi:lock-open-variant-outline
{% endif %}
car_lock_front_left:
friendly_name: Lock Front Left
value_template: >-
{% if is_state_attr('sensor.zhe_a_lock', 'doorlockstatusfrontleft', false)%}
off
{% else %}
on
{% endif %}
icon_template: >
{% if is_state_attr('sensor.zhe_a_lock', 'doorlockstatusfrontleft', false)%}
mdi:lock-outline
{% else %}
mdi:lock-open-variant-outline
{% endif %}
car_lock_rear_right:
friendly_name: Lock Rear Right
value_template: >-
{% if is_state_attr('sensor.zhe_a_lock', 'doorlockstatusrearright', false)%}
off
{% else %}
on
{% endif %}
icon_template: >
{% if is_state_attr('sensor.zhe_a_lock', 'doorlockstatusrearright', false)%}
mdi:lock-outline
{% else %}
mdi:lock-open-variant-outline
{% endif %} |
|