[SOLVED] Lovelace: Launch local Android app in Fully Kiosk Browser?

UPDATE JUNE 2020: This thread is outdated. Instead, follow this guide:

Original post:

I’m planning to use Lovelace to make a dashboard using an Android tablet using Fully Kiosk Browser. That will replace my current method of a bunch of Tasker-connected Android home screen widgets to perform specific HA tasks like turning switches on/off. Importantly for this question, I also use the Sonos widget on the homescreen. We often use the Sonos widget to launch the Sonos app.

I’d like to include a Lovelace media player card that has a button to launch the Sonos app. I can think of a few ways to achieve opening of the Sonos app by going back through the HA server. But, I’d like to keep everything local to the tablet if possible.

Fully Kiosk Browser has two local methods (It think) of launch a app from a web page Fully Kiosk Browser Lockdown | Android Kiosk Mode App, an Android intent or a JavaScript call.

Is there a way to invoke one of those two methods on a button tap without the roundtrip through the HA server.

Thanks!

3 Likes

If you want to invoke it locally, javascript is your only option, and that still has to be hosted on the server.

In your position, I’d probably look at the REST interface (https://www.ozerov.de/fully-kiosk-browser/#rest), and specifically the command called startApplication.

Thanks, @thomasloven. I could only think of server-side solutions myself, so you’re helping to confirm my fear. It may not actually be a problem, but my main concern is latency introduced by more moving parts and the roundtrip through the server. I wonder if it will seem like too long between pressing a button and the app opening. I’ll try REST and see how that performs.

Now that I think about it, it might be possible to trigger the javascript thing via a weblink or similar. I’m not fluent enough in javascript to figure out how, though.

With a bit of trial and error of the formatting of the URL, it turns out that you can launch an Android app from the HA frontend in Fully Kiosk Browser with an Android intent. This https://developer.chrome.com/multidevice/android/intents implies that it should work in Chrome for Android, as well, but I couldn’t make it work.

This works in Fully Kiosk Browser to launch Sonos, for example:

   weblink:
     entities:
      - name: Sonos
        url: intent://sonos/#Intent;launchFlags=0x10000000;component=com.sonos.acr/.SonosLaunchActivity;end
        icon: mdi:speaker
2 Likes

I got an old Android tablet as well. Sadfully, stone age 4.0x.
Because of this I took MQTT Dash as my tool of choice…HA with Node-RED.

Anyways, perhaps you can place a pure URL in your frontend and start a tasker task by a plugin called “Tasker URL launcher”. I don’t know why, but it has been kicked out the playstore.

Another option could be using Autotools by Autoapps, which has a WebView builtin, with JS injection (not sure).

I ended up with: AutoVoice by AutoApps to send my spoken text to Snips.ai via MQTT, which parses my text and control HA as result :slight_smile:

Thanks, @letsoulfly.

I was actually doing something similar in my old set-up with Domoticz. I was using a combination of Google Assistant connected dummy switches with MQTT to trigger Tasker tasks. It worked quite well, but I’m trying to cut down on the “moving parts” so that there are fewer points of failure.

1 Like

does this launch on the device that sent the request or can i use my phone and it will open on the tablet that fully is running on remotely ?

@yes13q Are you talking about the Android app launch? If so, that’s on the local device you’re interacting with. For the voice examples, there’s no frontend device involved. It’s all on the server and in the cloud.

How did you figure out the URL to launch the Sonos app? I’d like to do the same with the Spotify app, but not sure if I just replace sonos.acr with spotify.acr, .SonosLaunchActivity with .SpotifyLaunchActivity, etc.

For Spotify, use:

url: intent:#Intent;launchFlags=0x10000000;component=com.spotify.music/.MainActivity;end

Here’s a good write-up of how to find intents for various apps:
https://support.actiontiles.com/communities/12/topics/1255-open-android-app-or-app-activity-via-url-formatted-shortcut

There doesn’t appear to be much of a pattern which would help in guessing.

1 Like

What is weird is that I tried setting up the weblink component in configuration.yaml using the two examples you gave, but Home Assistant failed to setup the component. I tried with the config below:

weblink:
  entities:
    - name: Spotify
      url: intent://#Intent;launchFlags=0x10000000;component=com.spotify.music/.MainActivity;end
      icon: mdi:spotify   

and I also tried with the one below, but both created errors for me.

url: intent:#Intent;launchFlags=0x10000000;component=com.spotify.music/.MainActivity;end

I would look into it more but rebooting my HA instance takes too long, haha.

That’s strange. I have the following in configuration.yaml which always works without errors.

weblink:
  entities:
    - name: Sonos
      url: intent://sonos/#Intent;launchFlags=0x10000000;component=com.sonos.acr/.SonosLaunchActivity;end
      icon: mdi:speaker
    - name: Calendar
      url: intent://calendar/#Intent;launchFlags=0x10000000;component=com.google.android.calendar/com.android.calendar.AllInOneActivity;end
      icon: mdi:calendar

Does a simple link to just a web page like the one below work for you?

weblink:
  entities:
    - name: BBC
      url: http://www.bbc.co.uk

The BBC weblink works using Chrome and my Fire HD8, but Calendar doesn’t work, though I have the app installed. It is probably an Amazon Fire tablet issue.

Hello.
I am using the same technic as described here to launch spotify on my tablet from fully kiosk. It works great. I have a small problem however. The weblink from lovelace always open a new blank tab in fully kiosk. As anyone found a way to avoid that ? It s not very user friendly to have to close the blank tab each time :wink:

I don’t think you can avoid a new tab being opened using an intent. However, using Fully Kiosk’s REST API as originally suggested by @thomasloven in this thread does not open another tab. It’s a bit more work, though.

The REST command format for launching an app is:

http://ip-address:2323/?cmd=startApplication&package=[pkg]&password=[pass]

[pkg] refers to the Android package name. Some package name examples:

  • Sonos - com.sonos.acr
  • Spotify - com.spotify.music
  • Tado - com.tado
  • Google Maps - com.google.android.gm

To find the package name of an installed app, go to Settings/Universal Launcher/Select Items to Show/Add Application in Fully Kiosk. You’ll see a list of installed apps with the package name underneath each.

To enable the REST API in Fully Kiosk go to Settings/Remote Administration (PLUS):

  1. Turn on Enable Remote Administration
  2. Set a Remote Admin Password - Use your password in place of [pass] in the url above. Do not include the brackets.
  3. Turn on Remote Admin from Local Network - Note the IP address. It goes in place of ip-address in the URL above. (You’ll probably want to set a that as a static IP on your router.)

EXAMPLE: Launch Spotify

Edit configuration.yaml:

rest_command:
  launch_spotify_on_android_tab:
    url: http://192.168.xx.xx:2323/?cmd=startApplication&package=com.spotify.music&password=YourPassword
    method: POST

script:
  spotify_app:
    sequence:
       - service: rest_command.launch_spotify_on_android_tab

Add a Lovelace button using the frontend UI or raw config editor:

type: entity-button
name: Spotify
icon: 'mdi:speaker'
tap_action:
  action: call-service
  service: script.turn_on
  service_data:
    entity_id: script.spotify_app
entity: script.spotify_app
hold_action:
  action: none
6 Likes

Thanks a lot for the detailed answer. I’ll do that :slight_smile:

1 Like

Thanks that’s working great, is there a way to pass the ip of the calling device as a parameter, as i have 3 of wall mounted kiosks, and want to know which one called the service, or perhaps having 3 ui conditional elements for each kiosk and only show 1 per device but i dont know hiw to implement this. Any advice?

I don’t think that you can pass parameters such as the IP address directly, but there are other ways that you can differentiate among more than one tablet.

I have two tablets. I handle them as follows:

  1. Create two Lovelace tabs, one for each tablet with different script entity_ids in the launch buttons on each, e.g. on one tablet the action looks like this:
tap_action:
  action: call-service
  service: script.turn_on
  service_data:
    entity_id: script.call_spotify_topfloortab_launch

And on the other tablet a different entity_id in the action, e.g.,

entity_id: script.call_spotify_diningroomtab_launch

  1. Control which tab is available on which tablet using Compact Custom Header: CCH.

  2. Create two separate scripts and rest commands that correspond to each tablet. For example, the script for one tablet:

  alias: "Launch Sonos app on DININGROOMTAB" 
  sequence:
    - service: rest_command.sonos_diningroomtab_launch

and the corresponding rest command:

sonos_topfloortab_launch:
  url: http://192.168.xxx.xxx:2323/?cmd=startApplication&package=com.sonos.acr&password=xxxxxxxxx
  method: POST

and on the other tablet:

  alias: "Launch Sonos app on TOPFLOORTAB" 
  sequence:
    - service: rest_command.sonos_topfloortab_launch

and

sonos_topfloortab_launch:
  url: http://192.168.xxx.xxx:2323/?cmd=startApplication&package=com.sonos.acr&password=xxxxxxxxx
  method: POST

You could reduce the duplication using templates and perhaps conditional cards, but this works. I haven’t gotten around to making it more elegant.

How do you differentiate with CCH the 2 tablets are they using different users? Or you can query ip/mac ?