Convert ESPhome text sensor to int or float

Ok I have exhausted my meagre Google skills and have yet to find an answer that works.

I want to perform calculations in ESPHome for a Home Assistant Text Sensor.

To do this I need to convert it to int.

Most of the lambda examples I have seen appear to be from C++ coders and don’t work, generating various compile errors.

Can anyone provide an example of converting a string to int (or float) in ESPHome?

Solved in another post:

2 Likes