RESTful Switch to control projector, problem with is_on_template


I’m trying to make a On/Off switch for my projector, I have gotten it to turn on, but the switch resets to the off state so I cannot turn it off. My workaroud for this was to create two switches, but I need a way to get the state of the projector.

This is what I have now:

- switch :
  name: Projector On
  platform: rest
  resource:  http://X:[email protected]/ctrl.cgi
  body_on: "PWRON=  On  "

- switch 2:
  name: Projector Off
  platform: rest
  resource:  http://X:[email protected]/ctrl.cgi
  body_on: "PWROFF=  Off  "

This works fine, but I want to be able to get the state from the projector to make one switch that works as it should.

The projector shows the state on this page:
This is the part of the HTML on the webserver on the projector that shows the state, can I somehow get this into HA?
<div class="txt"><br>Power: <b>Off</b>

If anyone knows how to use this with is_on_template from HA please let me know.

1 Like

Old post, but in case someone looks for the answer, you can use is_on_template with a regex, see Regex in Scripts.yaml "regex_match"