Help with scrape sensor for TV

I am trying to setup the scrape sensor to tell me when my TV is on or off.

- platform: scrape
  resource: http://172.16.0.80/
  name: "TV Power State"
  select: "body > div > table:nth-child(6) > tbody > tr > td > table > tbody > tr:nth-child(5) > td.s2"
  value_template: "{{ 'ON' if value == 'ON' else 'OFF' }}"
  authentication: basic
  username: admin
  password: admin
  scan_interval: 3

This is my config;

The selector is: body > div > table:nth-child(6) > tbody > tr > td > table > tbody > tr:nth-child(5) > td.s2

I am not sure what the error means, can anybody help me please ?

You might be using a deprecated way out scrape sensor, can you give a try with this?

Oh I see, so add it directly to configuration.yaml rather than a subset of the sensor: config

image
now I get this…

its showing off but it should be on, so its still not working… hmmm

I assume that this page is generated dynamically rather via post request rather than with a fixed address. So, basic scrape sensor would not work for you, you should investigate exact network calls using google chrome inspector window and see how this content is generated.

Looks like it is an iframe from:

http://172.16.0.80/page_status.cgi

but the selector appears the same

If you can open this page in a new browser window and you can see the content via javascript disabled, it is good scrape, otherwise, you should find out what us being post between pages. I feel like it is not straight forward, again use google chrome inspector

1 Like

with javascript disabled via dev tools, the page still loads fine.

so I am not sure why the sensor doesnt work…

i find it funny that when i search “pn-70ta3 home assistant” i find your post from like 4 years ago
anyway when developing for the scrape sensor, try using something like curl to see what home assistant is actually scraping
also try removing your value_template? that may/may not make it easier to debug