I would like to be able to extract the 100 (or whatever number is delivered) in a data_template and use it as the value for brightness_pct. I have looked at the JINJA documentation but don’t see any string functions that I believe will let you extract portions. Or at least none that I recognize.
Is this possible? Any examples or pointers are appreciated.
What other formats of payload could there be from this topic? You’ll have to consider all of them that could potentially be published. If this is the only one, you could do something like this:
{%- set value = "ON 100" -%}
{%- set parts = value.split(" ") -%}
key = '{{ parts[0] }}', value = '{{ parts[1] }}'
Output
key = 'ON', value = '100'
Much of the time you can also use the methods on python strings as well.