busutm
(Marco)
1
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…
jocnnor
(Jim O'Connor)
2
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”
busutm
(Marco)
3
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
jocnnor
(Jim O'Connor)
4
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
busutm
(Marco)
5
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:](https://community.home-assistant.io/images/emoji/twitter/thinking.png?v=9)
jocnnor
(Jim O'Connor)
6
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.
busutm
(Marco)
7
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
jocnnor
(Jim O'Connor)
8
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