Scrape value of input field?

Hi,

Looking for a way to scrape value from my ventilation system. It expose data on a simple web page (no css tags). I was able to successfully scrape parts of it, but struggling how to access value of the input field?

part of the page:

<div style="width: 90%; height: 8%; margin-right: auto; margin-left: auto; clear: none; ">
   <div style="width: 25%; height: 100%; float: left; ">
      <input type="submit" ;="" name="Tywe" value="Tylko wentylacja" span="" style="color: black; font-size: 12pt; background-color: grey; border-style: double;  border-color: black; box-shadow: inset 5px 10px 20px black; width: 50%; height: 100%;text-align: center; ">
   </div>
   <div style="width: 50%; height: 100%;  margin-left: auto;margin-right: auto; ">
	<input type="submit" ;="" name="Wentminus" value="-" span="" style="color: black; font-size: 18pt; background-color: olive; border-style: dashed;  border-color: green; border-radius: 20px 20px 20px 20px; box-shadow: inset 5px 10px 20px purple; width: 10%; height: 100%; text-align: center; margin-left: auto; ">
	<input type="submit" ;="" name="Wentylacja" value="Wentylacja  10%" span="" style="color: yellow; font-size: 18pt; background-color: green; border-style: double;  border-color: black; box-shadow: inset 5px 10px 20px black; width: 70%; height: 100%; text-align: center; margin-left: auto; margin-right: auto; ">
	<input type="submit" ;="" name="Wentplus" value="+" span="" style="color: black; font-size: 18pt; border-radius: 20px 20px 20px 20px; background-color: olive; border-style: dashed;  border-color: red; box-shadow: inset 5px 10px 20px purple; width: 10%; height: 100%; text-align: center; margin-right: auto; ">
   </div>
</div>

I al looking for this value “10%”.

The selector copied from Chrome developer console i tried to use is:
“body > span > font > form > div:nth-child(8) > div:nth-child(2) > input[type=submit]:nth-child(2)”

But this sensor

  • resource: http://192.168.9.45/?
    sensor:
    • name: “Vent power”
      select: “body > span > font > form > div:nth-child(8) > div:nth-child(2) > input[type=submit]:nth-child(2)”
      value_template: ‘{{ value.split("%")[1] }}’

does not show anything.

Any hints hot to scrape it?

Best regards,

Michał

Please format your code with the </> button. Try this, with the attribute set (docs), and a much simpler select, assuming there are no other input elements outside of the code snippet:

resource: http://192.168.9.45/?
sensor:
  - name: Vent power
    select: "input"
    index: 2
    attribute: value
    value_template: '{{ (value.split()[1]).replace('%','') }}'
    unit_of_measurement: '%'

Thank you, that worked.
Except getting rid of % - had to remove .replace(’%’,’’) - as received errors.