Nvidia Shield - start an app from HASS

I want to use my home harmony remote to be able to start a specific application (netflix/plex/you tube) on my nvidia shield. It’s not as easy as I thought it would be, so I thought I’d share the process!

Prereq:
Ensure you have mosquitto installed and configured (you also obviously need HASS and a shield!) I talk about integrating with harmony, but you don’t have to do this bit - it’s just what I use to trigger the automatioin.

Part 1:
The first part is getting it so the harmony remote can actually interact with Home Assistant. Thankfully a chapp called Marton has does the hard part with his home assistant roku emulator: https://gitlab.com/mindig.marton/ha-emulated_roku/. Simply add this, configure it and you can add the fake roku to the harmony.

Part 2:
Now I need to be able to actually start the applicaiton on the shield. For this I had to install Tasker (https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm&hl=en_GB). There are many experts for this complex app, so please don’t take what I’m saying as the right way to do it… but it did work for me.

To get started you will need to install this on your shield. This can be done from the google play website, but to launch it you will need to install the sideload launcher (https://play.google.com/store/apps/details?id=eu.chainfire.tv.sideloadlauncher&hl=en). You might want to have a mouse plugged into your shield too.

With tasker launched go to tasks and create one called Netflix. In there you should be able to add a task to launch netflix (you can pick netflix from the list of apps), Check that running the task start netflix!

Now you need to get an app called mqttclient (https://play.google.com/store/apps/details?id=in.dc297.mqttclpro&hl=en). This one you have to side load. I’d follow a guide for this, but you basically use a file explorer to grab the apk and install it.

With that installed, open it using the sideload launcher and add your mosquitto broker. Subscribe to a topic, and veirfy it can recieve a message.

Now go back to tasker and on profiles add in an event from a plugin. Select mqtt client. In the new window enter variable names for the topic and message, but in the section for message eq type in “netflix”. Save this and go back to the shield home screen

Now sent “netflix” to the topic from mosquitto and it should launch on your shield!

Step 3:
The automation should be very simple from here. You can see mine here: https://github.com/rossdargan/hass-config/blob/master/configuration/automation/roku.yaml#L131

It basically looks like this:

  • id: turn_on_netflix
    initial_state: ‘on’
    alias: Turn on netflix
    trigger:
    • platform: event
      event_type: roku_command
      event_data:
      type: keypress
      key: Home
      action:
    • service: media_player.select_source
      entity_id: ‘media_player.yamaha_reciever’
      data:
      source: “HDMI6”
    • service: mqtt.publish
      data:
      topic: ‘tv’
      payload: ‘netflix’

So when I press the “home” button on the fake roku it will switch my av reciever onto the correct source, and will launch netflix!

Please note I’ve written this from memory so it you have any issues let me know and I’ll look up the exact steps!

10 Likes

Hey thanks for this idea. I’ve used it to add buttons to the living room HADashboard android tablet/remote. I also installed tasker and mqtt client on the tablet to launch Yatse for Kodi/Plex and Google Play Music for chromecast. Yatse supports actions via yatse:// urls so I can load the right remotes for kodi and plex.

1 Like

Hi, Thanks for this guide. I tried to set it up, but I get the following message:

1522880278: Socket error on client , disconnecting.
1522880286: New connection from xx.xxx.xx.xxx on port 1883.
1522880286: Client Test disconnected.
1522880286: New client connected from xx.xxx.xx.xxx as Test (c0, k1200, u’homeassistant’).
1522880286: New connection from xx.xxx.xx.xxx on port 1883.
1522880286: Client Test already connected, closing old connection.
1522880286: Client Test disconnected.

So mqtt is reconnecting every time, and therefore restarting netflix every time.

I also get this message in the home-assistant log:

ERROR (SyncWorker_13) [homeassistant.core] Error doing job: Task was destroyed but it is pending!

The clue is in the error message :slight_smile:

Client Test already connected, closing old connection.

Change your client name to something else and it will work fine.

already tried that, then I get the same message with the new client name.

EDIT: I don’t know what I did differently, but gave it a go again a few weeks later, and it works now!

Set this up and it works awesome for launching Netflix, Plex, and HDHomeRun. Amazon Video doesn’t show up in Tasker’s list of Apps to launch – has anyone got it working for launching Amazon Video? I’m thinking it can be done with an intent.

Great stuff, thank you!