It opens Plex properly, but then I get errors about HA not being able to contact the IP/port of the Plex client. I’ve tried sleeping a couple seconds, and using a wait template for the client state to be ‘idle’, but nothing is working.
Has anyone setup a script which is simply:
1 wake up Apple TV
1 open plex
1 play media to plex
You’ll likely need a step which forces a scan for newly available Plex clients. You can do this by using the new Plex button.scan_clients_* entity along with the button.press service.
You may also need to add a step after the scan to wait for the state of the Apple TV Plex client to change to a non-unavailable state before playing media. You may need to add a short delay between switching sources and scanning for the Plex client.
Thanks @jjlawren ! I actually had been trying that as well, with little luck. However, since you responded, I tried again, and simplified it. The following script seems to work 100% of the time so far:
Great, glad that’s working well. I can imagine a scenario where the Plex app takes longer to launch (after calling select_source) and the Plex client scan finishes before the app is ready to respond. If that happens you can extend the delay or perhaps use a retry loop for the scan/wait steps.
Hi, I haven’t messed with this much since this posting. Recently I’ve run the script below, and it seems to work. But I haven’t tested it a lot to see if it’s super reliable: