Unkown value for template sensor of input boolean

I’m trying to create a template sensor showing the current stage of a plant but I can’t seem to get the sensor to show anything else then “unknown” or “unavailable”. What am I doing wrong here? The template editor in the developer tools shows it exactly right. I’ve tried to use the input_boolean directly and using a binary_sensor on the input_boolean but neither work.

binary_sensor:
  - platform: template
    sensors:
      growtent_stage_seedling_on:
        value_template: "{{ states('input_boolean.growtent_stage_seedling_on') }}"
  - platform: template
    sensors:
      growtent_stage_vegitative_on:
        value_template: "{{ states('input_boolean.growtent_stage_vegitative_on') }}"
  - platform: template
    sensors:
      growtent_stage_flowering_on:
        value_template: "{{ states('input_boolean.growtent_stage_flowering_on') }}"
  - platform: template
    sensors:
      growtent_stage_drying_on:
        value_template: "{{ states('input_boolean.growtent_stage_drying_on') }}"

template:
  - sensor:
      - name: 'Large growtent stage'
        unit_of_measurement: "days"
        state: >
          {% if (states('binary_sensor.growtent_stage_seedling_on'))=='on' %}
            seedling
          {% elif (states('binary_sensor.growtent_stage_vegitative_on'))=='on' %}
            vegitative
          {% elif (states('binary_sensor.growtent_stage_flowering_on'))=='on' %}
            flowering
          {% elif (states('binary_sensor.growtent_stage_drying_on'))=='on' %}
            drying
          {% endif %}
      - name: 'Small growtent stage'
        unit_of_measurement: "days"
        state: >
          {% if is_state('input_boolean.small_growtent_stage_seedling_on', 'on') %}
            seedling
          {% elif is_state('input_boolean.small_growtent_stage_vegitative_on', 'on') %}
            vegitative
          {% elif is_state('input_boolean.small_growtent_stage_flowering_on', 'on') %}
            flowering
          {% elif is_state('input_boolean.small_growtent_stage_drying_on', 'on') %}
            drying
          {% endif %}

input_boolean:
  growtent_stage_seedling_on:
    name: Seedling stage on
  growtent_stage_vegitative_on:
    name: Vegitative stage on
  growtent_stage_flowering_on:
    name: Flowering stage on
  growtent_stage_drying_on:
    name: Drying stage on

Remove this line:

unit_of_measurement: "days"

Whenever you employ unit_of_measurement, the sensor’s value must be numeric. However your sensors don’t have numeric values.

1 Like

ah stupid mistake, thanks @123 !

1 Like