Service Template MQTT + input select + IoT Link help?

Hello,

I’m trying to send the input_select STATE inside a MQTT payload (within the “args” option) but not sure if it can be done or how to write it:

Please see the automation below where it says <— INSERT INPUT_SELECT.GAME_SELECT STATE HERE —> this is where I need the selection from the input_select.game_select entitiy.

I’m using IoT Link to send commands to a Windows PC and trying to use a dropdown list box to select a game which will then send the MQTT payload to the computer (arcade) and start the selected game (input_select.game_select).

The input_select.game_select STATE needs to be inserted in the middle (“args”) of the payload… is this possible please?

input_select:
  game_select:
    name: Game Select
    options:
      - kinst
      - mk3
      - pblank
    initial: kinst
- id: '158941234354'
  alias: start selected game
  trigger:
    platform: state
    entity_id: input_select.game_select
  action:
    service: mqtt.publish
    data_template:
      topic: iotlink/workgroup/arcade/commands/run
      payload: '{ "command": "C:\\Emulators\\mame_0219nonag\\mame64.exe", "args": "<--- INSERT INPUT_SELECT.GAME_SELECT STATE HERE --->" , "path": "C:\\Emulators\\mame_0219nonag", "user": "", "visible": true, "fallback": true }'

Thank you in advance :slight_smile:

    data_template:
      topic: iotlink/workgroup/arcade/commands/run
      payload: >
        { "command": "C:\\Emulators\\mame_0219nonag\\mame64.exe", "args": {{ states('input_select.game_select') }} , "path": "C:\\Emulators\\mame_0219nonag", "user": "", "visible": true, "fallback": true }

1 Like

Thank you as always @tom_l for the prompt support. :+1::+1::+1:
I’ll give it a shot and let you know how I go.

Just gave it a shot and it worked!!!
Thank you @tom_l you are a credit to this community.

Thanks again