To clarify what is happening, first some facts: the state of any entity is always a string. An attribute of an entity can be any type. A jinja template always returns a string.
Now where it gets complicated: if you put a template in the template tester, or if you use a template to specify an attribute, then HA will try to convert the string to a number or a compound type if it can.
So from what is shown above, the template editor is saying something is a list, but from list[0] being the character ‘(’ you can tell that the template editor saw samething in a string that it could convert to a list. To illustrate, put this in the template tester. It is clearly a template returning a string (that looks like a data type known as a tuple, which is very similar to list with 2 elements):
{{ "(12, 34)" }}
The output in the right panel states this is a list, which is what HA converted the string to:
[
12,
34
]
Now this, which is the first element of the same string inside the template:
{{ "(12, 34)"[0] }}
Shows:
(
While what you all were expecting to see:
{{ [12, 34][0] }}
Shows:
12
Which is the same result that you would get from:
{{ (12, 34)[0] }}
Unfortunately, it isn’t so straightforward that you can convert the string to the tuple easily yourself:
{{ "(12, 34)" | list }}
Will get you a list of characters:
[
"(",
"1",
"2",
",",
" ",
"3",
"4",
")"
]
Your best option (as far as I can tell) is to remove the braces, split the result using a comma and convert the parts to a number or use a regular expression.
PS. Put only one of those templates in the tester at the time. Otherwise it is a string with multiple lines that it may not be able to convert to anything else.