Scrape sensor for domotika relay ip board

Hi,
I have this code:

i want to create one sensor scrape with value cs2=0

- platform: scrape
   scan_interval: 10
   resource: http://admin:[email protected]/index.htm
   name: consumo_test
   select: ???
   value_template:???
   unit_of_measurement: "Kw"

Can you help me?
Sorry for my english…

Why did you circle style='color: rgb…? Is that part of the requirements?

- platform: scrape
   scan_interval: 10
   resource: http://admin:[email protected]/index.htm
   name: consumo_test
   select: "#cs2"
   unit_of_measurement: "Kw"

To get a value by id, you use “#id” for the select. If this is the only id with this name, this will pull that value.

Hard to tell without access to the site.

You don’t need a value_template if the output is already in the correct format.

If you have multiple relays (r1, r2, …), you can do

select: “#r1 > #cs2

HI Jocnnor,
the first circle is a mistake!
I tried your scrape sensor but doesn’t work.
I think the sensor doesn’t connect to the ip board.
i tried:

- platform: scrape
   scan_interval: 10
   resource: http://192.168.178.10/index.htm
   username: admin
   password : domotika
   name: consumo_test
   select: "#cs2"
   unit_of_measurement: "Kw"

but dosen’t work.

thank you

Can you run the curl command from the same machine as home assistant?

curl -u admin:domotika -X GET http://192.168.178.10/index.htm

Hi,
i tried this scrape sensor

- platform: scrape
     scan_interval: 5
     resource: http://192.168.178.10/index.htm
     username: admin
     password: domotika
     name: consumo_test
     select: 'div p:nth-child(1)'

with this code I successfully extracted the word RELAY then the connection works very well!

I tried various solutions to extract the number 0 but it does not work.
:thinking: :thinking:

Is that the whole website? Or just a snip of it?

Without access, I can’t see all of the tags.

If div p:nth-child(1) gets you ‘RELAYS’, then try this I guess…

select: 'div p:nth-child(1) > span > span#cs2'

That says to get the span tag directly beneath p:nth-child(1). Then from there, get the span tag directly beneath that one with the id cs2.

Hi,
your “select” code not work.
this is all web code of my relay ip board.

I opened all the tags
Thank you so much for your help
Marco

It should work, assuming those tags are there and not populated by javascript. Javascript wont be run when you scrape it…

What is the output of:

curl -u admin:domotika -X GET http://192.168.178.10/index.htm

Hi,
this is the output:
output

:thinking: