Sensor from template not working

Hello!
I’m trying to make some automations based on the outside temperature. To do this I have created a sensor from template that is supposed to pull the temperature attribute from my weather card entity.

sensor:
  # Temperature from entity
  - platform: template
    sensors:
      norwegian_temperature:
        friendly_name: "norwegian_temperature"
        unit_of_measurement: '°C'
        value_template: "{{ states_attr('weather.home', 'temperature') }}"

This worked like a charm (thanks to your help!) and I have found a new entity on my list:

However, this new entity does not seem to be working. It never updates and is listed at unavailable.

I would be very grateful for any ideas that could help to make it work.

Best wishes!

The function’s name is:

state_attr()

not:

states_attr()

Reference: Templating Documentation.

Change it to this:

        value_template: "{{ state_attr('weather.home', 'temperature') }}"
1 Like

Thank you very much! This has fixed everything! I now feel a bit stupid cause of the typo :frowning:
Best wishes!

1 Like