Conditional scan interval for media_player.plex component. Doable?

I’d like to set the scan interval on the media_player.plex component to change dynamically depending on whether my server is sleeping or not. If it keeps getting scanned, it does not sleep :slight_smile:

I figured using an if else statement would do it, but check config does not like it. Is there anyway of accomplishing this?

This is what I have now:

  - platform: plex
    entity_namespace: 'plex'
    include_non_clients: true
    scan_interval:
      value_template: >
       {% if states('sensor.tp_link_watts') | float > 20 %}
         5
       {% else %}
         21600
       {% endif %}    
    show_all_controls: false
    use_episode_art: false
    remove_unavailable_clients: true
    client_remove_interval: 600

This won’t be possible. You may be able to edit the components python file and create a custom component that points to an entity to populate the scan interval. Your current configuration will not work because configs typically do not allow value_templates. plex scan_interval definitely does not allow templates.

That sounds reasonable, thanks. Any idea how I can get the state of another sensor in the python code?

depends on the direction you are going. Are you going to make it a component? If you are making a component, the way to get states from an object is:

    entity_id = 'domain.device_name'

    #example entity_id = 'light.mylight1'

    hass.states.get(entity_id)