eslavnov / pylips

Control Philips TVs (2015+) and Ambilight (+ Hue) through their reverse-engineered API (+ MQTT support!)
MIT License
348 stars 59 forks source link

feat: add powerstate support #2

Closed FezVrasta closed 5 years ago

FezVrasta commented 5 years ago

The api returns a JSON object containing the powerstate key that can be On or Off

FezVrasta commented 5 years ago

Right now I use this API inside a command_line control in Home Assistant to scan for its state each 10 seconds, so that I can run automations when the TV is on or off. I doubt it's very efficient, it'd be great to find a way to retrieve the power state in a different way.

Here how I use it right now:

  - platform: command_line
    name: Philips 65OLED873/12 state
    scan_interval: 10
    command: "curl -X GET -s --digest --insecure -u xxxx:xxxx  https://x.x.x.x:1926/6/powerstate"
    value_template: >
      {% if value_json.powerstate == 'On' %}
        on
      {% else %}
        off
      {% endif %}
eslavnov commented 5 years ago

Thank you for the PR!

Regarding querying the TV state I have some plans to integrate MQTT for this purposes, we'll see how it goes...