Forum

Full Version: turn on on tv with cec
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
does anyone know how i can turn my tv on by sending a command to xbmc to
turn on the tv remotely by cec
echo "on 0" | cec-client -s
i think he's about that his cec do not work,so when pi starts the TV is not switching ON .
lets wait what he says Wink
first of all thank you for the echo "on 0" | cec-client -s
and rikardo1979 im sorry if my msg is not clear
what im trying send a command to my tv when someone at the door and play a webcam stream so if im cooking or something i can just look at my tv and see who is at the door

so now you know what i want to use it for how can i send this command from my http or tcp i hope it makes sense what im trying to do
you can always call xbmc build in functions by accessing xbmc through web interface or json, and I'm sure there is build in function to run system command, but for this case it unnecessary complicated.

of course it depends on the system / machine which is triggered by the movement (change in picture on your cam), but to run the command remotely you can always do like:
Code:
ssh xbian@my_xbian_rpi_ip "echo \"on 0\" | cec-client -s"
of course you would need to configure to be able to login without password, what is possible by removing xbian password and allow sshd to accept zero passwords, or by generating rsa key pair.

or via xbmc http and build in functions http://wiki.xbmc.org/index.php?title=List_of_built-in_functions by using System.Exec("echo \"on 0\" | cec-client -s")

there is broad scale of possibilities for this one and depends on all the devices used in this "chain" of events starting from the cam and ending by turning on the tv
i dont think im doing this right

http://192.168.0.2/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"System.Exec("echo \"on 0\" | cec-client -s")

but i get
{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
what im i doing wrong?
hey uncle leave out the xbian@my_xbian_rpi_ip out ones you ssh just type# echo \"on 0\" | cec-client -s


but when i do that im getting

xbian@xbian ~ $ echo \"on 0\" | cec-client -s
opening a connection to the CEC adapter...
DEBUG: [ 62] unregistering all CEC clients
DEBUG: [ 65] Broadcast (F): osd name set to 'Broadcast'
DEBUG: [ 67] InitHostCEC - vchiq_initialise succeeded
DEBUG: [ 69] InitHostCEC - vchi_initialise succeeded
DEBUG: [ 71] InitHostCEC - vchi_connect succeeded
DEBUG: [ 73] logical address changed to Broadcast (f)
DEBUG: [ 74] RegisterLogicalAddress - registering address e
DEBUG: [ 255] logical address changed to Recorder 1 (1)
DEBUG: [ 255] logical address changed to Free use (e)
DEBUG: [ 255] Open - vc_cec initialised
NOTICE: [ 255] connection opened
DEBUG: [ 256] processor thread started
DEBUG: [ 261] << Broadcast (F) -> TV (0): POLL
DEBUG: [ 264] initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
TRAFFIC: [ 265] << e0
DEBUG: [ 298] >> POLL sent
DEBUG: [ 298] TV (0): device status changed into 'present'
DEBUG: [ 298] << requesting vendor ID of 'TV' (0)
TRAFFIC: [ 298] << e0:8c
TRAFFIC: [ 502] >> 0f:87:00:00:f0
DEBUG: [ 502] >> TV (0) -> Broadcast (F): device vendor id (87)
DEBUG: [ 503] TV (0): vendor = Samsung (0000f0)
DEBUG: [ 503] expected response received (87: device vendor id)
DEBUG: [ 503] replacing the command handler for device 'TV' (0)
NOTICE: [ 504] registering new CEC client - v2.0.5
DEBUG: [ 504] detecting logical address for type 'recording device'
DEBUG: [ 504] trying logical address 'Recorder 1'
DEBUG: [ 504] << Recorder 1 (1) -> Recorder 1 (1): POLL
TRAFFIC: [ 504] << 11
DEBUG: [ 504] UnregisterLogicalAddress - releasing previous logical address
DEBUG: [ 505] logical address changed to Broadcast (f)
DEBUG: [ 507] RegisterLogicalAddress - registering address 1
DEBUG: [ 689] logical address changed to Free use (e)
DEBUG: [ 689] logical address changed to Recorder 1 (1)
TRAFFIC: [ 689] << 11
DEBUG: [ 689] >> POLL not sent
DEBUG: [ 689] using logical address 'Recorder 1'
DEBUG: [ 689] Recorder 1 (1): device status changed into 'handled by libCEC'
DEBUG: [ 689] Recorder 1 (1): power status changed from 'unknown' to 'on'
DEBUG: [ 690] Recorder 1 (1): CEC version 1.4
DEBUG: [ 690] AllocateLogicalAddresses - device '0', type 'recording device', LA '1'
DEBUG: [ 690] Recorder 1 (1): osd name set to 'CECTester'
DEBUG: [ 690] Recorder 1 (1): menu language set to 'eng'
DEBUG: [ 691] GetPhysicalAddress - physical address = 1000
DEBUG: [ 693] AutodetectPhysicalAddress - autodetected physical address '1000'
DEBUG: [ 694] Recorder 1 (1): physical address changed from ffff to 1000
DEBUG: [ 694] << Recorder 1 (1) -> broadcast (F): physical adddress 1000
TRAFFIC: [ 695] << 1f:84:10:00:01
NOTICE: [ 846] CEC client registered: libCEC version = 2.0.5, client version = 2.0.5, firmware version = 1, logical address(es) = Recorder 1 (1) , physical address: 1.0.0.0, host: armv6l-unknown-linux-gnueabihf, features: 'P8 USB' 'P8 USB detect' 'RPi', git revision: 6fb1aef, compiled on: Thu Dec 6 22:24:44 UTC 2012 by root@xbian on Linux 3.6.7 (armv6l)
DEBUG: [ 846] << Recorder 1 (1) -> TV (0): OSD name 'CECTester'
TRAFFIC: [ 846] << 10:47:43:45:43:54:65:73:74:65:72
DEBUG: [ 1147] << requesting power status of 'TV' (0)
TRAFFIC: [ 1147] << 10:8f
TRAFFIC: [ 1291] >> 01:90:01
DEBUG: [ 1292] >> TV (0) -> Recorder 1 (1): report power status (90)
DEBUG: [ 1292] TV (0): power status changed from 'unknown' to 'standby'
DEBUG: [ 1293] expected response received (90: report power status)
DEBUG: [ 1294] unregistering all CEC clients
NOTICE: [ 1294] unregistering client: libCEC version = 2.0.5, client version = 2.0.5, firmware version = 1, logical address(es) = Recorder 1 (1) , physical address: 1.0.0.0, host: armv6l-unknown-linux-gnueabihf, features: 'P8 USB' 'P8 USB detect' 'RPi', git revision: 6fb1aef, compiled on: Thu Dec 6 22:24:44 UTC 2012 by root@xbian on Linux 3.6.7 (armv6l)
DEBUG: [ 1294] Recorder 1 (1): power status changed from 'on' to 'unknown'
DEBUG: [ 1294] Recorder 1 (1): CEC version unknown
DEBUG: [ 1294] Recorder 1 (1): osd name set to 'Recorder 1'
DEBUG: [ 1294] Recorder 1 (1): device status changed into 'unknown'
DEBUG: [ 1294] unregistering all CEC clients
DEBUG: [ 1295] UnregisterLogicalAddress - releasing previous logical address
DEBUG: [ 1298] logical address changed to Broadcast (f)
Thank you rana, you must have been adding your past while I was deleting mine. :-)
I have done as you suggested and I get the same DEBUG message(s) The TV is not turning on via the remote at this time.
I guess we just have to wait on one of the experts to help us out then
(21st May, 2013 04:25 PM)mk01 Wrote: [ -> ]echo "on 0" | cec-client -s
Where I can find a list of all compatible cec commands?

How can I turn on my tv and swith it to the HDMI2 input?
(22nd May, 2013 06:27 PM)kraleksandr Wrote: [ -> ]
(21st May, 2013 04:25 PM)mk01 Wrote: [ -> ]echo "on 0" | cec-client -s
Where I can find a list of all compatible cec commands?

How can I turn on my tv and swith it to the HDMI2 input?

http://libcec.pulse-eight.com maybe ?
Wink
did anyone have any luck i have not been able to make it work
ok so here are the command to turn on the tv and off

echo "on 0" | cec-client -s
echo "standby 0" | cec-client -s

now if someone please tell me how i can send this from http ill be set i have been looking for but no lock the best i got was but that didnt work can someone help fix this command
http://192.168.0.2/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"System.Exec("echo "standby 0" | cec-client -s")
i tried making a addon so i can call the addon to run the script to turn off the tv didnt have any luck anyone want to look at and let me know what im doing wrong

here is the addon.xml file

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.script.tvoff" name="Tv off" version="0.1.0" provider-name="RaNa">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="off.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
</extension>
</addon>

and here is the off.py

import os
os.system('echo "standby 0" | cec-client -s')

not sure why its not working
(23rd May, 2013 05:36 PM)rana Wrote: [ -> ]http://192.168.0.2/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"System.Exec("echo "standby 0" | cec-client -s")

jsonrpc doesn't implement system.exec function, but old http does. go for it.
and btw: you can't have quotations ' " ' inside other ones. so you need to use something like " xxx yyy \"inner quotation\" text continues" and you miss "}" at the end as well. so if system.exec would be implemented, the command would look like:

Code:
http://192.168.0.2/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"System.Exec(echo \"standby 0\" | cec-client -s)"}

(25th May, 2013 05:05 PM)rana Wrote: [ -> ]import os
os.system('echo "standby 0" | cec-client -s')

not sure why its not working

if you want to check whether the script is at least started as you are expecting, start some test command like that:

os.system("echo $(date) >> /home/xbian/file.txt")
Pages: 1 2
Reference URL's