After rebooting HA I get the error message because the sensor doesn’t exist yet.
TemplateError('UndefinedError: None has no element 0') while processing template 'Template<template=({{ state_attr('weather.accuweather', 'forecast')[0].temperature }}) renders=4>' for attribute '_attr_available' in entity 'sensor.accuweather_temperatur_vorhersage_morgen'
TemplateError('UndefinedError: None has no element 0') while processing template 'Template<template=({{ state_attr('weather.accuweather', 'forecast')[0].temperature | default(0) }}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.accuweather_temperatur_vorhersage_morgen'
Now I wanted to improve this with the availabilty entry. Unfortunately this did not work. What’s wrong with the code?
template:
sensor:
- name: "AccuWeather Temperatur Vorhersage Morgen"
state: "{{ state_attr('weather.accuweather', 'forecast')[0].temperature | default(0) }}"
availability: "{{ state_attr('weather.accuweather', 'forecast')[0].temperature }}"
icon: "mdi:thermometer"
unit_of_measurement: "°C"
Does somebody has any idea?