I am in the process to move my yaml based templates to UI template helpers.
here’s a binary sensor I have created in yaml:
# Intrusion Alarm Device
- binary_sensor:
- name: "Einbruchsalarm Waschkeller"
unique_id: "intrusion_alarm_waschkeller"
icon: >
{% if states('sensor.rauchwarnmelder_waschkeller_smoke_detector_alarm_status') in ['idle_off', 'secondary_alarm', 'primary_alarm'] %}
mdi:shield
{% elif is_state("sensor.rauchwarnmelder_waschkeller_smoke_detector_alarm_status", "intrusion_alarm") %}
mdi:shield-alert
{% endif %}
device_class: tamper
state: >
{% if states('sensor.rauchwarnmelder_waschkeller_smoke_detector_alarm_status') in ['idle_off', 'secondary_alarm', 'primary_alarm'] %}
off
{% elif is_state('sensor.rauchwarnmelder_waschkeller_smoke_detector_alarm_status', 'intrusion_alarm') %}
on
{% endif %}
availability: >
{{ states('sensor.rauchwarnmelder_waschkeller_smoke_detector_alarm_status') not in ['unknown', 'unavailable', 'None'] }}
attributes:
device_state: >
{% if is_state('sensor.rauchwarnmelder_waschkeller_smoke_detector_alarm_status', 'idle_off') %}
Untätig
{% elif is_state('sensor.rauchwarnmelder_waschkeller_smoke_detector_alarm_status', 'intrusion_alarm') %}
Einbruch erkannt!
{% endif %}
As you can see, I am using state based icons - and also some attributes.
Unfortunately, the helper does only support pre-defined icons, and also, it is not possible to add attributes to the sensor.
I would really appreciate if this could be included for the helper