Template binary sensor fails?

Hi,

made this config, it fails to restart?

in my binary_sensors.yaml

template:
  - binary_sensor:
      - name: tapwater
        value_template: >
          {{states('binary_sensor.boiler_tapwater_active')}}
        icon: >
          {% if is_state("binary_sensor.boiler_tapwater_active", "off") %}
             mdi:water-pump-off
          {% else %}
            mdi:water-pump
          {% endif %}
The system cannot restart because the configuration is not valid: Invalid config for [binary_sensor]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 132).
The system cannot restart because the configuration is not valid: Invalid config for [binary_sensor.template]: [binary_sensor] is an invalid option for [binary_sensor.template]. Check: binary_sensor.template->binary_sensor. (See ?, line ?).
The system cannot restart because the configuration is not valid: Invalid config for [sensor.template]: [binary_sensor] is an invalid option for [sensor.template]. Check: sensor.template->binary_sensor. (See ?, line ?).
The system cannot restart because the configuration is not valid: Invalid config for [binary_sensor]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 131). 

in my configuration.yaml

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
binary_sensor: !include binary_sensors.yaml
sensor: !include sensors.yaml

template: is an integration, not a (binary) sensor platform. So it goes in your configuration.yaml file.

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
binary_sensor: !include binary_sensors.yaml
sensor: !include sensors.yaml
template:
  - binary_sensor:
      - name: tapwater
        value_template: >
          {{states('binary_sensor.boiler_tapwater_active')}}
        icon: >
          {% if is_state("binary_sensor.boiler_tapwater_active", "off") %}
             mdi:water-pump-off
          {% else %}
            mdi:water-pump
          {% endif %}

did place it in configuration.yaml, now I have this

  
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml
template:
  - binary_sensor:
      - name: tapwater
        value_template: >
          {{states('binary_sensor.boiler_tapwater_active')}}
        icon: >
          {% if is_state("binary_sensor.boiler_tapwater_active", "off") %}
             mdi:water-pump-off
          {% else %}
            mdi:water-pump
          {% endif %}

Invalid config for [template]: [value_template] is an invalid option for [template]. Check: template->binary_sensor->0->value_template. (See /config/configuration.yaml, line 133)

line 133 is : template

value_template: >

Should be

state: >

See https://www.home-assistant.io/integrations/template/#configuration-variables

Out of curiosity, why have you created a Template Binary Sensor that reports the same information as one of your existing binary sensors (binary_sensor.boiler_tapwater_active)?

Was it just to display a preferred icon?

@tom_l

No error anymore, and is working.thnx

@123 , yes it’s jut for the preferred icon

Consider voting for this then. It would be much easier:

https://community.home-assistant.io/t/custom-device-classes/368238

1 Like

I voted ofcourse.

Is something for covers possible with template?

I would like to have that if my covers are

closed value 0: mdi:windows-shutter
open value 100: mdi:window-shutter-open
value between 1-99: mdi:window-shutter-alert

But it can’t be a sensor you want to still have the up/stop and down button

Unfortunately not. Even if you duplicate your cover with a template cover there is no icon template for this.

The closest you can come is to apply one of the available cover device classes using customize to your existing cover.