#Jinja template

1 messages · Page 1 of 1 (latest)

dreamy lance
#

I'm sure this is simple but I can't work it out. I'm working with a Modbus RTU device. I have created a mqtt sensor and the Payload (Values) is [56]. 56 is the value I want but I don't want the square brackets. How do I filter out the square brackets?
value_template: "{{ value_json['ModbusReceived'].Values }}"

hushed lance
#

The square brackets indicate it's a list, with in this case only one item

#

"{{ value_json['ModbusReceived'].Values | first }}"

#

That will return the first item from the list, so 56 in this case