Thx you, but it don’t work, in the log file, i have this error ;
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1243, in regex_findall_index
return re.findall(find, value, flags)[index]
IndexError: list index out of range
I don’t have those cameras to test live. I just copied your supplied results from above into the template editor and tested there. And everything worked as expected for me.
The first one failed because it used the wrong pattern. This pattern \d is used for matching numbers (not letters).
This pattern .+ matches anything. The reason why it works in finity’s example is because pattern-matching stops at the first newline so md1=(.+) will only match the first line and return off.
However, I suspect your sensor’s state value contains no newlines (all the data is on one line) so the same pattern will match something very different (the word offand all the characters after it).
A problem I encountered with regex_findall_index is that if it fails to find a match it returns the error you have seen (list index out of range). I feel it should simply return an empty string and not abort with an error.