Turn on / off TV via HDMI CEC


27 posts   Page 1 of 2   1, 2
by mavo » Mon Aug 27, 2012 9:29 am
Hi,

I want to be able to turn my Samsung TV on (and off) and change to the correct HDMI input by a script or commandline using the HDMI CEC interface.

What is the easier way to do this?
Posts: 7
Joined: Wed Aug 01, 2012 2:08 pm
by dom » Mon Aug 27, 2012 10:29 am
I'd start with cec-client from libCEC.

There's some info here:
viewtopic.php?f=35&t=15593&p=158409&hilit=cec_client#p158409
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5039
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by mavo » Mon Aug 27, 2012 10:57 am
Thanks, i'll give it a go.
Posts: 7
Joined: Wed Aug 01, 2012 2:08 pm
by mavo » Mon Aug 27, 2012 11:41 am
I installed cec-client by 'apt-get install cec-client' however i only get a failure to detect all CEC adapters.

Do i need to compile cec-client or libcec specifically for raspi?
Posts: 7
Joined: Wed Aug 01, 2012 2:08 pm
by dom » Mon Aug 27, 2012 11:46 am
mavo wrote:I installed cec-client by 'apt-get install cec-client' however i only get a failure to detect all CEC adapters.

Do i need to compile cec-client or libcec specifically for raspi?


Yes.
https://github.com/Pulse-Eight/libcec
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5039
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by mavo » Tue Aug 28, 2012 8:19 am
I followed the instructions on how to compile libcec on raspberry itself.

However ./configure does not automatically find the raspi lib and headers, so i specified the path but ./configure ends with "raspberry pi api not found or incompatible with libcec".

Any idea on how to solve this?

I already updated to the latest raspi firmware using rpi-update.
Posts: 7
Joined: Wed Aug 01, 2012 2:08 pm
by polyglot » Mon Sep 10, 2012 12:44 pm
I had this problem too; assuming you're running debian, you need to:
Code: Select all
apt-get install libraspberrypi-dev

That will get you the latest VideoCore libraries that libCEC-1.8 requires.

Mine is compiling now so I haven't tested, but installing that package will make the configure stage work:
Code: Select all
Configured features:
  Pulse-Eight CEC Adapter :             yes
  Pulse-Eight CEC Adapter detection :   yes
  Raspberry Pi support :                yes
Posts: 2
Joined: Wed Aug 08, 2012 9:02 am
by mavo » Thu Sep 13, 2012 12:58 pm
Hi,

Thanks for your feedback.

I'm running the wheezy image. The libraspberrypi-dev was already the latest version.

Any way to check specifically for the videocore lib?
Posts: 7
Joined: Wed Aug 01, 2012 2:08 pm
by Menace » Wed Sep 19, 2012 8:44 am
Any news on this?
I want to do the exact same thing...
Posts: 11
Joined: Sun Sep 16, 2012 5:55 pm
by mavo » Wed Sep 19, 2012 9:09 am
I'm still not able to compile with raspberry pi support...

Any input would be appreciated.

Let me know if you succeed.

Thanks.
Posts: 7
Joined: Wed Aug 01, 2012 2:08 pm
by notboolean » Wed Sep 19, 2012 4:42 pm
I've just took the package from :

http://blog-selfprogramming.dyndns.org/ ... pberry-pi/

good luck
Posts: 2
Joined: Wed Sep 19, 2012 4:16 pm
by kokki » Mon Sep 24, 2012 1:54 pm
Installed the cec-client .. everything was looking good, but some minor problems. When I use something like:

echo "p 0000 1" | cec-client -s .. how can I use mnimun loglevel, I didn't succeed with -d 1 or anything like that? How about making some "macro" for the client? Something like this: echo "on;p 0000 1" | cec-client -s ?? And finally when I did some udev-rule for the bt-keyboard.. I was able to power on TV by connecting the bluetooth keyboard but then I try to change the hdmi output by echoing the cec-client -s .. not working, but if I started the cec-client and manually typed to change the HDMI.. everything works fine, what I am missing here?
Posts: 5
Joined: Sat Jul 14, 2012 1:31 pm
by XavM » Tue Oct 16, 2012 9:49 pm
@kokki : to set log level to minimum use "-d 1"
Ex : echo "on 0" | cec-client -d 1 -s

--------------------------------

I can't turn off the screen of my Samsung TV when using libcec cec-client;
It keeps saying the opcode 'standby' is not supported by my TV

Has anyone been able to turn the TV screen OFF using cec commands on a Samsung ?

How did you manage to turn it off?
Which Samsung model and firmware do you have ?

--------------------------------

The commands I use to turn it off (unsuccessfully) :

echo "tx 10 36" | cec-client -s or echo "standby 0" | cec-client -s

standby 0
DEBUG: [ 56474] << putting 'TV' (0) in standby mode
TRAFFIC: [ 56476] << 10:36
DEBUG: [ 56477] sending data: len = 1, payload = 10:36
DEBUG: [ 56538] received data: header:00020001 p0:00003610 p1:00000000 p2:00000000 p3:00000000 reason:1
DEBUG: [ 56539] command transmitted
DEBUG: [ 56660] received data: header:00040002 p0:04360001 p1:00000000 p2:00000000 p3:00000000 reason:2
TRAFFIC: [ 56661] >> 01:00:36:04
NOTICE: [ 56661] >> TV (0) -> Recorder 1 (1): feature abort ( 0)
DEBUG: [ 56661] marking opcode 'standby' as unsupported feature for device 'TV'


I can power off HDMI from the raspi with /opt/vc/bin/tvservice -o, but it doesn't turn off the TV screen that displays the message "No Signal"

Anynet+ (HDMI-CEC) is set to ON on the TV Settings
'Auto turn Off' is set to Yes.
"StandBy Mode Upgrade" is set to OFF

I can turn on TV : echo "on 0" | cec-client -s

I can change the source from TV Tuner to Raspi HDMI :

echo "as" | cec-client -s
or
echo "tx 1f 82 30 00" | cec-client -s

--------------------------------

My Configuration :

Samsung TV LE40A566P1M - XZF
TV Firmware v 1017 (the last one available)

Libcec, Debian Wheezy and Raspi Firmware are up to date

cec-client -i
libCEC version: 1.9.0, host: armv6l-unknown-linux-gnueabihf, features: 'P8 USB' 'P8 USB detect' 'RPi', git revision: 815dbda, compiled on: Wed Sep 26 10:18:45 UTC 2012 by root@raspberrypi on Linux 3.2.27+ (armv6l)

uname -a
Linux raspberrypi 3.2.27+ #160 PREEMPT Mon Sep 17 23:18:42 BST 2012 armv6l GNU/Linux

/opt/vc/bin/vcgencmd version
Sep 18 2012 01:44:00
Copyright (c) 2012 Broadcom
version 337601 (release)

--------------------------------

Usefull ressources regarding cec and libcec :

http://www.cec-o-matic.com/
http://selfprogramming.bplaced.net/?page=downloads
Posts: 35
Joined: Thu May 31, 2012 11:29 pm
by neophytte » Wed Oct 17, 2012 6:39 am
I know this may be a bit OT for this conversation, but you may also want to investigate SamyGo

http://sourceforge.net/projects/samygo/

Cheers

Richard
{sig}
Pi1 [media]: Updated version Raspberry Pi (B, rev2, 512Mb), Samsung 58" Plasma (PN58C8000YFXZA), 8GB Class 6 SD Card with RaspBMC
Pi2 [webserver?]: Original Raspberry Pi (B, rev1, 256Mb), headless, 4Gb Class 6 SD Card
{/sig}
User avatar
Posts: 16
Joined: Thu Oct 11, 2012 5:58 am
Location: Perth, Australia
by Therket » Wed Oct 17, 2012 4:44 pm
@XavM

Can't really help you here. I just can confirm that both "standby 0" and the raw tx-command work fine with my Philips TV.
Seems Samsung just didn't implement that feature.

Regards
Jens
Posts: 12
Joined: Mon Aug 06, 2012 3:48 pm
by shaun5 » Fri Oct 19, 2012 7:04 pm
Anybody get this working on Wheezy?
Posts: 3
Joined: Wed Oct 03, 2012 6:40 pm
by aman » Sun Oct 21, 2012 9:27 pm
I've got a Wheezy install and used the instructions here:

http://selfprogramming.bplaced.net/inde ... rsion-190/

But I on cec-client -i get libcec version: 1.6.2

I follow these instructions

sudo dpkg -r libcec
sudo dpkg -i libcec_1.9.0-1_armhf.deb

and sometimes it upgrades to version 1.9.0 but then drops back on reboot. Even before reboot, it can't find any registered CEC devices.

Any ideas?

Thanks

Aman
Posts: 11
Joined: Wed Oct 10, 2012 6:26 am
by eth0 » Sat Dec 22, 2012 1:21 am
I had the same issue with my Samsung TV. cec-client was reporting it didn't support the standby op-code so I enabled "Auto Turn Off" in the Anynet+ setup menu and now it works. If the TV does go into standby it doesn't turn off my Pi.

I've actually hooked this up to voice control and now when I say "raspberry on" the TV will turn it self on and switch to the correct input. If I say "raspberry tv" it will switch to the TV input and "raspberry off" it will turn the TV off :D
Posts: 6
Joined: Fri Dec 21, 2012 11:41 pm
by migube » Wed Dec 26, 2012 7:18 am
hi Eth0
can u post a link to the Voice control portion ? how did u implement on the PI ?:)
tx
Posts: 29
Joined: Tue Jul 17, 2012 7:02 am
by rana » Mon May 20, 2013 10:48 pm
+1 please share

eth0 wrote:I had the same issue with my Samsung TV. cec-client was reporting it didn't support the standby op-code so I enabled "Auto Turn Off" in the Anynet+ setup menu and now it works. If the TV does go into standby it doesn't turn off my Pi.

I've actually hooked this up to voice control and now when I say "raspberry on" the TV will turn it self on and switch to the correct input. If I say "raspberry tv" it will switch to the TV input and "raspberry off" it will turn the TV off :D
Posts: 1
Joined: Mon May 20, 2013 10:40 pm
by georg.bartzos » Mon Sep 16, 2013 7:16 pm
another easy (wheezy) way is ...

-- turn of tv --

$ /opt/vc/bin/tvservice -o

-- turn on tv --

$ /opt/vc/bin/tvservice -p

for more information:

$ tvservice -h

:-)
User avatar
Posts: 15
Joined: Sat Aug 17, 2013 3:55 pm
Location: Germany
by acognard » Sun Dec 01, 2013 9:05 pm
hi all,
i am interested in using this features. But i am not sure to understand all prerequisites... Do i need any special hardware in addition of an hdmi ?
Sincerly.
Arnaud
Posts: 7
Joined: Sat Oct 12, 2013 1:15 pm
by leinad » Fri May 02, 2014 4:06 pm
Finally managed to get around the problem of using cec-client.
I tried downloading/compiling/using cec-client and always got a response like

pi@rpi-xbmc:~$ echo "on 0" | cec-client -s
DEBUG: [ 2] trying to autodetect all CEC adapters
autodetect FAILED

I had read about the issue that XBMC has its own cec-client, but was never able to find/use it.

echo "on 0" | /opt/xbmc-bcm/xbmc-bin/bin/cec-client -s
echo "standby 0" | /opt/xbmc-bcm/xbmc-bin/bin/cec-client -s

works out of the box to turn on/off my samsung tv via ssh.
Posts: 5
Joined: Fri Jun 08, 2012 2:42 pm
by pouipsch » Fri Jul 11, 2014 2:15 am
leinad - Registered here just to say huge thanks for posting this - I was looking for a way to do the same thing and it was driving me nuts!

Thanks!

leinad wrote:Finally managed to get around the problem of using cec-client.
I tried downloading/compiling/using cec-client and always got a response like

pi@rpi-xbmc:~$ echo "on 0" | cec-client -s
DEBUG: [ 2] trying to autodetect all CEC adapters
autodetect FAILED

I had read about the issue that XBMC has its own cec-client, but was never able to find/use it.

echo "on 0" | /opt/xbmc-bcm/xbmc-bin/bin/cec-client -s
echo "standby 0" | /opt/xbmc-bcm/xbmc-bin/bin/cec-client -s

works out of the box to turn on/off my samsung tv via ssh.
Posts: 1
Joined: Fri Jul 11, 2014 2:12 am
by jessemillerjom » Mon Jan 12, 2015 6:38 pm
Hi all, I have a similar problem with my Samsung TV. I can turn it on, but not off. Full details here: viewtopic.php?f=28&t=87151&p=0&e=0

Can anyone help?
Posts: 2
Joined: Tue Sep 16, 2014 5:48 pm