HDMI CEC and Shutdown
Posted: Mon Jul 26, 2021 7:53 pm
Hello
I modified https://github.com/Howchoo/pi-power-button file to allow me to turn the tv off wait 30 sec and turn the pi off when gpio pin5 state changes. Still trying to figure out how to get the tv on once I turn the pi on. here is the python script i am running
#!/usr/bin/env python
import RPi.GPIO as GPIO
import subprocess
import cec-client
import time
cec.init()
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(3, GPIO.FALLING)
tv = cec.device(0)
tv.standby()
# wait for 30 secs before shutting down
sleep(30)
subprocess.call(['shutdown', '-h', 'now'], shell=False)
the shutdown part works and if use the terminal and type echo 'standby 0.0.0.0 | cec-client -s -d 1 it turns the tv off.
I modified https://github.com/Howchoo/pi-power-button file to allow me to turn the tv off wait 30 sec and turn the pi off when gpio pin5 state changes. Still trying to figure out how to get the tv on once I turn the pi on. here is the python script i am running
#!/usr/bin/env python
import RPi.GPIO as GPIO
import subprocess
import cec-client
import time
cec.init()
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(3, GPIO.FALLING)
tv = cec.device(0)
tv.standby()
# wait for 30 secs before shutting down
sleep(30)
subprocess.call(['shutdown', '-h', 'now'], shell=False)
the shutdown part works and if use the terminal and type echo 'standby 0.0.0.0 | cec-client -s -d 1 it turns the tv off.