Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 107415

Help me figure out this Plex error!

$
0
0

I am working on a Halloween script that will play a random ghost video on my projector. I have 12 videos, so I’m setting a random number 1-12 to select the video and storing that in an input_text.

Using the script below, the video DOES play. But it also results in an error so the script will not progress further than playing the video, so the delay does not execute. If I remove the media_player task, the delay code does execute properly. Is there a better way I can/should write this? Any idea why I’m getting the error?

ghost_attack:
  mode: restart
  sequence:
     # Set a random value of 1-12, representing each of the 12 videos
    - service: input_text.set_value
      entity_id: input_text.halloween_ghost_video
      data_template:
        value: "{{ (range(1, 12) | random | int) }}"

    # Play selected video
    - service: media_player.play_media
      data_template:
        entity_id: media_player.plex_plex_for_android_nebula_projector
        media_content_type: VIDEO
        media_content_id: >
          {% set x = states.input_text.halloween_ghost_video.state | int %}
          {% if x == 1 %}
            { "library_name": "AtmosFearFX", "video_name": "Alien Ghost" }
          {% elif x == 2 %}
            { "library_name": "AtmosFearFX", "video_name": "Beckoning Beauty" }
          {% elif x == 3 %}
            { "library_name": "AtmosFearFX", "video_name": "Dancing Skeletons" }
          {% elif x == 4 %}
            { "library_name": "AtmosFearFX", "video_name": "Facade of Fright" }
          {% elif x == 5 %}
            { "library_name": "AtmosFearFX", "video_name": "Ghoulish Girl" }
          {% elif x == 6 %}
            { "library_name": "AtmosFearFX", "video_name": "Grim Reaper" }
          {% elif x == 7 %}
            { "library_name": "AtmosFearFX", "video_name": "Rising Skeletons" }
          {% elif x == 8 %}
            { "library_name": "AtmosFearFX", "video_name": "Skeleton Band" }
          {% elif x == 9 %}
            { "library_name": "AtmosFearFX", "video_name": "Spectral Surfaces" }
          {% elif x == 10 %}
            { "library_name": "AtmosFearFX", "video_name": "Unholy Hovering" }
          {% elif x == 11 %}
            { "library_name": "AtmosFearFX", "video_name": "Wicked Portal" }
          {% elif x == 12 %}
            { "library_name": "AtmosFearFX", "video_name": "Wraiths" }
          {% else %}
            { "library_name": "AtmosFearFX", "video_name": "Black Filler" }
          {% endif %}

    - delay: >-
        {% set x = states.input_text.halloween_ghost_video.state | int %}
        {% if x == 1 %}
          00:01:06
        {% elif x == 2 %}
          00:02:18
        {% elif x == 3 %}
          00:01:11
        {% elif x == 4 %}
          00:01:53
        {% elif x == 5 %}
          00:01:57
        {% elif x == 6 %}
          00:00:41
        {% elif x == 7 %}
          00:00:45
        {% elif x == 8 %}
          00:01:46
        {% elif x == 9 %}
          00:02:22
        {% elif x == 10 %}
          00:00:58
        {% elif x == 11 %}
          00:00:35
        {% elif x == 12 %}
          00:01:07
        {% else %}
          00:01:30
        {% endif %}

Log Details (ERROR)
Logger: homeassistant
Source: components/plex/media_player.py:588
First occurred: 2:23:40 PM (1 occurrences)
Last logged: 2:23:40 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/local/lib/python3.8/xml/etree/ElementTree.py”, line 1693, in feed
self.parser.Parse(data, 0)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 790, in async_run
await asyncio.shield(run.async_run())
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 565, in async_run
await super().async_run()
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 185, in async_run
await self._async_step(log_exceptions=False)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 193, in _async_step
await getattr(
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 382, in _async_call_service_step
await service_task
File “/usr/src/homeassistant/homeassistant/core.py”, line 1281, in async_call
task.result()
File “/usr/src/homeassistant/homeassistant/core.py”, line 1316, in _execute_service
await handler.func(service_call)
File “/usr/src/homeassistant/homeassistant/helpers/entity_component.py”, line 208, in handle_service
await self.hass.helpers.service.entity_service_call(
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 454, in entity_service_call
future.result() # pop exception if have
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 595, in async_request_call
await coro
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 485, in _handle_entity_call
await result
File “/usr/src/homeassistant/homeassistant/components/media_player/init.py”, line 603, in async_play_media
await self.hass.async_add_job(
File “/usr/local/lib/python3.8/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/plex/media_player.py”, line 588, in play_media
self.device.playMedia(playqueue)
File “/usr/local/lib/python3.8/site-packages/plexapi/client.py”, line 490, in playMedia
self.sendCommand(‘playback/playMedia’, **dict({
File “/usr/local/lib/python3.8/site-packages/plexapi/client.py”, line 208, in sendCommand
return query(key, headers=headers)
File “/usr/local/lib/python3.8/site-packages/plexapi/client.py”, line 171, in query
return ElementTree.fromstring(data) if data.strip() else None
File “/usr/local/lib/python3.8/xml/etree/ElementTree.py”, line 1320, in XML
parser.feed(text)
File “/usr/local/lib/python3.8/xml/etree/ElementTree.py”, line 1695, in feed
self._raiseerror(v)
File “/usr/local/lib/python3.8/xml/etree/ElementTree.py”, line 1602, in _raiseerror
raise err
File “”, line None
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 107415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>