Extremely new to writing my own stuff in HA… I have been trying to learn how the heck these templates work, but I admit i’m at a loss. There are two ways to make them it seems, a new way, and a old way, and I cant even figure out which way is the new way…
What I have now are two methods I have figured:
Method 1-
in configuration.yaml add a line
What docs did you consult, or did you maybe use ChatGPT? There’s a lot wrong here.
The first problem is how your configuration is broken up. Start simple. Just put everything in your configuration.yaml for starters. You have the template: key twice. It should only be defined once. YAML and Jinja (this is the templating part) are two different things. Your problems seem much less about templates, but more about YAML. Google for Thomas Loven’s YAML guide.
Secondly, your indentation of energy_total is off, and it should be a list item (which is denoted by a -).
Thirdly, what is the entity_id: key doing there? Either you want to define a trigger-based template sensor, in which case you’re missing a trigger: key (and a platform: state, which is the only one that will use entity_id:), or just omit it, as the template sensor will listen to all entities referenced. Going with that, value_template: is invalid and should be state:, if you’re not using the legacy template sensor format.
Lastly, carefully read about the usage of state_class. If your source sensors reset at some point, you should be using total_increasing.
And when you actually have a template issue, test it in the template editor first. That part seems fine though.
So, in summary, there’s a lot going on here and it seems like you dove in big bang. Start small. Start simple.
Created a Helper (Settings → Devices & Services → Helpers → Create Helper → Combine the state of several Sensors) to calculate the the sum of power utilization in Watts.