The other settings are made as supposed:
Unit: W
Device class: power
Class: measurement
The helper works fine.
But if I reboot home assistant I get an error in the logs telling me the state is unknown.
If I did understand the templste documentation correct this shouldnt appear if I use my template code.
(States(‘entity’)) instead of states.entity.state.
So did I do sth wrong?
Or is this an error that cant be avoided?
And is there any advantage creating template sensors in the UI instead of inside the configuration.yaml?
Didnt try it yet.
But stating float(0) means: if sensor value = unknown - the value would be 0?
This should fix the problem.
As the availabilty template would, too.
But availability is only possible in configuration.yaml, i guess?
Is there any advantage from creating template in UI over config.yaml?
Im wondering if its besser to use defaults an UI,
or use availaility (with or without defaults) an define the sensors in the configuration?
However, as you have discovered, it has less functionality compared to configuring a Template entity in YAML.
For your application, I suggest using availability (so you will need to configure the Template Sensor in YAML). If you don’t use availability, and simply rely on using float(0), then the computed sum might be artificially low at startup because one or both sensor values will be zero.
And to avoid a strange computed sum in the avability sensor, would you suggest to use round instead of round(0)?
Or should I use round(0) for the case any inverter loses connection or goes broken?
Btw. a computed sensor value at HA start wouldnt be an issue for me (i think at the moment), because the sensor is used to turn on and off devices regarding to PV excess.
And this sensor updates every 30 seconds.
And one last question (after rading the HA template artice)
Why round(0) returns 0 if convertet input isnt a number?
The round(0) could also be precision?
How to know its default in this case?