A guide mainly to myself for how to connect PlexAmp and HomeAssistant
https://www.plex.tv/plexamp/ https://github.com/odinb/bash-plexamp-installer
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)"
https://www.home-assistant.io/integrations/plex/
python_scripts
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:
Create an automation
{{ 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'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
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)
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: