This script is to do the similar thing with little difference. When I am in my room with TV turned on, I want to turn off the light always. So I made a script that checks if the TV is turned on and if it is, it will turn off the light.
But the point is that if your TV is able to access network, you can use this script, because this script uses only basic aspect of network adapters. It doesn't have to be Samsung TV and most of Smart TV will work with this script.
The script works in three steps:
- Figure out the IP address of TV and Hue brigde
- Ping on the TV IP
- Turn off Hue if TV is turned on
There is one assumption that came from my TV. It shouldn't respond to PING if the TV is turned off. If your TV respond to PING request even when it is turned off, I will be surprised.
For the controlling Hue lights with a script, I already explained it a few month ago, so I am skipping it here.
Once you got the script running, you can keep running it with crontab.