newAM / hisensetv

Python API to control Hisense brand TVs via their internal MQTT broker.
MIT License
37 stars 17 forks source link

Turn on the TV on "--key power" #17

Closed nonvegan closed 2 years ago

nonvegan commented 2 years ago

Right now the paho connection just times out when the tv is turned off. We should send a wake-on-lan magic packet when this happens, turning on the TV. I've tested it with wakeonlan and it does work on port 4343.

newAM commented 2 years ago

This one was intentional :)

There are multiple ways to wake up the TV from power off, I found that HDMI-CEC was effective for my usecase because it can detect if the TV is on or off faster than waiting for a socket to time out. I did not want to include this as default behavior incase someone wanted to use a different power-on mechanism to handle this.

nonvegan commented 2 years ago

Yeah I figured you would leave it for other people to choose. I'm not sure which approach the remote app uses but it seems to also work pretty reliably. Could you please provide an example on how you did this?

newAM commented 2 years ago

I went a little bit crazy trying to find a reliable solution :sweat_smile:

Here is what I have tried:

I have a micro-controller gaffer taped on to the back of my TV that accepts commands from my home theater PC. The microcontroller is wired into the HDMI-CEC line on a free HDMI port. Zero reliability issues so far, and I have full control over the hardware & firmware to fix it if something does go wrong. Unfortunately this is crazy amounts of custom for what amounts to a power switch :expressionless:

That all said if you want to do the same the code for this is open source: Firmware: https://github.com/newAM/hdmi-cec-ctrl CEC driver: https://github.com/newAM/stm32-cec

nonvegan commented 2 years ago

Thank you so much for your answer. Since the TV is right by my computer I just have two bat scripts on my desktop to either turn it on or off, not perfect but it will suffice for now 😅. HDMI-CEC seems like something that would be fun to dig into though 😃