Hi there,
I have a question regarding my sensor template.
I read the electrical energy consumption of the house with an Hichi IR flashed with tasmota at the smart meter.
To get reasonable values I have this template set up:
template:
- sensor:
- name: "Strom_Zahlerstand"
unique_id: Stromkasten_gesamt_Zaehlerstand
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
state: >
{% if states('sensor.tasmota_sm_1_8_0') == 'unavailable' or states('sensor.tasmota_sm_1_8_0') < '1' %}
{{ states('sensor.strom_zahlerstand') }}
{% else %}
{{ (states('sensor.tasmota_sm_1_8_0') | float / 1000) | round(2) }}
{% endif %}
But I get the following error in the logs:
Logger: homeassistant.helpers.template_entity
Source: helpers/template_entity.py:344
First occurred: 11:00:52 (1 occurrences)
Last logged: 11:00:52
TemplateError('ValueError: Template error: float got invalid input 'unknown' when rendering template '{% if states('sensor.tasmota_sm_1_8_0') == 'unavailable' or states('sensor.tasmota_sm_1_8_0') < '1' %} {{ states('sensor.strom_zahlerstand') }} {% else %} {{ (states('sensor.tasmota_sm_1_8_0') | float / 1000) | round(2) }} {% endif %}' but no default was specified') while processing template 'Template<template=({% if states('sensor.tasmota_sm_1_8_0') == 'unavailable' or states('sensor.tasmota_sm_1_8_0') < '1' %} {{ states('sensor.strom_zahlerstand') }} {% else %} {{ (states('sensor.tasmota_sm_1_8_0') | float / 1000) | round(2) }} {% endif %}) renders=8>' for attribute '_attr_native_value' in entity 'sensor.strom_zahlerstand'
Unfortunately I don’t get what it’s actually complaining about, or how I can fix it.
Is unknown the state of sensor.tasmota_sm_1_8_0
so that it can’t be converted to a float?
I am very happy for any help!
Samuel