Calculation of an entity from the values of other entities and/or constants

This must be THE most asked question in the community: How the heck do I create an entity which is a mathematical function of other entities and/or constants? But the story seems to change … what should be simple seems very hard! Is YAML in or out? Are templates in or out? My latest attempt has been to try to create a helper of the “template” variety. I’m ok with the bizarre templating language, but even when I get something that I can save without errors, it still produces an output which is “unavailable”. I would happily author YAML code, but I can’t even find ANY YAML code in my Raspberry Pi / docker install. It all seems so arcane as to belong in the world of demons and wizards. Any advice? Where’s an up-to-date, simple tutorial for non-experts?

Template entities.

You can make template entities in both the UI and YAML.

No idea what you’re asking here.

Post what you’re trying. You most likely have a syntax error or you’re pasting yaml in there.

All yaml associated with HA will not be inside your docker container, it will reside in a configuration folder that you set up. Search for configuration.yaml on your OS.

Templating is for experts. Sorry, but that’s the short end of it. You’ll need to learn Jinja in order to take advantage of template entities.

Myself and TheFes (mostly thefes) helped Smart Home Junkie make HA templating videos, you should check them out.

Templating might be for experts, but surely simple arithmetic is not (good grief)! Looks like the creators of HA were “too smart by half” in co-opting jinja as the solution for simple arithmetic. What I mean by “are templates in or out” is this: Templates are obviously the only way to do simple arithmetic (so they’re in), but if I try to create one using the Helper tab (Q. What kind of Helper? A. Template) the process leads to a result that doesn’t work, and for very non-obvious reasons. Very useful (not). If I can ever find the YAML (another very obscure and undocumented process) it will be interesting to see if I can fix it in order to get what I need - essentially MeasurementA / MeasurementB / Scale Factor. Simple objective, totally opaque process.

They are not. You can make a sensor group and do simple calculations like sum, average, mean, median, etc.

Again, post what you’re trying.

Do you actually want help or do you want to bitch? If you’re here for the latter, I suggest you move to Reddit, they will gladly join in on the poo-poo party. Otherwise, we can get past your rants and solve the problem at hand.

If my car is a lemon, I bitch about it, then I trade it an and buy another one. There are many, many examples of people asking for help on this topic, with extensive back and forth that seems to get nowhere: That should be a sign from the gods that the bitching has some basis in truth. Never mind, I’ll watch the video first.

This just reinforces that you don’t want help and you want to complain.

You could simply just post the equation you are trying to use.

Complaining here is not going to remove templates.

1 Like

Got it working.

  1. It turns out you have to type in the “primitive” name of an entity in a formula, not the descriptive name that you can copy and paste from a dashboard entity
  2. And of course it helps if you use an entity that actually exists in your system :frowning:
    Now if I could just find that YAML …

Installed File Editor and the Terminal. Both tell the same story - there is no YAML in the config directory for the Helper that I just created. Totally confused.

UI generated entities are not created in yaml. You make yaml template entities or UI template entities. The items created in the UI are stored in JSON files in a hidden folder .storage. It’s not recommended to modify those files unless you have intimate knowledge of HAs backend code.

Ok. Live and learn. Thanks for that.

When I have some problems with a template (e.g. result “unavailable”), I copy/paste the code in the Developer Tools/Template page to debug. Don’t forget to do that…

Post a few links to these “many, many examples”.