Unfortunately, when I do this (see below), it produces a syntax error complaining about the unexpected escape character ** before the dot character: \.exe
…If I remove the escape character before the dot, regex_findall() will no longer treat the dot as literal. It means something completely different without the escape character.
Could someone please tell me what I’m missing? Also, I’m not sure how to move the availability template to the REST sensor either. My ultimate goal is to make the code a little shorter/more concise.
I’m guessing the issue is because in one case you’re surrounding it in double-quotes, and the other you’re not. So possibly the double-quoted string is seeing the backslash and escaping the ‘.’ before the “value_template” gets to see it.
So try putting it on a separate line like you did for the sensor, ie:
I managed to escape the dot by using the backslash Unicode character: \u005c See below. This syntax is considered acceptable by YAML validators. However, Home Assistant\s REST sensor not handling regex_findall() pattern correctly.
PS: I’ve seen official documentation using: regex_findall(find=‘()’,ignorecase=False) and regex_findall(’ ', False). Is there any reason to do it the long way? I’m not sure if there are any issues to using the shorter way.
If you omit the find and ignorecase argument tags, you must enter the two arguments in the correct order (the regex pattern first, for find, and the boolean value second, for ignorecase). If you include the tags, you can specify the two arguments in whatever order you want (it also allows you omit an argument such as in the situation where a filter accepts three arguments and you only need to specify the values of the first and third one).
The tags also serve to document the arguments (i.e. at a later date you would know that the False means to ignorecase).