Hey,
I read this thread while trying to figure out a solution to my problem.
I want to do the following:
Interpolate the electric consumption for a year based on former consumption.
by
- setting the start date - in this case when the electricity contract started
- having a statistic sensor to sum up the consumption since then (see code)
- having a template sensor to divide by the days since then and multiply by 365 (to be done)
I do get errors in the configuration.yaml, I assume I have the concept right, if I put in a number, it works. But I do not know how to fix it, tried several things
- platform: statistics
unique_id: strombezug_seit_startdatum
entity_id: sensor.jahresverbrauch_strom
name: "Strombezug seit Startdatum"
state_characteristic: change
max_age:
days: '{{ ( as_timestamp(now()) - as_timestamp(states(input_datetime.datum_start_stromverbrauchsrechnung)) ) / 86400 }}'
Any ideas? Here I do get an error that it expects a float.
“days: !!float {{…”
does not work. Removing the singe quotes doesn’t either. Using double quotes neither. Piping to float neither.