WANTED! Value Template Generator / Calculator tool/website

Just a simple webpage where you paste in what you are starting with. Various returned entities data etc. Could be nearly anything HA related I imagine.
The before.

Have a space just under that for the result you would like to achieve. Type that in.

Hit a button.
It spits out an easy and correctly formatted copy and pasteable HA value template ready to use. Wam Bam Man. Easy Peasy.

Wouldn’t that be cool?
I think so.

Well, sure, it’d be cool, but what do you imagine would do the work?

If this were easily achievable, why wouldn’t HA just do the same kind of interpretation automatically and transparently by itself.

Post an example of something you would start with.

Could be nearly anything.
Let’s start here…
an easy one

volt=1.3375V

Result wanted…

1.3

Hit Button…
Presto Chango. Results

The template that extracts 1.3 out of that string is this:

Is that an example of what you want the Template Generator to do? Because if it is, slicing a sub-string out of a string is so trivial that the argument might be that a Template Generator isn’t even needed.

So what would be a more complex example that the Template Generator would need to solve?

That is correct.

String slicing is trivial so there’s little incentive for anyone to take the time to build a dedicated interactive tool for it.

While you’re waiting for someone to implement this FR (might be never), you may wish to review these two posts. They provide simple examples and links to detailed, online tutorials. Armed with this knowledge, you can then use the Template Editor to experiment with slicing.

If what you have in mind is more complicated than merely plucking a simple sub-string out of a string, the ultimate tool is regex (regular expression). Regex is powerful but its notation isn’t for the faint of heart. There are existing online tools to experiment with regex and I often use this one https://regex101.com/ but there are others (like this one https://regexr.com/).

“There are existing online tools to experiment with regex and I often use this one https://regex101.com/ but there are others (like this one https://regexr.com/).”

Exactly my point. And that’s my wish.
Just looking for a/tool(s) to help create easy quick painless HA templates and such in seconds. Even minutes. Not hours or days.

Like I said, the notation for string slicing is so trivial to learn and use that it’s unlikely anyone will take the time to build a dedicated tool for it. To be clear, it’s not even “building a template” but merely using python’s native string-slicing capabilities.

In contrast, regex is vastly more complicated. Composing a proper regex pattern can be far more challenging than slicing notation, which is merely [start:stop], and that’s why there are numerous books on the subject and online regex tools.

Anyway, don’t forget to vote for your own FR.

Your request seems pretty impossible. Let’s take even your simple example for a second

Taras presented one template that does that:

{{ 'volt=1.3375V'[5:8] }}

But is that correct? Maybe? But what if you actually wanted to round to the nearest 10th of a volt, that’s this one:

Or what if you had a 950 amp outlet and wanted that result converted to kilowatts and then rounded to the nearest tenth?

Ok last one is silly but the point is I have no idea how you want to get from point A to point B. There are literally infinite ways to do so. And they aren’t all equivalent since in all likelihood you aren’t actually dealing with a static string, volt=1.3375V is going to be changing based on the reading from some device. And while all 3 of these templates give the same answer now, they don’t when the reading is volt=1.2750V.

The only way to know which one is the right template is for you as the author to say so. Which means you have to actually know what the template is doing. I’m sorry you find it tedious but there’s really not a shortcut to learning templates here. It’s really only one of the following options:

  1. Learn templates
  2. Avoid them like the plague and try to stick within the options integrations provide and other non-template based utility integrations
  3. Ask in here or discord for every template you need and wait for a response.
1 Like

Especially when you add the entities states/attributes/whatever into this mix.

then you would need some sort of advanced speech parser to try to figure out…

:man_shrugging:

This FR is literally impossible.

my vote is for #1

just put in the work to learn them.

and if you get stuck you can always fall back to a modified option 3 - “ask on here to help you figure out what you are doing wrong”.