Need to be careful using “dot notation” with keys that also have special meanings in Python or Jinja. Probably safest with bracket notation: this should work:
Exactly. In this instance, I think you’d get away with it, but pop this in the template editor to see the issue:
{% set a = {'duck':'quack','value':'careful','keys':'ouch','0':'nodots'} %}
{{ a.keys }}
{{ a['keys'] }}
{{ a.value }}
{{ a['0'] }}
Because keys() is a function on a dictionary, you can’t use dot notation to refer to a member called keys. Same with e.g. a.0 which is interpreted as an index, not valid on a dictionary. It’s always safer to use bracket notation.
here is sensor attribute. i need to take a value of description attribute. But it includes word “value” inside. I need it without this word and without any other symbols
Put that and the ChatGPT one in the template editor and see if there’s any difference.
The ChatGPT solution you show simply adds a few extra filters to remove newlines, double quote characters at the very beginning or end of the string, and the string "Today: ". You didn’t ask for that processing to be done, and it looks to me like you’re taking its answer without understanding what it’s doing.