Jinja2 value_template help

Hi all,

I’m pretty new to HASS and have been reading about using jinja2 filters in the value_template configuration for the mqtt sensor.

I have an MQTT topic that returns strings like this:
[1465965499,1257,“W”]
[1465965499,2116,“W”]

I need to extract that second number - it’s the realtime electricity consumption from my Flukso monitor. Looking through http://jinja.pocoo.org/docs/dev/templates/#filters I’m struggling to find something I can use. Any assistance would be appreciated.

Thanks,
James

1 Like

When you say “second number”, do you mean the 1257 & 2116 values shown above?

I have the same issue. Yes, we would like to extract the values 1257 & 2116. Thanks in advance for any help.

How about:

{{ yourstring.split(",")[1]|int }}

?

That’s it indeed! Thanks a lot.