cannot get this last if to work!
{% if states(‘entry.temperature’) > tempr %}
uid: wzeit8grad always unavailabe! tried a lot of variants, but not the right one until now. can someone help me?
code in template.yaml file:
- trigger:
- platform: time
at: “10:30:00”
action: - variables:
w: weather.forecast_home - service: weather.get_forecasts
target:
entity_id: ‘{{ w }}’
data:
type: daily
response_variable: d
sensor: - name: ‘WetterMaxTemp’
unique_id: ‘wmaxtemp’
unit_of_measurement: ‘°C’
device_class: temperature
state: “{{ d[w].forecast[0].temperature }}”
- platform: time
- trigger:
- platform: time
at: “10:30:00”
action: - variables:
w: weather.forecast_home - service: weather.get_forecasts
data:
type: hourly
target:
entity_id: ‘{{ w }}’
response_variable: h
sensor: - name: “WetterMaxZeit”
unique_id: wmaxzeit
state: >
{% if h[w] and h[w].forecast %}
{% set max_temp = h[w].forecast | map(attribute=‘temperature’) | max %}
{% for entry in h[w].forecast %}
{% if entry.temperature == max_temp %}
{{ as_timestamp(entry.datetime) | timestamp_custom(‘%H:%M’) }}
{% endif %}
{% endfor %}
{% else %}
“Keine Daten”
{% endif %} - name: “WetterZeit8Grad”
unique_id: wzeit8grad
state: >
{% if h[w] and h[w].forecast %}
{% set tempr = 8 | float %}
{% for entry in h[w].forecast %}
{% if states(‘entry.temperature’) > tempr %}
{{ as_timestamp(entry.datetime) | timestamp_custom(‘%H:%M’) }}
{% endif %}
{% endfor %}
{% else %}
“Keine Daten”
{% endif %}
- platform: time