Plex Media Player + Automtion to toggle lights

Hi,

I have created automations to turn on/off lights when the plex media player state changes on my Nvidia shield in my living room. The problem is that the state isnt communicated immediatly to home assistant and the lights change from on/off about 10-20 secs after the play/pause state of the media player alters.

Is there a better way to do this so when the media is played the lights turn off immediatly? My MQTT Sonoff outlets are able to switch states immediatly for instance.

    alias: 'Plex Lamps1'
    trigger:
      platform: state
      entity_id: media_player.plex_shield
      from: 'idle'
      to: 'playing'
    action:
    - service: homeassistant.turn_off
      entity_id: group.lamps

  - id: 453x
    alias: 'Plex Lamps2'
    trigger:
      platform: state
      entity_id: media_player.plex_shield
      from: 'paused'
      to: 'playing'
    action:
    - service: homeassistant.turn_off
      entity_id: group.lamps

  - id: 452x
    alias: 'Plex Lamps3'
    trigger:
      platform: state
      entity_id: media_player.plex_shield
      from: 'playing'
      to: 'paused'
    action:
    - service: homeassistant.turn_on
      entity_id: group.lamps

  - id: 452x
    alias: 'Plex Lamps4'
    trigger:
      platform: state
      entity_id: media_player.plex_shield
      from: 'playing'
      to: 'idle'
    action:
    - service: homeassistant.turn_on
      entity_id: group.lamps

Bump. Anyone?

I have similar automations and it can vary a bit - sometimes the trigger is instant, sometimes it takes a few seconds

Plex supports scan_interval so if you haven’t added a custom scan_interval to the Plex config the default is set at 10 seconds - you could try setting it lower

Also you could delete 2 of your automations entirely by just using ‘to’ without ‘from’…

trigger:
- platform: state
  entity_id: media_player.plex_shield
  to: 'playing'

And ‘from’ without ‘to’…

trigger:
- platform: state
  entity_id: media_player.plex_shield
  from: 'playing'

(Also, just checking that you have got unique id’s for your automations as the post above has 2 automations with the same ‘id’?)

I followed this guide to get near instantaneous changes:

just remember to turn on allow duplicate notifications in the tautulli settings, else when the show/movie ends you will not get the stop message as the watched message is sent at the same time.

1 Like

in my system there is hardly any delay, maybe 1 second…