Giter Site home page Giter Site logo

plexamp_homeassistant's Introduction

plexamp_homeassistant

A guide mainly to myself for how to connect PlexAmp and HomeAssistant

PlexAmp

https://www.plex.tv/plexamp/ https://github.com/odinb/bash-plexamp-installer

HomeAssistant

https://www.home-assistant.io/ https://tteck.github.io/Proxmox/ Homeassistant OS: bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/vm/haos-vm.sh)"

HomeAssistant Plex Integration

https://www.home-assistant.io/integrations/plex/

My own 'integration'

For HomeAssistant:

  1. Download the directory: python_scripts
  2. Move the contents to /config/python_scripts/.
  3. Add to your /config/configuration.yaml:
shell_command:
    get_plexamp_playing_status: /config/python_scripts/get_plexamp_playing_status.py <plexamp_ip>
    pause_plexamp: /config/python_scripts/pause_plexamp.py <plexamp_ip>

Create a Toggle helper from the HomeAssistant UI:

  1. Go to Settings
  2. Devices & Services
  3. Helpers tab
  4. Create helper
  5. Toggle
  6. Name it 'is plexamp playing'

Create an automation

  1. Add a time pattern trigger for every second * * *
  2. Add an action to call a service. Call a shel command 'get_plexamp_playing_status'. Add response variable to 'is_plexamp_playing'
  3. Add an action, if/then/else. Within the 'if', create a template, use this: {{ is_plexamp_playing['stdout'] == '1' }}. Within the 'then' call service 'input boolean: turn on' and select 'input_boolean.is_plexamp_playing'. Do the same for the else (but you're calling service 'input boolean: turn off'
  4. Here is the yaml:
alias: get plexamp playing status
description: ""
trigger:
  - platform: time_pattern
    hours: "*"
    minutes: "*"
    seconds: "*"
condition: []
action:
  - service: shell_command.get_plexamp_playing_status
    data: {}
    response_variable: is_plexamp_playing
  - if:
      - condition: template
        value_template: "{{ is_plexamp_playing['stdout'] == '1' }}"
    then:
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.is_plexamp_playing
    else:
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.is_plexamp_playing
mode: single

Summary

Now you have a toggle that will turn on and off when you're playing music on PlexAmp.
I have created automations to turn on my Receiver if PlexAmp is playing. Or to pause PlexAmp if the Receiver source is changed (using the Plex/HomeAssistant integration)

Things to note

I only have one PlexAmp so I don't have any device checks within the Python code. If you have multiple PlexAmps, I suspect playing any of them will make the toggle switch to 'on'. You may be able to work around this by adding some python code to check device ID. I've not specified how to use the 'pause_plexamp.py' script in an automation (because I'm assuming that will be different for different people), but it should be straightforward enough. When you call the script, plexamp should get paused

There are also the following PlexAmp APIs that may be helpful to you:

  • /resources (which is for Plex discovery protocol GDM)
  • /player/playback/play
  • /player/playback/pause
  • /player/playback/stop
  • /player/playback/skipNext
  • /player/playback/skipPrevious
  • /player/playback/playPause
  • /player/playback/playMedia????
  • /player/playback/createPlayQueue????
  • /player/playback/seekTo?offset=1
  • /player/playback/skipTo?key=???&playQueueItemID=???
  • /player/playback/setParameters?repeat=???
  • /player/playback/setParameters?volume=0
  • /player/playback/setParameters?volume=100
  • /player/playback/setParameters?shuffle=(true/false)
  • /player/playback/setParameters?speed=???

plexamp_homeassistant's People

Contributors

n00b001 avatar

Stargazers

Brian Gilbert avatar Justin B. Alcorn avatar  avatar Kim Lidberg avatar  avatar CatDuck avatar Jack avatar

Watchers

 avatar

plexamp_homeassistant's Issues

New plexamp integration

Hey man, just to let you know I was inspired by your work and I've made a proper integration on HomeAssistant of plexamp.

This is my PR: home-assistant/core#111465

It's currently a work in progress, but I have installed on my own live home assistant instance and even if it's lacking some things (like volume control) is fully functional for back, next, pause, play, shuffle and repeat. I'm also getting the artist and album so it can be displayed in a mini-player (screenshot below).

My next step is to add also the ability to select a playlist to start a new session and I'm looking into being able to activate the DJ (although I'm not sure this is possible).

If the PR gets rejected because it's quite similar to functionality to the current Plex integration, I'll make a custom_component out of it to be integrated from HACS.

Just to let you know, I felt like I owed to you :)

imagen

PS: If you want to test it out, you gonna have to add the translations. When creating the PR to HA core, the translations are missing because are auto-generated. To do so, just copy the plexamp folder to your custom_components folder and copy the content of string.json into a file called en.json and place it in a folder named translations (you have to create that) at the root of plexamp.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.