[solved] Automation that keeps AMP (on smartplug) up, even after short pause, stop or idle from mediaplayer?

Hi guys, could use your help with this. (have seen a solution for it some time ago but cannot find it anymore)

With the Kodi integration I get an idle/playing/paused status from the player.
I have an automation that switches on a smart plug when going from * to playing and with some delay switches off when going to idle.
This works except when, within that timeframe, the player goes into idle state briefly, the automation is triggered and switches off the plug.

How can I prevent that the next step in the automation fires within the timeframe of the delay?

- id: '1615072826241'
  alias: Kodi-speakers OFF
  description: ''
  trigger:
  - platform: state
    entity_id: media_player.mc
    to: idle
    from: playing
  - platform: state
    entity_id: media_player.mc
    to: idle
    from: paused
  condition: []
  action:
  - delay:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: bbb36b9da2b826c63bb7ae63b23f52a3
    entity_id: switch.smartplug
    domain: switch
  mode: single

Thanks A LOT in advance!

Hi Nick! Instead of the delay, trigger the automation when the state has been idle for e.g. 10 minutes.
As far as I’m concerned, you can add for: 00:10:00 to both triggers and remove the delay in the action block. If the idle-state is only temporary, the automation won’t trigger.

trigger:
  - platform: state
    entity_id: media_player.mc
    to: idle
    from: playing
    for: "00:10:00"

Here are the docs:

1 Like

That easy huh… :blush:

THANK YOU!

1 Like

You’re welcome :slight_smile: