Openhab2 on Rpi3, call external android app

Hi,
is it possible to call from OH2 a local external app (Samsung TV control) and after closing of app back to OH ?

I assume you are talking about apps on a phone? If so the answer is no.

If you are talking about calling external programs or scripts on your OH host, then yes you can using the Exec binding or executeCommandLine.

Thank’s Rich,
I suspected that…

I would like to launch apps on my Android TV (MiBox) from OH as well.
So far I’ve side loaded Tasker and tried to set up AutoRemote. But that didn’t work - AutoRemote can’t obtain an URL for messaging.

My plan was to send HTTP requests from OH to the URL given by AutoRemote, and then my MiBox would react on them with Tasker.

But as I said, I couldn’t figure out how to push this forward.

On the other hand, I’ve seen that you can launch other Android apps from Kodi. There’s a list of other apps on my Kodi home screen (YouTube, Netflix etc).
Maybe Kodi binding would allow me to automate it? @cweitkamp do you think that’s possible?

Cheers

Can you run Notify My Android on Android TV? There is a Tasker 3rd party that can receive and parse NMA messages. That may get you there.

Yes, that is possible. You can launch other Android Apps from Kodi. This feature is restricted to the Kodi Android App. It is not possible to launch external Android Apps from Linux, Windows or IOS installations (e.g. on a RPi).

I assume, it is. But we have to test it in detail. The Kodi API provides an Addons section especially a method to execute addons (see http://kodi.wiki/view/JSON-RPC_API/v8#Addons. Maybe we can access Android Apps on the same device with the interface es well.

I propose trying to use a curl request for calling the Kodi API to execute those commands. I am not sure if it’s worth integrating it into the binding. Wdyt?

If we know the addonid - see method Addons.GetAddons - the call should look like this:

curl -su <USER>:<PASSWORD> -H "Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"<ADDONID>"},"id":1}' http://<IP>:8080/jsonrpc

Please be aware of typos. I wrote it down w/o testing.

1 Like

Thanks @cweitkamp!

I’ve run the following command to get list of all Add-ons:

curl -H "Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"Addons.GetAddons","params":["unknown","unknown",true,["name"]] ,"id":1}' http://192.168.0.XXX:8080/jsonrpc

But no Android apps there whatsoever - just the addons that are installed in Kodi. Maybe their API doesn’t expose it?

I’ll do some more research. There has to be a way :slight_smile:

Have you @kubawolanin looked at https://community.openhab.org/t/sony-devices-binding/? Popped to my mind when you mentioned Android TV.

You are welcome.

Too bad that it doesn’t work at first attempt. I’m pretty sure you somehow find a solution. I will do a little research on myself. You touched me with that idea - never thought about installing the Kodi App on my Android tablet before but now I did.

Keep you posted.

1 Like

One step forward :sunglasses: but not the “easy” goal we want to reach :wink:.

It is possible to fetch a list of all android apps:

curl -su <USER>:<PASSWORD> -H "Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"androidapp://sources/apps/"},"id":1}' http://<IP>:8080/jsonrpc

And it is possible to open the subsection for android apps:

curl -su <USER>:<PASSWORD> -H "Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"GUI.ActivateWindow","params":{"window":"programs","parameters":["androidapp://sources/apps/"]},"id":1}' http://<IP>:8080/jsonrpc

I tried to open one of my android apps by using the value exposed as “file” from the first request but unfortunately the app did not start. It only gets selected in the subsection :thinking::

curl -su <USER>:<PASSWORD> -H "Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"GUI.ActivateWindow","params":{"window":"programs","parameters":["androidapp://sources/apps/com.android.chrome"]},"id":1}' http://<IP>:8080/jsonrpc

We now can send an “Input.Select” command to start the android app. We have to send this request twice :sweat_smile::

curl -su <USER>:<PASSWORD> -H "Content-type: application/json" -X POST -d '{"jsonrpc":"2.0","method":"Input.Select","id":1}' http://<IP>:8080/jsonrpc

According to these two posts in the Kodi forum (https://forum.kodi.tv/showthread.php?tid=260686, https://forum.kodi.tv/showthread.php?tid=235521) it is actually not possible to start android apps through JSON-RPC.

Happy testing :sunglasses:.

1 Like