Home Assistant

Speaker plug follows playback

A smart plug on an amplifier or powered speakers turns on when a media player starts playing, and turns off only after playback has stayed idle for a countdown. The countdown is a timer helper, so a Home Assistant restart still finishes the off.

Difficulty · BeginnerSetup · 20–40 minutesHA · current stable (blueprint)
Get the pack · from $19Have us set it up

Some hardware links on this page are affiliate links. As an Amazon Associate I earn from qualifying purchases. We may earn a commission if you buy through them, at no extra cost to you. See the affiliate disclosure.

An amplifier left on all night is a warm box doing nothing. An amplifier that drops power on every pause pops, and it drops again in the gap between tracks. This workflow turns the plug on when playback starts and turns it off only after the player has been out of playing for a countdown (pack default 8 minutes). A short pause keeps the amp up. A real stop runs the countdown down.

The countdown is a Home Assistant timer with restore, not a delay inside the automation. A restart while the countdown is running still turns the plug off at the end. A restart while audio is playing turns the plug on again if it came back down.

Entity ids are blueprint inputs. Do not publish a live plug or speaker name.

Ramping volume on a player that is already powered is restart-proof volume ramp. A timer that starts because you turned a switch on is relay auto-off timer.

What problem it solves

You want the amp or the powered speakers powered only while something is actually playing, with enough slack that a pause or a track change does not cycle the outlet, and with the off still happening if Home Assistant restarts during the wait.

How it works

  1. Playing — the media player changes to playing. Cancel the off timer if it is running, then turn the plug on. The trigger is the transition into playing, so switching the plug off by hand during a track does not immediately fight you. The next start (or a Home Assistant start while the player is still playing) brings the plug back.
  2. Left playing — the player leaves playing (paused, idle, off, or standby). Start the timer for the idle countdown. Do not turn the plug off yet.
  3. Timer finishes — if the player is still not playing, turn the plug off. If it returned to playing before the timer finished, the playing trigger has already cancelled the timer and the plug stays on.
  4. More than one player — optional extra players share the plug (a second streamer on the same amp). The plug turns on when any of them is playing. The countdown starts only when all of them have left playing. One player pausing while another is still going does not arm the off.
  5. Restart — the timer is created with restore, so a pending off survives a reboot and still fires. On homeassistant start, if any selected player is already playing, the plug is turned on and a leftover timer is cancelled. If none are playing and the plug is on and the timer is idle, a fresh countdown starts so a reboot does not leave the amp on forever.
  6. Order — one plug, one step. Turn the plug on, then let the player use it. This pack does not sequence a TV, a streamer, and a subwoofer. A subwoofer that should stay off at night gets its own instance of the blueprint with its own timer, or no instance at all.

Match the plug to the load. A small amplifier on a 15 A plug is a normal case. A large receiver that specifies a higher continuous draw is not a job for a travel plug.

Hardware notes

  • Plug. Any Home Assistant switch on the amplifier’s mains. The linked plug is a 15 A Wi-Fi outlet. Read the amplifier label. Do not put a hard-wired receiver on a smart plug by cutting into its cord.
  • Player. Any media_player whose state is playing while audio is coming out and something else (idle, paused, off) when it is not. Players that sit at playing forever (a live stream that never stops) will never start the countdown. Stop that stream with a script, or do not point this pack at it.
  • Timer. One timer helper per plug, restore enabled. The blueprint can create the instructions; you still add the helper so the duration survives a restart. A delay in the automation will not.
  • Speakers. Passive speakers on the amp, or powered speakers with the plug on their supply. The pack switches mains. It does not speak to the speaker’s own standby protocol.

Snippet

The pack ships a blueprint. Inputs replace real entity ids:

trigger:
  - platform: state
    entity_id: !input media_players
    to: "playing"
    id: playing
  - platform: state
    entity_id: !input media_players
    from: "playing"
    id: stopped
  - platform: homeassistant
    event: start
    id: startup
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: !input off_timer
    id: elapsed

action:
  - choose:
      - conditions:
          - condition: trigger
            id: playing
        sequence:
          - service: timer.cancel
            target:
              entity_id: !input off_timer
          - service: switch.turn_on
            target:
              entity_id: !input amp_plug
      - conditions:
          - condition: trigger
            id: stopped
          - condition: template
            value_template: "{{ none_playing }}"
        sequence:
          - service: timer.start
            target:
              entity_id: !input off_timer
            data:
              duration: !input idle_time
      - conditions:
          - condition: trigger
            id: elapsed
          - condition: template
            value_template: "{{ none_playing }}"
        sequence:
          - service: switch.turn_off
            target:
              entity_id: !input amp_plug

none_playing is true when every player in the input list is not playing. The startup branch is in the pack: playing → plug on and timer cancel; otherwise if the plug is on, start the idle timer.

Setup outline

  1. Add the plug and confirm the player’s state while you play, pause, and stop.
  2. Create a timer helper (restore on). Set the duration to the idle countdown you want; the blueprint also passes a duration when it starts the timer.
  3. Import the blueprint. Select the plug, the timer, the player (and any others that share the amp), and the idle time.
  4. Test: start playback → plug on within a second; pause → plug stays on; wait out the countdown → plug off; start playback during the countdown → timer cancels, plug stays on. Restart Home Assistant during the countdown → the plug still goes off when the restored timer finishes. Restart while audio is playing → the plug is on after startup.

Troubleshooting

  • Plug drops on every pause. The idle countdown is too short, or the off is tied to from: playing with no timer. Use the timer. Eight minutes survives a phone call; thirty seconds does not.
  • Plug never turns off. The player stays playing (a stream), another player in the list is still playing, or the timer helper was not created with restore and a restart cancelled a delay. Check each player’s state in Developer Tools.
  • Plug turns off during a song. One of the extra players fired from: playing and none_playing was wrong because the main player’s state lagged. The pack requires every listed player to be non-playing. Remove players that flap.
  • On after a hand off. Home Assistant restarted, or the player re-entered playing. A hand off is respected until the next playing transition or the next startup while audio is still going. Startup turns the plug on if audio is playing so a reboot does not leave you with silent speakers.
  • Pop from the speakers. The amp is switching on under load, or off while the player is still sending audio. Lengthen the idle countdown so the player has actually stopped. This pack does not insert a mute delay; if the amp pops on every power-up, fix that at the amp (a soft-start, or a player that can go quiet before the outlet opens).
  • Wrong outlet. The plug entity is a different switch. Turn it on from Developer Tools once, with the amp volume down, before you bind the blueprint.

Credits

Based on the community project Better Media Player. This write-up is the plug-follows-playback piece: on when a player is playing, off after an idle countdown that survives a restart.

Changelog

v1.0 · Oct 21, 2026: First publish.