Value_template problem

I’m reading temperature from a sensor connected to nodeMCU with tasmota
This is the line I use
value_template: “{{ value_json[‘DHT11’].Temperature }}”
I get “22.1”

But, when I try to use the sensor for a thermostat I get this error?

Unable to update from sensor: could not convert string to float: ‘“22.1”’
components/generic_thermostat/climate.py

I guess the problem are the " " but I don’t know how to fix it

Can you help?

Thank you

Try this:

value_template: "{{ value_json['DHT11'].Temperature | float }}"

thank you, but it does not work

Where can I find more info about the rules for value_template?
What kind of language is it?

Thank you

The template code is jinja2. Start reading here.

“Does not work” - does not help us identify your problem. You need to post your code and the relevant entry/error in the HA logs for anyone to be able to determine what your problem is.

Hint - try developing your templates in the template editor before committing them to your code.

image

1 Like

It’s jinja.

There’s a command to remove matched characters but I cant remember it.

There’s a command to remove matched characters

I think the replace filter is what you are thinking of. Replace the unwanted character with ‘’.

http://jinja.pocoo.org/docs/2.10/templates/#replace

As mentioned, just remove the double-quote characters:

value_template: "{{ value_json.DHT11.Temperature.replace('\"','') }}"
1 Like

Thank you using | replace I could solve it