Start kodi and launch playlist when ready - automation

Hi,

I have been attempting to do the following,
I have tablets (ios/android) I use around the house.
Both platforms have Kodi configured as a mediaplayer into hass.
What I would like to do is, by 1 click launch a video or audio file.

So basically the workflow I want is
launch kodi, wait for kodi to be available, start some playlist/media

To achieve this I implemented the following:

Script A:
Start Kodi, Turn on Automation A

Automation A
Triggered when Kodi is Idle
Start Script B

Script B:
Tell Kodi to open media
Turn off Automation A

Is there some less complicated way I am missing here?

And if no, is there a way to be more generic. For example not have to hard code the media url or media player would be nice. I would like to avoid to create a Script/Automation combo for every media/media_player.

So can a script pass or store variables to/for an automation? Like to specify the media and the media_player it should be triggered with?

Thanks,
J.

So this doesn’t have a direct correlation to playing media but it might give you an idea. I posted the the entire setup for this to help illustrate how they all work together. These together give me a drop down I can select which lights I’d like to change and lets me use the same sliders to adjust them together or individually. Unrelated, the templates for brightness and rgb modify the output of the slider that represents a percentage to the value needed by my LED controller.

EDIT: The relevant part for you is the data_template in the script that selects which device to control. You could also make an input_select with your media which would allow for the one script to be used for all media and media players.

input_slider:
  - brightness:
      name: Brightness
      min: 0
      max: 100
      step: 1
  - red:
      name: Red
      min: 0
      max: 100
      step: 1
  - green:
      name: Green
      min: 0
      max: 100
      step: 1
  - blue:
      name: Blue
      min: 0
      max: 100
      step: 1

input_select:
  kitchen_light_selector:
    name: Light Selector
    options:
      - All
      - Accent
      - Breakfast Bar
      - Sink

automation:
  - alias: RGBW Slider control
    trigger:
      - platform: state
        entity_id: input_select.kitchen_light_selector
      - platform: state
        entity_id: input_slider.brightness
      - platform: state
        entity_id: input_slider.red
      - platform: state
        entity_id: input_slider.green
      - platform: state
        entity_id: input_slider.blue
    action:
      service: script.rgbw_slider_control

script:
  rgbw_slider_control:
    sequence:
      service: homeassistant.turn_on
      data_template:
        entity_id: >-
          {% if states.input_select.kitchen_light_selector.state == "Accent" %}
          light.kitchen_accent
          {% elif states.input_select.kitchen_light_selector.state == "Breakfast Bar" %}
          light.breakfast_bar
          {% elif states.input_select.kitchen_light_selector.state == "Sink" %}
          light.kitchen_sink
          {% elif states.input_select.kitchen_light_selector.state == "All" %} 
          - light.kitchen_sink
          - light.breakfast_bar
          - light.kitchen_accent
        {% endif %}
        brightness: >-
          '{{ (states.input_slider.brightness.state | float * 255 / 100) | round }}'
        rgb_color: >-
          ['{{ (states.input_slider.red.state | float * 255 / 100) | round }}','{{ (states.input_slider.green.state | float * 255 / 100) | round }}','{{ (states.input_slider.blue.state | float * 255 / 100) | round }}']

cool! thanks this is very helpful.

Also useful is this input_select with templates shown here:

I’m curious as how you managed to start Kodi. I’ve tried creating a simple shell command with just “kodi” in it. Kodi starts but for some reason it remains unresponsive.

Did you also have this problem, and if so, how did you solve it?