Sensor read value on http page local server

Hello !
I would like to make a two sensor that will read the temperature and humidity from local http server. The value is enclosed between two square brackets.
If i enter address
192.168.1.43
show this page with value :

Outside temperature: [12.70] ° C
Outside humidity: [100.00] %

thanks for the advice and help

scrape ?

Can you do a View Source on the web page, and post the HTML here, correctly formatted using the </> button?

<!DOCTYPE HTML>
<html>
<center>
<H1>
Data of SHT31 - Wifi NODEMCU 1.0 
<br />
192.168.1.43
<br />
<font color=black size=7>Outside temperature: [11.00] &#176;
C
<br />
<font color=black size=7>outside humadity: [100.00] %

Here is source code of html

Yuk: that’s a long way from being nice HTML. Scrape sensor might work but the code is so fundamentally broken all bets are off:

sensor:
  - platform: scrape
    name: SHT31 Temperature
    resource: http://192.168.1.43
    select: "font"
    index: 0
    value_template: "{{ value.split('[')[1].split(']')[0] }}"
    unit_of_measurement: '°C'
  - platform: scrape
    name: SHT31 Humidity
    resource: http://192.168.1.43
    select: "font"
    index: 1
    value_template: "{{ value.split('[')[1].split(']')[0] }}"
    unit_of_measurement: '%'

If it’s your code producing that HTML and it’s not needed for any other use, I’d suggest returning nice clean JSON instead: something like:

{"temperature": "12.7", "humidity": "100"}
2 Likes

Thankyou!!

2 months work super, now after upgrade i get messege

Configuring Scrape using YAML has been moved to integration key.

Can someone help me how convert scrape to this for me new, integration key ??

- platform: scrape
    name: SHT31 Temperature
    resource: http://192.168.5.42
    select: "font"
    index: 0
    value_template: "{{ value.split('[')[1].split(']')[0] }}"
    unit_of_measurement: '°C'
    
  - platform: scrape
    name: SHT31 Humidity
    resource: http://192.168.5.42
    select: "font"
    index: 1
    value_template: "{{ value.split('[')[1].split(']')[0] }}"
    unit_of_measurement: '%'

go to devices and services under settings, select integrations and add ‘scrape’ (if not already there)

but it says that scrape will be removed in the next versions…Screenshot 2023-01-03 133345

No it doesn’t. It’s the YAML configuration that is being removed. You can configure it via the UI instead. See here: Scrape - Home Assistant

As per my original suggestion, if you have any control over the code coming out of your sensor, you could reconfigure it to put out valid JSON then read that with a rest sensor. Scraping should always be a last resort.

1 Like