Hi,
I tried to parse a battery state from the payload, which is NOT json:
from mosquitto_sub verbose output:
robonect/mower/battery/charge 99 %
Like this:
sensor:
- platform: mqtt
name: "mymower charge"
state_topic: "robonect/mower/battery/charge"
value_template: "{{ value_json | regex_findall_index('\\d+') | int }}"
unit_of_measurement: "%"
But then the entity value is null and the logs say:
WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'value_json' is undefined when rendering '{{ value_json | regex_findall_index('\d+') | int }}'
If I just remove the value_template then the sensor entity shows up with the correct value but as a string and a trailing percent sign.
I tried this in the template editor and it works:
{% set value_json = "99 %" %}
{{ value_json | regex_findall_index('\\d+') | int }}
The documentation does not give any hint about how to access non json payloads.
Or did I miss something?
Thank you!