kjetilsn Skrevet 14. desember 2021 Skrevet 14. desember 2021 Hei, Bruker i dag noen enkle men "stygge" templates, og noen gir meg nå feilmelding. Det er nok template syntax som er i endring og som da ikke lenger vil støttes i neste versjon. I tillegg kan nok template skrives på en mer ryddig måte? Noen som har anbefalinger? Feilmelding: Template warning: 'float' got invalid input '<template TemplateState (<state sensor.kwh_kjellerbad_today=1.5; unit_of_measurement=kWh, friendly_name=Kwh Kjellerbad Today @ 2021-12-14T01:44:14.262309+01:00>)>' when rendering template '{%- if not (is_state("sensor.kwh_bad_1etg_today","unknown") or is_state("sensor.kwh_bad_2etg_today","unknown") or is_state("sensor.kwh_kg_today","unknown") or is_state("sensor.kwh_ks_today","unknown") or is_state("sensor.kwh_n_today","unknown") or is_state("sensor.kwh_stue_today","unknown") or is_state("sensor.kwh_a_today","unknown") or is_state("sensor.kwh_drivhus_today","unknown") or is_state("sensor.kwh_s_today","unknown") or is_state("sensor.kwh_masterbedroom_today","unknown") or is_state("sensor.kwh_t_today","unknown") or is_state("sensor.kwh_kjellerbad_today","unknown") or is_state("sensor.kwh_vr_today","unknown") )-%} {{ ((states.sensor.kwh_bad_1etg_today.state | float) + (states.sensor.kwh_bad_2etg_today.state | float) + (states.sensor.kwh_kg_today.state | float) + (states.sensor.kwh_ks_today.state | float) + (states.sensor.kwh_n_today.state | float) + (states.sensor.kwh_stue_today.state | float) + (states.sensor.kwh_a_today.state | float) + (states.sensor.kwh_drivhus_today.state | float) + (states.sensor.kwh_s_today.state | float) + (states.sensor.kwh_masterbedroom_today.state | float) + (states.sensor.kwh_t_today.state | float) + (states.sensor.kwh_kjellerbad_today | float) + (states.sensor.kwh_vr_today.state | float)) |default(0)|round }} {%- endif -%}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2022.1 Template Sensor: total_kwh_heating_today: value_template: '{%- if not (is_state("sensor.kwh_bad_1etg_today","unknown") or is_state("sensor.kwh_bad_2etg_today","unknown") or is_state("sensor.kwh_kg_today","unknown") or is_state("sensor.kwh_ks_today","unknown") or is_state("sensor.kwh_n_today","unknown") or is_state("sensor.kwh_stue_today","unknown") or is_state("sensor.kwh_a_today","unknown") or is_state("sensor.kwh_drivhus_today","unknown") or is_state("sensor.kwh_s_today","unknown") or is_state("sensor.kwh_masterbedroom_today","unknown") or is_state("sensor.kwh_t_today","unknown") or is_state("sensor.kwh_kjellerbad_today","unknown") or is_state("sensor.kwh_vr_today","unknown") )-%} {{ ((states.sensor.kwh_bad_1etg_today.state | float) + (states.sensor.kwh_bad_2etg_today.state | float) + (states.sensor.kwh_kg_today.state | float) + (states.sensor.kwh_ks_today.state | float) + (states.sensor.kwh_n_today.state | float) + (states.sensor.kwh_stue_today.state | float) + (states.sensor.kwh_a_today.state | float) + (states.sensor.kwh_drivhus_today.state | float) + (states.sensor.kwh_s_today.state | float) + (states.sensor.kwh_masterbedroom_today.state | float) + (states.sensor.kwh_t_today.state | float) + (states.sensor.kwh_kjellerbad_today | float) + (states.sensor.kwh_vr_today.state | float)) |default(0)|round }} {%- endif -%}' friendly_name: "Kwh Oppvarming i dag" unit_of_measurement: 'Kwh' Siter
stigvi Skrevet 14. desember 2021 Skrevet 14. desember 2021 Denne, states.sensor.kwh_bad_2etg_today.state, måten å referere til en sensor på er noe du bør endre. Bruk states("sensor.kwh_bad_2etg_today") istedenfor. Avoid using states.sensor.temperature.state, instead use states('sensor.temperature'). It is strongly advised to use the states(), is_state(), state_attr() and is_state_attr() as much as possible, to avoid errors and error message when the entity isn’t ready yet (e.g., during Home Assistant startup). Templating - Home Assistant (home-assistant.io) Alle |float bør endres til |float(0) (eller bruk en mer fornuftig standardverdi enn null hvis mulig) Siter
kjetilsn Skrevet 14. desember 2021 Forfatter Skrevet 14. desember 2021 Takk stigvi, Det er supert, da slipper jeg tydeligvis å bruke første delen av templaten som "sjekker" om state er "unknown" Siter
stigvi Skrevet 14. desember 2021 Skrevet 14. desember 2021 kjetilsn skrev (1 minutt siden): da slipper jeg tydeligvis å bruke første delen av templaten som "sjekker" om state er "unknown" Det slipper du, ja 👍 Siter
Anbefalte innlegg
Bli med i samtalen
Du kan publisere innhold nå og registrere deg senere. Hvis du har en konto, logg inn nå for å poste med kontoen din.