I’m using the integrated weather forecast:
How would I extract the temperature value to be shown in a entity card?
I’m using the integrated weather forecast:
Lookup your weather integration in Dev Tools/states
and create a template sensor from the attribute.
{{ state_attr('weather.dark_sky', 'temperature') }}
Thanks @VDRainer, but… still have problems.
First a maybe stupid question: What is the “dev-info panel for details”?
Because that’s the message I get with the entry in my sensors.yaml shown below.
The log shows
Invalid config for [sensor.template]: invalid slug weather.in_kolle_ze_hus (try weather_in_kolle_ze_hus) for dictionary value @ data['sensors']. Got OrderedDict([('weather.in_kolle_ze_hus', OrderedDict([('value_template', "{{ state_attr('weather.in_kolle_ze_hus', 'temperature') }")]))]). (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.template/
sensors.yaml:
# Temperatur-Attribut als Extra-Wert
- platform: template
sensors:
weather.in_kolle_ze_hus:
friendly_name: "HA Temperatur Vorhersage"
unit_of_measurement: '°C'
value_template: "{{ state_attr('weather.in_kolle_ze_hus', 'temperature') }}"
When I put weather_in_kolle_ze_hus
instead, the syntax is okay, but I don’t get the values…
The problem is in the fourth line:
# Temperatur-Attribut als Extra-Wert
- platform: template
sensors:
weather.in_kolle_ze_hus:
Remove weather.
from that line and you’ll have sensor.in_kolle_ze_hus
created:
# Temperatur-Attribut als Extra-Wert
- platform: template
sensors:
in_kolle_ze_hus:
Thanks @Tinkerer, @VDRainer. Got it to run
Here my working template to provide the complete solution:
# Temperatur-Attribut als Extra-Wert
- platform: template
sensors:
norwegian_temperature:
friendly_name: "met.no Temperatur Vorhersage"
unit_of_measurement: '°C'
value_template: "{{ state_attr('weather.in_kolle_ze_hus', 'temperature') }}"
My idea is to figure out, which forecast fits best to my measured values.
Hi, thanks for your example, and how to read the condition, like “rainy” in your example? I tried to replace ‘temperature’ with ‘condition’ but I get None. And ‘forecast condition’?
EDIT, sorry it was
value_template: "{{ states('weather.homexxx') }}"
I’m not sure I understand, you posted a question.
VDRainer gave you 85% of what you needed
Tinkerer then came back and corrected your syntax (say another 10%)
Then you say “you” solved it ?
Good way of giving credit where its due and encouraging others to help you in the future
Thanks Mutt for your remark:
If understand correct, you are complaining that I collect credits for things I haven’t solved by my own?
To be honest, beside the fact that this is totally of topic, I don’t care about those medals, but I have pity on people who aspire to it.
My idea was to summarize and complete the x% posts in one single post to make it more comfortable for other users without the need to read the whole thread!
@VDRainer, @Tinkerer: If one of you think it’s better to mark one of your post as solution, please tell me and of cause I will do so.
I don’t care.
Eh, your post has the final solution - which is what others who find this thread will want
I think I know what you whant, shomthing like this
weather-card/143260/5
- platform: template
sensors:
solar_angle:
friendly_name: "Sun angle"
unit_of_measurement: "degrees"
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
sunrise:
value_template: "{{ state_attr('sun.sun', 'next_rising') }}"
- platform: template
sensors:
norwegian_temperature:
friendly_name: "met.no Temperatur Vorhersage"
unit_of_measurement: '°C'
value_template: "{{ state_attr('weather.hjem', 'temperature') }}"
norwegian_weather:
friendly_name: "met.no weather Vorhersage"
value_template: "{{ states('weather.hjem') }}"
Hey,
I’d like to take benefit of this post.
I do not get created the sensor. Am I missing something?
- platform: template
sensors:
casita:
friendly_name: "Temp"
unit_of_measurement: '°C'
value_template: "{{ state_attr('weather.casita', 'temperature') }}"
Cheers&Thanks
In “config.yaml” this must be under “sensor” statement like
sensor:
- platform: template
sensors:
casita:
friendly_name: "Temp"
unit_of_measurement: '°C'
value_template: "{{ state_attr('weather.casita', 'temperature') }}"
…, or if You have “!include sensor.yaml” in the beginning of config.yaml then You need to create, (or if You have one, edit it), with your statement.
here is my example in config.yaml:
sensor:
- platform: time_date
display_options:
- 'time'
- 'date'
- 'date_time'
- 'date_time_utc'
- 'date_time_iso'
- 'time_date'
- 'time_utc'
- 'beat'
- platform: template
sensors:
wetemp:
friendly_name: "temperatura_vani"
unit_of_measurement: '°C'
value_template: "{{ state_attr('weather.dom', 'temperature') }}"
hoping someone can help me with very similar problem. I wish to extract the outside temperature (for the moment, the basic value from weather.home will do) , and record it (forever, give or take) so that I can graph it against heating requirements, etc.
I have a bunch of templates already defined and working with this kind of syntax
sensor:
- platform: template
sensors:
zappi_garage_load_kw:
unit_of_measurement: 'kW'
value_template: "{{ ( states('sensor.myenergi_zappi_15606200_internal_load_ct1') | float / 1000)}}"
friendly_name: "Zappi Garage Load"
(and lots more)
if I add a temperature one using this format like this:
temp_outside:
unit_of_measurement: '°C'
value_template: "{{ state_attr('weather.home','temperature') }}"
I can see its value correctly in History . but I can NOT see it in devtools->statistics, which is what I believe I need to be able to track it long term. Its my understanding that this
state_class: measurement
is required to be added to enable the long term tracking. If I add THAT line, the config for that template section becomes invalid. So then I read that there is a new way to do templates which has to be used to allow this so I have tried that format as well:
(obviously I removed the other one from config)
template:
-sensor:
- name: outside_temperature_internet
friendly_name: "Outside Temperature Internet"
unit_of_measurement: '°C'
state_class: measurement
value_template: "{{ state_attr('weather.home','temperature') }}"
this a) passes config validation b) gives the expected numeric value corresponding to the actual temperature when pasted into devtools->templates editor. BUT when actually in use, gives a state of “unavailable” in devtools->states and no data in History.
this is driving me nuts going round in circles, can anyone help?
thanks
You can do this for the stats.
template:
- sensor:
- name: "Énergie heures chauffage premier"
unit_of_measurement: "kWh"
device_class: energy
state_class: measurement
state: >-
{% set a = state_attr("climate.sinope_thermostat_salon","daily_kwh") | float %}
{% set b = state_attr("climate.sinope_thermostat_cuisine","daily_kwh") | float %}
{% set c = state_attr("climate.sinope_thermostat_salle_deau","daily_kwh") | float %}
{{ (a + b + c) | round(2) }}
And then add the sensor to a stats sensor.
sensor:
- platform: statistics
unique_id: "energie_heures_chauffage_premier"
name: "Statistiques heures chauffage premier"
entity_id: sensor.energie_heures_chauffage_premier
state_characteristic: mean
sampling_size: 20
max_age:
hours: 24
thanks but your method doesn’t fix it for me . the problem seems to me that with the
template:
- sensor:
etc...
method, which you also used, then in my case I get unavailable for the newly created item
my config as of now:
template:
-sensor:
- name: outside_temperature_internet2
friendly_name: "Outside Temperature Internet"
unit_of_measurement: '°C'
device_class: energy
state_class: measurement
state: "{{ state_attr('weather.home','temperature') }}"
this yields the below: state exists but has nothing
with the
sensor:
- platform: template
sensors:
method, I can create a sensor and it has data, but I can’t track it… I don’t understand the difference (other than that I read one is newer)
Don’t forget to set device_class: temperature
to get the right icon automatically
- platform: template
sensors:
norwegian_temperature:
friendly_name: "met.no Temperatur Vorhersage"
unit_of_measurement: '°C'
value_template: "{{ state_attr('weather.in_kolle_ze_hus', 'temperature') }}"
Here are all the forecast details I capture in my own config:
sensor:
- platform: template
sensors:
forecast_current_temperature:
unique_id: forecast_current_temperature
friendly_name: Outside temperature
unit_of_measurement: °C
device_class: temperature
value_template: "{{ state_attr('weather.forecast_home', 'temperature') }}"
forecast_current_temperature_hourly: # testing to see if it gets more freq updates
unique_id: forecast_current_temperature_hourly
friendly_name: Outside temperature (hourly)
unit_of_measurement: °C
device_class: temperature
value_template: "{{ state_attr('weather.forecast_home_hourly', 'temperature') }}"
forecast_current_humidity:
unique_id: forecast_current_humidity
unit_of_measurement: "%"
device_class: humidity
value_template: "{{ state_attr('weather.forecast_home', 'humidity') }}"
forecast_current_pressure:
unique_id: forecast_current_pressure
friendly_name: Outside air pressure
unit_of_measurement: hPa
device_class: pressure
value_template: "{{ state_attr('weather.forecast_home', 'pressure') }}"
forecast_current_wind_speed:
unique_id: forecast_current_wind_speed
friendly_name: Outside wind speed
unit_of_measurement: km/h
device_class: wind_speed
value_template: "{{ state_attr('weather.forecast_home', 'wind_speed') }}"
forecast_current_wind_bearing:
unique_id: forecast_current_wind_bearing
friendly_name: Outside wind bearing
unit_of_measurement: "°"
icon_template: mdi:compass
# device_class: ???
value_template: "{{ state_attr('weather.forecast_home', 'wind_bearing') }}"
How can I read templow?
Hi Hajo,
I am curious in your findings about which forecasts gave you the best prediction?