I’m at my wit’s end here. I swear I try something, get an error code, make a change, get a new error code, change back to exactly how it was the first time, and somehow get a third new error code. I am trying to play media from my plex server on a Chromecast device. I have the plex integration set up, to where I can go into that device in the media tab and see Plex, navigate through the menus, choose a file, and play it. The problem comes with trying to automate.
My Script:
'play_random_tv_episode':
alias: Play Random TV Episode
sequence:
- service: media_player.play_media
target:
entity_id: media_player.living_room_hub_max
data:
media_content_type: EPISODE
media_content_id: >-
plex://{"library_name": "TV Shows", "show_name": "Psych",
"shuffle": "1", "maxresults": "1"}
enqueue: replace
mode: single
My current error message is: “‘<’ not supported between instances of ‘str’ and ‘int’”. Absolutely no clue where that is coming from, the ‘<’ symbol doesn’t appear at all. Before that, I was getting errors of media player url is relative but does not start with a /". That error initially went away when I added the ‘plex://’ at the beginning of my media_content_id section, but has returned even with that string present.
The other error appears to be a JSON encoding error, telling me it expected a ‘:’ at Line 1, column 80, character 81, but I do not even begin to know where to troubleshoot that. The only line of the script that has 80 characters is the media_content_id section, but the 80/81 character are part of the TV show name, and it is not line 1.
I’ve looked through multiple instances of people giving their examples but I just keep getting more and more error codes. Any help would be greatly appreciated!
Edit if anyone stumbles across this: Apparently it was just due to a bug with 2023.12.0. None of my scripts worked, and when I updated HA my code began working as expected.