miracle2k / onkyo-eiscp

Control Onkyo A/V receivers over the network; usuable as a script, or as a Python library.
MIT License
466 stars 110 forks source link

switching TV connected to HDMI On via CEC #80

Open lolouk44 opened 6 years ago

lolouk44 commented 6 years ago

I see in the list of commands that one can enable or disable CEC, but I can't see the command to turn a TV on. Yet if I turn my blu-ray or satellite receiver on, the TV turns on automatically.

What command would I need to use to turn the TV on? Thanks

ouija commented 6 years ago

Looked into this a bit further; Unfortunately doesn't look like the ISCP commands for "TV (via RIHD)" have been implemented into the script.

Any way this can be requested? (please!) Basically looking at sending a "POWER", "PWRON", "PWROFF" command via "CTV" code..... going to see if I can figure out how to do this myself, but my Python stills are terrible..

lolouk44 commented 6 years ago

@ouija I've not seen either an ISCP command that would do that, but if you do find one, please post your findings here 👍

ouija commented 6 years ago

"CTV" is the TV RHID (CEC) Operation command for the Onkyo ISCP protocol, as is "CDV" for DVD/BD Players, as per the latest documentation here: http://michael.elsdoerfer.name/onkyo/ISCP_AVR_134.xlsx)

I was curious about this, and came across another utility for sending iscp commands via Linux (http://simon.aldrich.eu/blog/2013/01/onkyo-network-remote/) which allows you to define the actual ISCP commands.

So after building the binary, I found that running the commands ./onkyo-iscp 192.168.1.100 CTV MUTE and ./onkyo-iscp 192.168.1.100 CTV VLUP or ./onkyo-iscp 192.168.1.100 CTV VLDN worked beautifully while both the receiver and TV are on, meaning the TV RHID (CEC) commands are indeed being passed from the receiver to the TV via the command line with this utility.

However, running the commands ./onkyo-iscp 192.168.1.100 CTV POWER and ./onkyo-iscp 192.168.1.100 CTV PWROFF had no effect if the TV was already on; But further testing found that if the TV was off (and the receiver was on) then it WORKS!

So using this utility, you essentially need to run the PWR 01 command to first turn on the receiver, and then the CTV PWRON command to turn on the TV 👍

Note that I was attempting this with a Samsung H Series TV (2015), and you need to ensure that "System -> Anynet+ (HDMI-CEC) -> Auto Turn Off" is enabled (for it to allow CEC power commands)

I would like to formally request that @miracle2k integrate the CTV/CDV commands into onkyo-eiscp, but I'll take a stab at forking the source code tonight and see if I can add them in myself...

Enjoy! :)

ouija commented 6 years ago

UPDATE: Sorry for turning this thread into a novel, but did some playing around with the source code tonight and I think I've gained a better understanding of why this was left out of the script to begin with.

Seems the CEC commands don't return a response from the receiver the way all other commands do (where it matches the response of the command that was sent to the group of commands it belongs to).

This works fine for all other commands where the receiver performs an action and a response is returned in relation to that action. But the CEC commands are different, in that they themselves essentially call other actions to complete the requests, and the response that is returned is in relation to this other action that was called, and not the initial CEC command itself.

For example, sending a volume up command via CEC returns the same response as sending the master-volume=level-up command, but this response doesn't match the same command group as the initial CEC command, and the script will end up timing out.

The CEC command is still sent and it does work, but the error message isn't pretty and leaves the impression that it fails.

Sooo... I decided to try and implement support for the CEC commands myself tonight (since @miracle2k wrote this thing so brilliantly that it's actually really easy to add in additional commands)

Once I figured out how the responses were being handled, I added an exception to the script which simply returns what CEC commands were called (instead of waiting for a response to these commands) and it now works beautifully!!

I now am able to turn on my TV and Receiver using a single command: onkyo power=on hdmi-cec.ctv=on

You can find my fork with all the changes at: https://github.com/ouija/onkyo-eiscp

If you simply replace the commands.py and core.py files under the eiscp package directory for python on your machine, you should be good to go.

Thanks to @miracle2k for making such a useful script, and also thanks to Simon Aldrich for his script as well.

lolouk44 commented 6 years ago

Great news, I can't wait to try tonight :)

miracle2k commented 6 years ago

@ouija Looks like something I might be able to merge; I'll try to find the time to look at it.

Note that with this script you can also submit raw commands like PWR01.

ouija commented 6 years ago

Awesome. Yeah, after I became more familiar with the script (and read the actual documentation) I realized this. Great job on it, it's going to serve my needs very well!

lolouk44 commented 6 years ago

Hi @miracle2k I was wondering if you could share with us approx when you think you could merge @ouija 's code? I'd rather wait for your version than play with different repos. Also I take it you're the owner of the Home-Assistant eiscp code? If so will you also update it? Thanks

wrobelda commented 6 years ago

Just tested this with my BenQ projector and while turning off works fine, turning off doesn't. I guess it's due to manufacturers' CEC incompatibilities.

ouija commented 6 years ago

Not sure if you're having trouble turning it on or off (reiterated yourself there!) but note there are three possible CEC power commands that can be issued: onkyo hdmi-cec.ctv=on, onkyo hdmi-cec.ctv=off and onkyo hdmi-cec.ctv=power

Also try maybe the CEC DVD Commands? ie: onkyo hdmi-cec.cdv=on

The specification had three separates codes listed for TV/DVD CEC Power (PWRON, PWROFF and POWER) and each of these commands correspond to each code, which may make a difference in your case, but not sure.

I think the single POWER command can do both power on and off (haven't really tested) and the ISCP documentation doesn't provide any details other can the code names :)

wrobelda commented 6 years ago

but note there are three possible CEC power commands that can be issued: onkyo hdmi-cec.ctv=on, onkyo hdmi-cec.ctv=off and onkyo hdmi-cec.ctv=power

Yeah, I have in fact tried them all, but still, only the "on" command works.

Also try maybe the CEC DVD Commands? ie: onkyo hdmi-cec.cdv=on

That's what I use now. "on" switches on my Apple TV, receiver and projector. "off" switches the Apple TV and a receiver, but not a projector. Similarly, if I turn off my Apple TV manually using its remote, only the receiver will turn off. I guess this is, therefore, BenQ's incompatible implementation here causing this behavior.

I worked around, however, but setting the auto power-off on the projector to 5 mins when no signal is present and that basically does the job.

toshibochan commented 6 years ago

Did you try change off to standby?

wrobelda commented 6 years ago

I have in fact tried them all, but still, only the "on" command works.

Yeah.

rui-nar commented 5 years ago

hey @miracle2k , do you think you are able to merge @ouija commits to enable CEC TV control ? I'd rather continue using your (official) package (from PyPi) rather than modifying by hand using @ouija modifications.

many thanks

toshibochan commented 5 years ago

Did you try onkyo hdmi-cec.ctv=standby

misomosi commented 4 years ago

I can't seem to get any of these CEC commands to do anything other than the ones that control volume. None of the power commands perform regardless of the TV state, but any connected devices like a PS4 has no problem turning the TV on.

TV is an LG 55UH7700, so perhaps there are incompatibilities with LG?

ouija commented 4 years ago

I had similiar issues with an LG 70UJ6570 and ended up using another script to power on the TV, and created my own fork of this here: https://github.com/ouija/LGWebOSRemote

The TV will send a CEC command to the Onkyo Reciever and power it on as well, if connected to HDMI ARC / CEC Enabled.

Hope this helps!

misomosi commented 4 years ago

I had similiar issues with an LG 70UJ6570 and ended up using another script to power on the TV, and created my own fork of this here: https://github.com/ouija/LGWebOSRemote

The TV will send a CEC command to the Onkyo Reciever and power it on as well, if connected to HDMI ARC / CEC Enabled.

Hope this helps!

Excellent workaround, ouija! I wasn't aware you could power the TV on and off from the network.