Need help to trunk sensor value

Hi,

I try to integrate the value the energie consumed of the house with a téléinfo module.

I create a rest sensor, who give me in json, 2 value:
HCHC
HCHP

For exemple, the result of the value HCHC is 50131222, but i need to only keep the 5 first digit (or a least trunk the 3 last digits) (50131).

Do someone could help me to this?

Thanks

if the result isn’t string then you need to convert it to a string then extract the value:

{% s = value_json|string %}
{{ s[:5] }}

or if it’s already a string (which is likely) then you can use this to get the first 5 digits:

{{ value_json[:5]}}

I hope that’s what you wanted.