Hello guys! I've made a little script to turn off my LEDs when my AVR turns off and vice versa. It uses the CEC-Client, so it should work with everyone as long as your devices are HDMI-CEC compliant. The instructions to install it are included in the top part of the script. It's a pretty simple script so it shouldn't be a big deal to make it work. PHP: #!/bin/bash# Script for hyperion which allows you to turn off your LEDs when your AVR is off and vice versa.# Tested with Raspian on an RPi3# 1 - Plug your RPi with an HDMI cable on your AVR# 2 - Copy the script on your RPi# 3 - Run sudo chmod +x on the script# 4 - To make it run at startup, add @reboot /your/path/yourscriptname.sh to crontab -e# 5 - Enjoy# RaPiiDeremotePath="hyperion-remote"isOn=-1while :do # We get the CEC status status=$(echo pow 0 | timeout 5 cec-client -d 1 -s) # If it's off and it wasn't already, let's turn off the LEDS if [[ "$status" == *"power status: standby"* ]] && [[ "$isOn" != "0" ]] then eval "$remotePath --priority 0 --color black" isOn=0 # If it's on and it wasn't already, let's turn on the LEDS elif [[ "$status" == *"power status: on"* ]] && [[ "$isOn" != "1" ]] then eval "$remotePath --clearall" isOn=1 fi sleep 2done Have fun!
Hallo Klingt interessant, aber habe von der Materie keine Ahnung. Der Raspberry ist am TV angeschlossen, somit also auch Cec möglich. Wo müsste ich die Datei einfügen?
I don't speak German so I'm going to answer in English. First, you need to copy the script on the raspberry, you've got at least 2 ways to do it. Copy/paste the text in a new file via SSH (with Putty) or you could copy the file via SFTP (Winscp or Filezilla can do that).
[QUOTE = "RaPiiDe, post: 30626, member: 5271"] Dies erfordert Sie das Skript auf die Himbeere kopieren. Sie haben mindestens zwei mögliche, stirbt zu tun. Kopieren Sie den Text in einer neuen Datei über SSH (mit Putty) oder Steuern Sie ihn über SFTP ein (Winscp oder Filezilla können das). [/ QUOTE] Hallo danke für die Rückmeldung. Wo muss denn die Datei genau hin, habe das Image Raspbian jes. Installiert. Benutze kein Kodi auf dem Himbeere, nur extern. Thank you for your answer I don't know where to insert the script? In which folder or path do I have to paste the script
I saved the script in root, rights are 755, but it doesn't work. What could it be? Image is Raspbian jessie
Hi, I've had to fight a bit with it too before getting it to work !! First, I'm on windows and created the xxx.sh file with notepad++ Thing is, windows uses CRLF instead of LF for line feeds... That's why it didn't work in the first place. If you use notepadd++ too, just double click on the "windows CRLF" text in the bottom-right of the window and choose "convert to UNIX LF" and save. Next problem was that I'm on Hyperbian, and it looks like the CEC package was not installed. So I ran this command in SSH : sudo apt-get install cec-utils After this, a simple reboot and it started to work !!! Very nice replacement for the signal detection.
Hi there Thanks for the information. I had installed the cec package and inserted the file with wincp But maybe I'm doing something wrong. I don't understand that at all: # 4 - So that it will at startup, you will crontab @reboot /your/path/yourscriptname.sh
Ok. First, how did you "create" the .sh file ? if it is on windows, you'll have the line feed problem as I mentioned, and you need to fix this otherwise it won't work. Second, the crontab part is mandatory. SSH to your pi (with putty) and then execute this command : crontab -e This will open a file editor with lot of comments. Add this line at the end of the file : @reboot /path/to/your/script.sh and save. Then reboot the Pi and you're good to go.
Hi It doesn't work I switched the TV off and the LEDs goes not off. The LEDs have the standby rainbow colours.
Damn I forgot one thing.... Somewhere in the script there is "priority 0", you have to change it to "priority 1 " Change also "sleep 2" to "sleep 1"
Hi There is the script, where do I have to change that? With remotePath = "PathToYourHyperion-remote" I have to enter the correct path? remotePath="hyperion-remote" isOn=-1 while : do # We get the CEC status status=$(echo pow 0 | timeout 5 cec-client -d 1 -s) # If it's off and it wasn't already, let's turn off the LEDS if [[ "$status" == *"power status: standby"* ]] && [[ "$isOn" != "0" ]] then eval "$remotePath --priority 0 --color black" isOn=0 # If it's on and it wasn't already, let's turn on the LEDS elif [[ "$status" == *"power status: on"* ]] && [[ "$isOn" != "1" ]] then eval "$remotePath --clearall" isOn=1 fi sleep 2 done Have fu Can you show me your Skript please
That script is 10 lines long and you can't find where are the words "priority" and "sleep" ? really ?... You will find attached the modified script (with correct line feeds). Rename it to whatever you named yours et also change its extension to .sh, because the forum doesn't accept .sh files as attachements. DO NOT MODIFY ITS CONTENT, UPLOAD IT TO YOUR PI
thank you very much !!! It works. My script didn't include switching the LEDs to black. I had already adapted the rest of the script like you did. Thank you and happy Christmas
Normally, there is no need to send Black when you disable a Led device. Depending on the Led type, the LEDs are set to black while switching off. Other led types, eg the network ones, the device is switched off via API. Writing black is only a solution for a subset of devices....
Thanks for the info. So what should we change the commands to enable/disable the led device according to CEC state instead of setting it to black ? Thanks in advance. EDIT: I mean instead of this command : eval "$remotePath --priority 0 --color black"
@NeeeeB Please check, if the following works with you: Code: ./hyperion-remote --disable LEDDEVICE ./hyperion-remote --enable LEDDEVICE The behavior is as you would disable/enable the LED-Device via the Remote-Control in the UI
Ah great !! Much better than setting it to black ofc. Do I have to replace "LEDDEVICE" with something (e.g name of the instance) or will it work as is ?
Sorry, if you using multiple instances, you can provide the instance via "--instance instancename" as an additional parameter: If you leave it out the default instance is used. Code: ./hyperion-remote --instance 'Nanoleaf' --disable LEDDEVICE To see all capabilities of hyperion-remote, just do a Code: ./hyperion-remote --help This might give you additional ideas, too ...
Thanks, greatly appreciated ! That works like a charm, much better than setting a black color. Will run the --help command to see what else I could do ^^ Thanks again !