Need a bit of help with scraping value on URL of camera

Hi, first of all, HA is great! I need some help with Scrape (I am a noob on this Scrape subject), maybe someone can put me in the right direction.

I have a camera which has a built-in thermometer. I can get this temperature value by accessing the follow URL: http://<IP_camera>/?action=command&command=value_temperature

It gives me the following output:

value_temperature: 24.1

I would like to scrap only this value with HA built-in Scrape and use this value as input for a sensor.

The HTML code of this website is as follows:

<html>
	<head></head>
	<body> == $0
		<pre stype="word-wrap: break-word; white-space: pre-wrap;">value_temperature: 24.1</pre>
	</body>
</html>

How can I scrape only this value?

I added the following to configuration.yaml:

   - platform: scrape
     resource: http://<IP_camera>/?action=command&command=value_temperature
     name: Temperature
     select: ".value"
     value_template:

I am not sure if the ‘select’ that I am using is correct and don’t know what to put in ‘value_template’.

Any help would be appriciated.
Thanks!

1 Like

If you use select: "pre" then I believe you will get:

value_temperature: 24.1

I don’t know if you can use a better template with scrape tool in this case.
But you could probably use another template sensor which splits the value on space.

Edit: I believe value_template can be used.

value_template: '{{ value.split(" ")[1] }}'

2 Likes

Thanks so much Hellis81, I used the template in combination with the Rest sensor and that works out just perfectly!

Hello. I have a very similar task. But a slightly different page code

<html data-kantu="1">
<head></head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;">value_temperature: 24.4</pre>
<span style="margin: 0px auto; border: 2px dotted rgb(0, 0, 0); position: absolute; z-index: 2147483647; visibility: hidden; left: 164px; width: 0px; top: 87px; height: 0px;"></span>
<span style="z-index: 2147483647; position: absolute; visibility: hidden; left: 149px; width: 50px; top: 72px; height: 20px; font-size: 10px; color: black;"></span>
</body>
</html>

And such a sensor does not display data for me. The state is always unknown

 - platform: scrape
     resource: http://<IP Camera>/?action=command&command=value_temperature
     name: Temperature
     select: ".value"
     value_template: '{{ value.split(" ")[1] }}'

I don’t understand why you changed the select. There is no HTML tag named value.
If it’s "value_temperature: 24.4" you want then it’s still the PRE tag just like the OP’s HTML

   - platform: scrape
     resource: http://<IP Camera>/?action=command&command=value_temperature
     name: Apartment Children Temperature
     select: "pre"
     value_template: '{{ value.split(" ")[1] }}'   

Hello. With this config also unknown