Plex Activity sensor with Docker

Just wondering if anyone has had any trouble with the Plex Activity sensor running on Docker? This is my first time attempting to use it and it doesn’t appear to be working for me, it looks like despite specifying the host in the sensor config, its not accepting it. Posting my configuration and logs below:

configuration.yaml:

sensor: !include_dir_merge_list includes/sensor

includes/sensor/media.yaml:

---
- platform: plex
  host: <redacted_ip>
  port: 32400
  username: !secret ha_plex_user
  password: !secret ha_plex_pass
#─► ip a show docker0 | sed -nr 's|.*inet ([^ ]+)/.*|\1|p'
172.17.0.1
#─► journalctl --no-pager -u container-home-assistant.service | grep -i plex
Apr 11 15:34:41 <redacted_host> docker[18652]: 17-04-11 15:34:41 ERROR (Thread-17) [plexapi] http://172.17.0.1:32400: HTTPConnectionPool(host='172.17.0.1', port=32400): Max retries exceeded with url: /?X-Plex-Token=<redacted_token> (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7fb66402f080>: Failed to establish a new connection: [Errno 111] Connection refused',))
Apr 11 15:34:41 <redacted_host> docker[18652]: 17-04-11 15:34:41 ERROR (Thread-14) [plexapi] https://172-17-0-1.c1cc57c28ed742e69b40165458d83332.plex.direct:32400: HTTPSConnectionPool(host='172-17-0-1.c1cc57c28ed742e69b40165458d83332.plex.direct', port=32400): Max retries exceeded with url: /?X-Plex-Token=<redacted_token> (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb66402b908>: Failed to establish a new connection: [Errno 111] Connection refused',))

Any help would be much appreciated.

I have the plex activity sensor working on Docker. I have both the plex docker and the HA docker network type set to “Host” instead of bridge? Maybe try that?

I’m already using host, sorry I forgot to post how I was starting the container. I am using systemd:

/etc/systemd/system/container-home-assistant.service:

[Unit]
Description=home-assistant in Docker container
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop home-assistant
ExecStartPre=-/usr/bin/docker rm home-assistant
ExecStartPre=-/usr/bin/docker pull docker.io/homeassistant/home-assistant:0.42.2
ExecStart=/usr/bin/docker run --rm -t \
    -v /opt/data/home-assistant/config:/config \
    -v /opt/data/home-assistant/config/options.xml:/usr/local/share/python-openzwave/config/options.xml \
    -v /etc/localtime:/etc/localtime:ro \
    --net=host \
    --hostname <redacted_public_hostname> \
    --device=/dev/ttyACM0 \
    --name home-assistant docker.io/homeassistant/home-assistant:0.42.2
ExecStop=-/usr/bin/docker stop -t 3 home-assistant
ExecStop=-/usr/bin/docker rm home-assistant
Restart=always
RestartSec=10s

[Install]
WantedBy=multi-user.target

did you get this working? I’m having the same problem using unraid dockers

As someone who has battled similar issues with Plex; anyone who is coming across this issue in future should try if at all possible to have the Plex container/vm/server AND HA on their own IPs (note: this is not currently possible Docker for Mac).

For Unraid, it became possible to do this in a recent version