Is there a working way to mimic the chromecast's cec switch-input behavior?

Search This thread

caffeinatedmike

New member
Aug 16, 2016
4
0
Hi everyone, first time poster so I'm sorry if this isn't the right forum to post in, but I felt like it was the closest I could think of.

I'm trying to find a way to mimic how the chromecast causes a tv to switch to the input of the chromecast dongle. I have an Android Box that came rooted and has HDMI-CEC capability. What I'm looking to do is somehow use Tasker to trigger the CEC-switch activity/intent/whatever to have my tv (turn on) and switch to the HDMI source of the Android Box (the box will be left on 24/7 and tasker will continually run as background service on the box). Basically, I'm trying to imitate the chromecast's cast action to bring me to my Android Box's input and ultimately it's home screen.

That's where I'm stuck at the moment. Things I've thought might work:

1. Wake-On-Lan (Doesn't seem to wake the box, even when I've checked to make sure the power button made the box sleep and not perform a full shutdown) Tried-Unsuccessful
2. AutoCast to have the box cast to itself, but it doesn't have chromecast/miracast/etc built-in as far as I can tell according to the specs and see anything about cast ability while browsing through its menus.
3. Using Android's HDMI-CEC library in a Java Action in Tasker to imitate the CEC switch sources intent/activity. However, I just recently learned that Google decided to lockdown their API for HDMI-CEC interactivity, so that scrubs that idea.
4. The best bet, and what gave me the idea to post here, is this App Cast Receiver that was created by another user on these forums that seems to accomplish something close to what I'm trying to do in allowing an android device to imitate a chromecast device. If I were able to use this couldn't I then use the AutoCast app I mentioned above to have the Android Box cast to itself, then stop the AutoCast app a few seconds later (after giving the box's CEC capability enough time to make the tv switch sources)? But, unfortunately it appears the app has since been deserted and won't work with the newer chromecast sdk. Maybe someone has an alternative app?

Since this is my first Android Box I'm not quite sure how Tasker actions function when ran from the box. Example: Would a Wake Screen Action trigger a switch of HDMI inputs?

So, after exhausting all my ideas after coming up with nothing in my searches I figured I'd ask the community here since this seems to be a pretty dev/mod-heavy community (and I love it). I'm not sure if this would be better suited for the Tasker or AMLogic Android Box forums on here. If so, I'll happily move the post if a mod cannot do so for me.

TL;DR: Looking for some way, be it app or otherwise, to imitate chromecast behavior (utilizing CEC) in order to make tv switch source to a running Android Box's homescreen.
 
Last edited:

jlongman

New member
Mar 16, 2017
2
0
Hey! tell me more about 3, I was looking to have a Raspberry Pi act as a go-between to simulate CEC with a non-CEC TV by receiving my remotes IR codes and sending either CEC codes to the ChromeCast or using the CC API to pause/stop play - but only reverse engineered versions are available on Pi.

The Pi has built-in CEC support so you can use `apt-get install cec-tools` and then play with the `cec-client` to do some interesting stuff. The ChromeCast in my case has an invalid address so I don't seem to be able to activate pause play. (I see a logical address of 4 but also an address of `f.f.f.f`, ie invalid).

Anyways, it may be worth playing with a Pi and seeing if HDMI-CEC will do what you want, and then seeing if you can get a CEC library for android and just recreate the Pi work. Less hoops to jump around.

I don't know enough about the Android side. The CC API has an Android implementation so I would think you'd be able to do everything you want, iff it does the switching. I've done very little development on Android (a meteor app and an Android native camera library work), unfortunately. (If the Pine64 supports CEC I may end up going down this route).

I've posted more about my interest here: on reddit /r/Chromecast/comments/5znpuk/i_want_to_use_a_raspberry_pi_to_control_the/
 

caffeinatedmike

New member
Aug 16, 2016
4
0
Hey! tell me more about 3, I was looking to have a Raspberry Pi act as a go-between to simulate CEC with a non-CEC TV by receiving my remotes IR codes and sending either CEC codes to the ChromeCast or using the CC API to pause/stop play - but only reverse engineered versions are available on Pi.

The Pi has built-in CEC support so you can use `apt-get install cec-tools` and then play with the `cec-client` to do some interesting stuff. The ChromeCast in my case has an invalid address so I don't seem to be able to activate pause play. (I see a logical address of 4 but also an address of `f.f.f.f`, ie invalid).

Anyways, it may be worth playing with a Pi and seeing if HDMI-CEC will do what you want, and then seeing if you can get a CEC library for android and just recreate the Pi work. Less hoops to jump around.

I don't know enough about the Android side. The CC API has an Android implementation so I would think you'd be able to do everything you want, iff it does the switching. I've done very little development on Android (a meteor app and an Android native camera library work), unfortunately. (If the Pine64 supports CEC I may end up going down this route).

I've posted more about my interest here: on reddit /r/Chromecast/comments/5znpuk/i_want_to_use_a_raspberry_pi_to_control_the/

Here's the link to Android's documentation for the HDMI-CEC Control Service. But, like I said it's been locked down and only allows system-level access now.

I don't have any Pi at my disposal (plus my Android Box also has built-in CEC-capability/functionality) and since my situation doesn't actually involve chromecast I never thought to look at their api/sdk. But, I was able to finally solve my problem with a painfully simple, yet not that intuitive or logical method. The way my box's os/firmware appears to work is by firing the cec signal to switch inputs only on its boot_complete and wake_from_standby procedures. My solution just simulates pressing the Standby button twice in a row via Shell command (with Root option checked) from within Tasker. Logically, I thought after the first press the box wouldn't respond to the second press due to already being in standby mode (because of the first button press). But, it turns out both simulated presses occur (maybe keyevents are queue?), allowing me to put the box in standby momentarily and immediately bring it out of standby, which triggers the wake_from_standby procedure and in turn causes the input to switch (or my tv to turn on then input to switch).
 

jlongman

New member
Mar 16, 2017
2
0
My thought with the Pi and CC API was that you would use the PI to monitor the HDMI-CEC bus as the output is controlled by the CC - assuming it switches the input to itself but my TV doesn't support HDMI so maybe that's a bad assumption - and then use that knowledge to replay using the Android HDMI-CEC API. And not understanding what you meant by the API being locked down. That kind of sucks - I was hoping Android would be another bridge platform if the Pi failed me.

Well congrats on a working solution. Cheers!