Scripting with conditions on entity_id for Kodi Library Update

Hi Everyone,

I’m new to scripting and templates, and am trying to write a script that will tell one of my kodi media players to update its library, based on which one is online.

Currently I have tried a few variations of the following code:

    alias: Update Kodi Library
      - alias: Call Kodi update
        service: media_player.kodi_call_method
          entity_id: >
            {% if is_state('states.media_player.kodi_bedroom', 'off') %}
            {% else %}
            {% endif %}
          method: VideoLibrary.Scan

But it doesn’t seem to work. I’m sure there is something obvious that I’m missing, I just don’t know what it is?


is_state('states.media_player.kodi_bedroom', 'off')

should be

is_state('media_player.kodi_bedroom', 'off')

As per @pnbruckner’s advice, you only need the additional state prefix if you’re referencing the attributes level

Awesome that worked, thank you!

1 Like