Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new apps and source selection #223

Closed
apaperclip opened this issue Dec 1, 2020 · 14 comments
Closed

new apps and source selection #223

apaperclip opened this issue Dec 1, 2020 · 14 comments

Comments

@apaperclip
Copy link
Contributor

Two questions for you.

  1. I have a branch ready to go that adds app entries for youtube tv and the new google tv launcher. Should I do the the pull request to dev or master?

  2. Regarding https://community.home-assistant.io/t/firetv-app-not-opening-when-selecting-source/160091/2 Would it make sense to add this additional information to the constants? I'm digging into to see how HA launches the apps.

@JeffLIrion
Copy link
Owner

  1. master, please.
  2. HA launches apps via the launch_app method. It doesn't work for some apps, though. There's an issue about it: Select source wont work on firetv #40. But the simple solution is to figure out the right shell command to use and call the androidtv.adb_command service. Unless I'm misunderstanding your suggestion, adding constants won't help.

async def launch_app(self, app):
"""Launch an app.
Parameters
----------
app : str
The ID of the app that will be launched
"""
await self._adb.shell(constants.CMD_LAUNCH_APP.format(app) if not self._is_google_tv else constants.CMD_LAUNCH_APP_GOOGLE_TV.format(app))

@apaperclip
Copy link
Contributor Author

  1. Thanks! glad I asked! I was ready to push to dev then I saw some other pulls using master.

  2. That's what I've done as well, it's a nice flexible ability.. I'm still a novice at this so I likely don't have all the details but my general thought was to either create or update the dict in the constants to include the launch intent. If HA is using the constants to name<>id, could it also pull another value that is launch intent and use that for source changes?

I really like how you've given the user flexibility to define their own detection rules, app names, and send events. This approach could also be used to self-service define launch intents.

@JeffLIrion
Copy link
Owner

Regarding the second point, yes, adding a "start intent" field to the APPS dictionary would be the way to achieve that. The problems are:

  1. Enabling users to configure this is kinda messy (not that custom state detection is simple!) and adding YAML configuration entries is no longer allowed.
  2. If it were all handled in this package, I don't know whether a command that works for one person's device would work on everyone else's.

@apaperclip
Copy link
Contributor Author

Thank you for taking the time to reply. Great points.

Perhaps if you have config flow in your future there could be some more UX friendly ways to provide it while offering flexibility.

Also thanks for the , fix on the pr and for merging!

@JeffLIrion
Copy link
Owner

I think most people make Lovelace remotes/buttons for their Android TV device so that they can launch, say, Netflix by pushing a button that calls the appropriate service (media_player.select_source or androidtv.adb_command). Allowing such users to customize the command used by the media_player.select_source service adds complexity -- for both the integration development and the user configuration -- without impacting the UX for these users.

I don't plan to add config flow to the Android TV integration, for several reasons:

  • I've never worked with config flow before.
  • Beyond the basic host + name configuration, there are a lot of config options and some of them would be difficult to implement in a config flow.
  • I like YAML.

That said, it would be great if someone wants to implement config flow for the integration. But I hope that they would support YAML, too!

@larena1
Copy link

larena1 commented Dec 27, 2020

I think I'm having an issue related to this. I logged the commands to switch to the HDMI inputs on my TV but currently there seems to be no way to add them to the source list where they'd obviously belong.

@JeffLIrion
Copy link
Owner

I think I'm having an issue related to this. I logged the commands to switch to the HDMI inputs on my TV but currently there seems to be no way to add them to the source list where they'd obviously belong.

The sources list in Home Assistant only includes the running apps.

@larena1
Copy link

larena1 commented Dec 27, 2020

The sources list in Home Assistant only includes the running apps.

You got my point. HDMI or other inputs should be sources too.

@JeffLIrion
Copy link
Owner

HDMI or other inputs should be sources too.

This package has all the necessary functionality to support that in the Home Assistant integration, at least as I envision that would be implemented.

The main thing that the Home Assistant integration needs is config flow. There was a pull request that allowed for listing all apps in the sources list instead of the running apps, but that was rejected because adding YAML configuration entries is no longer allowed.

Allowing users to include HDMI inputs in the sources menu is basically the same as the idea discussed above of allowing users to specify the command used to launch an app in the apps: configuration dictionary. But again, that requires config flow before those changes could be made.

One thing that would need to be decided upon is, if the HDMI input is "HDMI-1" and the current app is, say, Netflix, what should be shown as the source: Netflix or HDMI-1?

You could probably achieve a lot of this already using a universal media player, which you said you're already doing in a separate issue: #216

@larena1
Copy link

larena1 commented Dec 27, 2020

One thing that would need to be decided upon is, if the HDMI input is "HDMI-1" and the current app is, say, Netflix, what should be shown as the source: Netflix or HDMI-1?

I think that case can never happen because HDMI input is an app on its own. In my case it is com.mediatek.wwtv.tvcenter

You could probably achieve a lot of this already using a universal media player, which you said you're already doing in a separate issue: #216

Not really. With a lot of fiddling you could maybe manage to get a proper sources list but the select source service call can't be implemented with ump.

@JeffLIrion
Copy link
Owner

I think that case can never happen because HDMI input is an app on its own. In my case it is com.mediatek.wwtv.tvcenter

In that case, it should show up as the current app.

Not really. With a lot of fiddling you could maybe manage to get a proper sources list but the select source service call can't be implemented with ump.

I think the documentation is incomplete. select_source is used in some of the examples. https://www.home-assistant.io/integrations/universal/#chromecast--kodi-control-with-switches

@larena1
Copy link

larena1 commented Dec 28, 2020

I think that case can never happen because HDMI input is an app on its own. In my case it is com.mediatek.wwtv.tvcenter

In that case, it should show up as the current app.

It does but it requires a custom command with the desired HDMI input number.

Not really. With a lot of fiddling you could maybe manage to get a proper sources list but the select source service call can't be implemented with ump.

I think the documentation is incomplete. select_source is used in some of the examples. https://www.home-assistant.io/integrations/universal/#chromecast--kodi-control-with-switches

I'd want to keep the app sources and add the HDMI inputs as additional sources. But then there's no way to either call set source or adb command (for HDMI). It can only be one or the other.

@JeffLIrion
Copy link
Owner

I think this will work...

Make input_select.media_player_sources with the sources you want. In the UMP configuration, use:

commands:
  select_source:
    service: python_script.select_source
    data:
      source: '{{ source }}'
attributes:
  source_list: "input_select.media_player_sources|options"

Make a python_script.select_source that calls the appropriate service for the selected source. You could use a regular script but I think a python_script would be easier.

@larena1
Copy link

larena1 commented Dec 29, 2020

Too much fiddling and it'd also need another template to display current source (app or HDMI). Guess I'd rather modify the component as to my needs but for now I've just made 3 scripts for HDMI 1-3.

Thanks for your support though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants