❱ Plex Assistant

Thanks, it returned this …

<MediaContainer size="1">
<Server name="Chrome" host="192.168.0.10" address="192.168.0.10" port="32400" machineIdentifier="xxxxxxxxxxxxxxxxxxxxxxxxx" version="4.30.2" protocol="plex" product="Plex Web" deviceClass="pc" protocolVersion="3" protocolCapabilities="timeline,playback,navigation,mirror,playqueues"/>
</MediaContainer>

Let’s see if it turns up in HA :slight_smile:

@vulcanjedi Just remembered someone posted a similar issue before and checked on it, turns out it’s the exact same error found here. Make sure you’re using the latest version and maybe give a reinstall just in case.

I don’t know what sorted it, I restarted the Plex server, HASSIO and uninstalled/reinstall Plex Assistant, then ask google to update sensor, now it probably works (can’t test now, the missus is watching TV), it does show up in the sensor.plex_assistant_devices

Thanks, @mayker

thanks @mayker
I use the HomeAsssitant core via docker.
I just went to config and manually made the dirs. but git cloned so would hope the latest.
is there a better way to install?
shoudl it be /config/custom_components/plex_assistant

 ls  custom_components/plex_assistant/
helpers.py  __init__.py  localize.py  manifest.json  process_speech.py  __pycache__  sensor.py  services.yaml

Nah, that should be fine. Delete the __pycache__ folder just in case, it will appear again on next restart.

So if I use git clone:
it creates plex_assistant/custom_components/plex_assistant
To get the component to work i have to move the files to /config/custom_components/plex_assistant
but I still get the previous errors when trying to run a command from Google device…unless my IFTTT applet isn’t configured properly?
Configuration check passes. No errors in notification.
Sensor is working.
This doesnt work from the Google voice devices / dev tools

command: Play Batman on Living Room Chromecast
cast_delay: 7
Logger: homeassistant.components.automation
Source: custom_components/plex_assistant/helpers.py:42
Integration: Automation (documentation, issues)
First occurred: 4:26:07 PM (1 occurrences)
Last logged: 4:26:07 PM

Plex Assistant Automation: Error executing script. Unexpected error for call_service at pos 1: generator raised StopIteration
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/fuzzywuzzy/process.py", line 93, in extractWithoutOrder
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 153, in _async_step
    self, f"_async_{cv.determine_script_action(self._action)}_step"
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 656, in _async_call_service_step
    *self._prep_call_service_step(), blocking=True, context=self._context
  File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1299, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/plex_assistant/__init__.py", line 127, in handle_input
    command = process_speech(command_string, localize, default_cast, PA)
  File "/config/custom_components/plex_assistant/process_speech.py", line 25, in process_speech
    fuzz_client = fuzzy(control_check, devices)
  File "/config/custom_components/plex_assistant/helpers.py", line 42, in fuzzy
    return fw.extractOne(media, lib, scorer=scorer)
  File "/usr/local/lib/python3.7/site-packages/fuzzywuzzy/process.py", line 245, in extractOne
    return max(best_list, key=lambda i: i[1])
RuntimeError: generator raised StopIteration

/config/custom_components/plex_assistant is the correct folder, you are installing correctly.

Try adding a logger service to tell us what Plex Assistant is receiving. Replace your plex assistant automation with the one below. This will add the command it receives to your HA log.

  - alias: Plex Assistant Automation
    trigger:
    - event_data:
        action: call_service
      event_type: ifttt_webhook_received
      platform: event
    condition:
      condition: template
      value_template: "{{ trigger.event.data.service == 'plex_assistant.command' }}"
    action:
    - data_template:
        command: "{{ trigger.event.data.command }}"
      service_template: '{{ trigger.event.data.service }}'
    - service: system_log.write
      data_template:
        message: "{{ trigger.event.data.command }}"
        level: warning

Oh, that’s interesting. Same error?

Yes I believe so sir.
I will update the automation w/ the logger as you suggested.
Updated automation with the before mentioned.
Rebooted Hass instance

2020-07-13 17:10:15 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140194467126416] Received {'type': 'call_service', 'domain': 'plex_assistant', 'service': 'command', 'service_data': {'command': 'Play Batman on Living Room Chromecast', 'cast_delay': 7}, 'id': 42}
2020-07-13 17:10:15 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=plex_assistant, service=command, service_data=command=Play Batman on Living Room Chromecast, cast_delay=7>
Logger: homeassistant.components.websocket_api.http.connection.140194467126416
Source: custom_components/plex_assistant/helpers.py:42
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 5:08:49 PM (2 occurrences)
Last logged: 5:10:20 PM

generator raised StopIteration
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/fuzzywuzzy/process.py", line 93, in extractWithoutOrder
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1299, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/plex_assistant/__init__.py", line 127, in handle_input
    command = process_speech(command_string, localize, default_cast, PA)
  File "/config/custom_components/plex_assistant/process_speech.py", line 25, in process_speech
    fuzz_client = fuzzy(control_check, devices)
  File "/config/custom_components/plex_assistant/helpers.py", line 42, in fuzzy
    return fw.extractOne(media, lib, scorer=scorer)
  File "/usr/local/lib/python3.7/site-packages/fuzzywuzzy/process.py", line 245, in extractOne
    return max(best_list, key=lambda i: i[1])
RuntimeError: generator raised StopIteration

Weird when I added an alias it stopped throwing errors.
Plex will instantiate you can see the correct movie loading on the info bar but hen it flickers to other stuff and then just spins saying Playing Plex and then hangs/dies.

Greetings,

Sorry if this is something that has already been asked before:

I got plex_assistant running on homeassistant and I am using ifttt. The server is trying to play on a Chromecast Ultra hooked up to my network.

When I give it a command, the screen turns grey as expected, the title of whatever I asked for flashes and then it stays grey.

What could I be doing wrong?

Adjust your cast delay

I’ve been using the default cast delay. What would you recommend I change it to?

From the link above:

"The amount of delay needed is typically the time it takes from when the screen turns black after calling the service to when you see the show info on screen."

It also mentions how you can test the delay to make sure it’s working. Depending on the device, network speed, etc it could be anywhere between 0-10 seconds.

Is there a method for setting a universal cast delay? Like, if I want all cast devices to run on a 10 second delay?

Not at the moment, but that’s a good suggestion. I’ll try to get it in the next release.

Sorry for more questions and thank you for assisting me with this.

I am getting a new error now that I have set a cast delay

Plex Assistant Automation: Error executing script. Unexpected error for call_service at pos 1: generator raised StopIteration
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/fuzzywuzzy/process.py", line 93, in extractWithoutOrder
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 153, in _async_step
    self, f"_async_{cv.determine_script_action(self._action)}_step"
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 656, in _async_call_service_step
    *self._prep_call_service_step(), blocking=True, context=self._context
  File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1299, in _execute_service
    await self._hass.async_add_executor_job(handler.func, service_call)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/plex_assistant/__init__.py", line 127, in handle_input
    command = process_speech(command_string, localize, default_cast, PA)
  File "/config/custom_components/plex_assistant/process_speech.py", line 25, in process_speech
    fuzz_client = fuzzy(control_check, devices)
  File "/config/custom_components/plex_assistant/helpers.py", line 42, in fuzzy
    return fw.extractOne(media, lib, scorer=scorer)
  File "/usr/local/lib/python3.7/site-packages/fuzzywuzzy/process.py", line 245, in extractOne
    return max(best_list, key=lambda i: i[1])
RuntimeError: generator raised StopIteration```

My config is this:

plex_assistant:
  url: 'http://*****INTERNAL NETWORK IP****:32400'
  token: !secret plex_token
  default_cast: 'Living Room TV'
  language: 'en'
  tts_errors: true
  cast_delay:
      Living Room TV: 10

What could I be doing wrong?

Nothing, this error has been mentioned in this thread a few times and is also reported on the Github. I’ll hopefully have a fix up this weekend.

Hi all,

I like the look of this integration. I am trying to get it to work with the Rhasspy voice assistant. It looks like it should be easy enough.

Is there any example yaml code around? I’ve had a look through this thread and am still not sure what exactly i should be putting in the Action section - plain text command, JSON ?

Thanks

Hi @mayker

Is this maybe interesting?

https://developers.googleblog.com/2020/07/announcing-new-smart-home-shed-types-and-traits.html?m=1