Scraper value_template Trouble

Hey all,

Relatively new to HA, been running HAOS on Raspberry Pi for about a month.

I’ve successfully set up a a webscrapper to retrieve some date from a website, but the front end display of that data isn’t very pretty, see pic below:
Scraper Card

So, I figured the easiest option is to use a value_template to manipulate the string. I came up with the following and checked it in the template option in dev tools:

{% set txt = states('sensor.bin_info') %} {{ txt | regex_replace(find='\\s{2,}',replace='\n', ignorecase=False )}}

Looks good here, but when I use this in the scraper as a value_template the sensor changes from providing the expected day/date and it just returns ‘unknown’:

Where am I going wrong here?

Thanks in advance!

In the value_template you can just refer to the extracted text using the value variable. Your code is a circular reference which can’t work.

  value_template: "{{ value | regex_replace(find='\\s{2,}',replace='\n', ignorecase=False )}}"

Thanks for the quick response!

So using this stops it from returning unknown, but it still doesn’t provide me with the formatting that I see when I use the same code in the template tool.

I’ve also confirmed that this isn’t just a card formatting issue by checking the value of the sensor itself in the state tool.

Maybe the card ignores the newline character? Have tou tried using a HTML break instead? <br/>

I have tried <br/> as well, same result :frowning:

Well, that’s unfortunate. In this case, you might need to look into other cards where you have more control over the layout, like for example the Markdown card.

Spot on - I was trying to avoid manipulating it in the front end, would rather have had the data right at the source but I’ll take it! Thanks