How to display template sensor attributes in HA home page?

Still cannot get this to work. I am not sure what the secret is here…

sensor:
  - platform: template
    sensors:
     inside_humidity:
       name: "Carrier Inside Humidity"
       unit_of_measurement: "%"
       state: "{{ state_attr('climate.bedrooms_hallway_1', 'current_humidity') }}"

This is the error I get:

Invalid config for [sensor.template]: [name] is an invalid option for [sensor.template]. Check: sensor.template->sensors->inside_humidity->name. (See ?, line ?).

You are attempting to create a legacy Template Sensor but with the options of a modern Template Sensor. Pick one style or the other but don’t mix the two together like you have done.

This is legacy style:

sensor:
  - platform: template
    sensors:
      inside_humidity:
        friendly_name: "Carrier Inside Humidity"
        unit_of_measurement: "%"
        value_template: "{{ state_attr('climate.bedrooms_hallway_1', 'current_humidity') }}"

This is modern style:

template:
  - sensor:
      - name: Inside Humidity
        unit_of_measurement: "%"
        state: "{{ state_attr('climate.bedrooms_hallway_1', 'current_humidity') }}"
7 Likes

perfect. working now.