Power Control - jsiegenthaler/homebridge-samsungtvht GitHub Wiki
Turning On Directly
Turning On via cec-client
Most of the Samsung TVs (that this plugin work with) switch off their Ethernet port when turned off, so you cannot use a LAN-based remote control to turn them on. The only way to turn the TV on is with HDMI-CEC or an IR remote control. If you have Homebridge running on a raspberry pi, you can connect the raspberry pi HDMI port to a spare HDMI-CEC port on your TV, and then use the cec-client to turn the TV on over HDMI-CEC. You can use any cec-client command you like. Useful commands to turn on the TV are:
echo 'on 0' | cec-client -s -d 1
Turn on device 0 (TV). For the Home Theater (HT), use device 5 (receiver).echo 'tx 1F:82:10:00' | cec-client -s -d 1
Set the TV to HDMI input 1, and turn on if needed.echo 'tx 1F:82:20:00' | cec-client -s -d 1
Set the TV to HDMI input 2, and turn on if needed.echo 'tx 1F:82:30:00' | cec-client -s -d 1
Set the TV to HDMI input 3, and turn on if needed.echo 'tx 1F:82:40:00' | cec-client -s -d 1
Set the TV to HDMI input 4, and turn on if needed.
You can see what the CEC commands mean on the CEC-O-MATIC website. Not every device supports every CEC command, you need to experiment.
NOTE: the -s option for the cec-client means that the client sends a single command, and then quits. Experience has shown that the client sometimes may not quit properly, and also doesn't like running multiple instances at the same time. If the cec-client stops responding, you may need to reboot your raspberry pi.
Turning On via homebridge-apple-tv-remote
iOS 15, tvOS 15 and later versions
From iOS 15 and tvOS 15, released September 2021, the homebridge-apple-tv-remote v0.12.2 can no longer connect to the Apple TV, due to a change in the Apple protocols. Refer to pyatv for an alternative solution.
iOS 14 and earlier iOS versions
If you have an Apple TV connected to your TV, you can install the homebridge-apple-tv-remote plugin, and then use a switch in homebridge to turn on (wake) the Apple TV. Homebridge can then be controlled by a curl command. My curl command for my Apple TV switch on is:
curl -X PUT http://192.168.x.x:51437/characteristics --header "Content-Type:Application/json" --header "authorization: xxx-xx-xxx” --data "{ \"characteristics\": [{ \"aid\": 210, \"iid\": 4, \"value\": 1}] }"
In this example: 192.168.x.x is the ip address of homebridge, 51437 is the port that homebridge is running on (displayed in homebridge as "Running on port 51437"), 210 is the accessory id (aid), and 4 is the identifier id (iid). Find your aid and iid by going to http://192.168.x.x:51437/accessories
in your web browser. You will get a JSON response, put this in any text editor, preferably one that can display JSON formatted, and search for the name you gave your Apple TV switch.
Turning Off
Turning off the TV can happen via the remote control command over the LAN. The most common key code to turn off the TV or HT is:
- TV: KEY_POWEROFF
- HT: BD_KEY_POWER
Detecting Current Power State
The plugin uses pings to determine if the network power is responding, and thus if the TV or HT is turned on. It parses the ping response text to see if the device is responding. If response to at least 1 ping is found, then the device is considered ON. The ping response, and thus the text to parse for pingResponseOff
, varies by operating system. From v0.11.24, the ping response text for Linux and Windows are built in to the plugin. Any user-configured ping response text overrides the built in detection. Examples are given to detect the text in the ping statistics, see the Linux and Windows examples below.
If you are unsure what your system ping response is, put Homebridge in Debug Mode and restart. The plugin will log the ping commands and responses.
Linux Ping Response
TV is ON
1 packets transmitted, 1 received, 0% packet loss, time 0ms
TV is OFF
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
Windows Ping Response
TV is ON
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
TV is OFF
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),