Play a series/movie and enable scene

I am searching for the following solution :slight_smile:

I have an Nvidia Shield media player, with Plex on it. And a plex server running at home.
In my library I have some series and some movies and I would like to play them with an automation.

Let’s say I want to watch a certain series, so an automation starts running which looks up the series, and plays the next episode automatically.

Even better would be if I could tell Google home which series I want to watch, and it would be completely automatic. But that’s the ultimate goal.

Is it a shot in the dark, or did you already try:

A, will play a little bit with that one :slight_smile:

So that worked, but I get a error when I try to play from the library:


Logger: homeassistant.components.websocket_api.http.connection
Source: components/plex/media_player.py:487 
Integration: Home Assistant WebSocket API (documentation, issues) 
First occurred: 10:27:15 (8 occurrences) 
Last logged: 10:35:48

[140260817148928] Client is not currently accepting playback controls: Plex (Plex for Android (TV) - SHIELD Android TV)
[140260810631120] Client is not currently accepting playback controls: Plex (Plex for Android (TV) - SHIELD Android TV)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 199, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1849, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1889, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 226, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 798, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 981, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 838, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 789, in async_play_media
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/plex/media_player.py", line 487, in play_media
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Client is not currently accepting playback controls: Plex (Plex for Android (TV) - SHIELD Android TV)

@marcel1988 May I see your YAML code for the automation? I’m struggling too.

i dont use a YAML code.

I use the media browser of the integration. Then i get this error in the logs.

Got mine working :slightly_smiling_face:

target:
  entity_id: media_player.plex_plex_for_android_tv_shield_android_tv
data:
  media_content_type: EPISODE
  media_content_id: >-
    { "library_name": "TV Programs", "show_name": "House", "episode.unwatched":
    true, "episode.inProgress": [true, false], "resume": 1, "sort":
    "addedAt:asc", "maxresults": 1 }```

@matthew1
Nope, still no luck here.

When i do this:

service: media_player.play_media
target:
  entity_id: media_player.plex_plex_for_android_tv_shield_android_tv
data:
  media_content_type: EPISODE
  media_content_id: >-
    { "library_name": "Tv-series", "show_name": "The Good Doctor", "episode.unwatched":
    true, "episode.inProgress": [true, false], "resume": 1, "sort":
    "addedAt:asc", "maxresults": 1 }```

Nothing happens.
I also see that my Plex client is inactive. (It is only going active when i play something manual on the plex client.

@matthew1
Any update? :slight_smile:

does it work if you already have plex open on the Shield?

No, even then i get the same error message.
When i dont have plex open, the only thing that i see is that the Plex client is unavailable.

Can you tell me how you are running Plex server en on wich device are you playing the media files?

Weird, Synology 918+ with Plex installed natively. I play files on Phillips TV and Nvidia Shield, both with Android TV.

@matthew1 is your client inactive? or is it active?

And what about port forwarding? Did you do any of that? Because my ports are all closed.

Oddly i just want to test mine again and nothing - no response at all. I ended up rebooting the TV and now it’s working again. I seem to have to do that a lot at the moment, can you rebooting your Android TV device?

@matthew1

I have tested it on several devices:

2x Nvidia Shield
2x Windows pc’s
1X Linux ubuntu device.

I already have setup Plex server on:
Windows system
Linux System
Synology system

I’m really out of ideas at the moment :frowning:

@matthew1

I have installed Plex HTPC for windows, and that works like a charm without any problems i can select my own media from the Media Browser in Home Assistant.

But when i do it to the Nvidia Shield Plex client i get that error message.

@matthew1

i got it to work to play a movie or serie on the Shield.
But it seems that it picks randomly a episode. :thinking:

Ah yes i had the same problem, finally sorted it last night with a different sort filter.

service: media_player.play_media
data:
  media_content_type: EPISODE
  media_content_id: >-
    { "library_name": "TV Programs", "show_name": "James Martin's Saturday
    Morning", "episode.unwatched": true, "episode.inProgress": [true, false],
    "resume": 1, "sort": "originallyAvailableAt:asc", "maxresults": 1 }
enabled: true
target:
  entity_id: media_player.plex_plex_for_android_tv_5g

How did you get it working in the end?

@matthew1

I figured something out, but i dont understand :rofl:
I have 3x a Nvidia Shield in my house.
Living room = 2019 pro model
Bedroom = 2015 model
Bedroom son = 2015 model.

Both the 2015 models play instant the media without any error en without becomming unavailable.
The 2019 pro model will not work. i have checked the settings on the network side and those are all the same.

Wich model of the Nvidia shield do you have?

I bought mine in 2017 so guessing it not a 2019! Amazon say the model number was ‎L380287. So looks like the issue is only with the 2019 then?

Did you get the play order sorted?