Outside Temperature - Add to History

Although the local weather is being acquired and displayed by the Weather Forecast Card, the only variable that seems to be historized is the weather - no temperature, rainfall, etc.

I’ve looked for a how-to to add current outside temperature to the list of entities but came up dry. Does this how-to exist, or if not, how can this be done?


Because only an entity’s state value is recorded in the database, not its attributes.

Create a Template Sensor that extracts the outside temperature from the weather entity. This new sensor’s history will show what you want.

  - sensor:
      - name: "Outside temperature"
        unit_of_measurement: "°C"
        device_class: temperature
        state: "{{ state_attr('weather.your_weather_provider', 'temperature')  }}"
1 Like

Thanks for the prompt reply Taras - as you can tell, I’m still on the steep part of the learning curve ;).

Ok, got the sensor configured in configuration.yaml as follows:


sensor.outside_temperature now appears in the Entities list, but when I tried to activate data history I got this response:

Checked the documentation link, but the Entity is unique in the list - what’s the next step to resolving this issue?

Is this the correct Entity reference I should be using?
Weather Entity | Home Assistant Developer Docs (home-assistant.io)

Just add the unique_id option with a value of your choice to the Template Sensor’s configuration then execute Reload Template Entities.

Ensure the spelling of the attribute’s name is correct. I suspect it’s all lowercase.

Ok, that fixes the ID problem - another step closer!

Now this entity appears on the list like the others, but when selected from the historian pick list of variables, there’s no data on the trend … any ideas?

Go to Developer Tools → States and find sensor.outside_temperature. What is the value shown in the State column? It should be a numeric value.

Click the Information icon next to its name and it will display the sensor’s History graph.

The number of values in the graph depends on how often the value of the outdoor temperature changes.

OK, well, that’s the problem:

Here’s the relevant lines from the current configuration.yaml file:

What am I missing?

, 'temperature')  }}"
1 Like

If you may recall, I mentioned this before: Check the spelling of the Temperature attribute. It’s probably temperature (all lower-case) not Temperature.


1 Like

Yes, thank you both! Taras, yes, you mentioned it yesterday - and I glazed right over it. Doh!
It’s been too long since I coded in a case sensitive environment.
Looking good now - and lessons learned!!!

Many thanks!

1 Like

Also appreciate learning that the variable names listed in the Attributes column of the Developer Tools / States page are not just loose references but the literal / actual variables / tags used by the system!

This topic is about YAML configuration and it’s still necessary to wrap a single-line template in quotes.

Composing a template via the UI is an entirely different subject (and unrelated to this over one year-old discussion).

The Automation Editor in visual mode has supported the entry of a template via the UI (sans quotes) long before it became possible to configure a Template Sensor via the UI.

Therefore it’s misleading to claim quotes are “no longer needed” because they have never been needed for entering a template via the UI.

Is this process still relevant? I’ve been trying to replicate it, putting the code into the config file but I have no idea how the entity/state would be named. Does it take the name value and turn it into something like “sensor.outside_temperature”? Also the configuration.yaml file is quite empty, see the code, that is basically the whole file right now.

# Loads default set of integrations. Do not remove.

# Load frontend themes from the themes folder
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
  - sensor:
      - name: "Outside temperature"
        unit_of_measurement: "°C"
        device_class: temperature
        state: "{{ state_attr('weather.forecast_domov', 'temperature')  }}"


You can also go to the UI > Settings > Devices and services > Helpers

And create a Helper Template Sensor with the following
{{ state_attr('weather.forecast_home', 'temperature') }}