Hello,
I’m trying to split out (strip?) and convert scraped network data (bits), presented as a string, into an integer.
Config:
- platform: scrape
resource: http://<redacted>
name: data out
select: 'p:nth-of-type(3)'
Before the value template is applied I receive this string:
In: 8,186,964,137↵Out: 154,453,055↵Total: 8,341,417,192↵
After applying the template
value_template: {{states.sensor.jwandata.state.split(’:’ or ‘\n’ or ’ ')[1] |replace(“Out”, “”) }}
and I worked at that for a while ) I am closer to just having the 8,186,964,137 string but I sense there is a better way to extract the number and turn it into an integer. I’ve tried to add |int but it does not work in the template testing page in HA. I also wonder if white spaces are hidden in there?
Thoughts? Appreciate any suggestions.