Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106624

Script with Fields -> Condition of field value

$
0
0

Hi! I’m trying to build a script with input fields to get music assistant playing the music on different devices. The first two field “ID” and “type” are working, but i’m not able to get the field “device” with an condition working! If device==Soundbar it should play on my soundbar, if device==ZIPP it should use my ZIPP2-Speaker…
At the moment i just try to check if the field “device” is “Soundbar”, but the condition is true no matter what input value i’m trying…

Hope somebody could help me…

Here is my script:

alias: "Music Assistant: Start playing"
sequence:
  - if:
      - condition: template
        value_template: "data_template: \"{{ device == 'Soundbar' }}\""
        enabled: true
    then:
      - metadata: {}
        data:
          media_type: "{{ type }}"
          media_id: "{{ ID }}"
        action: music_assistant.play_media
        target:
          entity_id: media_player.soundbar
    else:
      - metadata: {}
        data:
          media_type: "{{ type }}"
          media_id: "{{ ID }}"
        action: music_assistant.play_media
        target:
          entity_id: media_player.zipp_2
    enabled: true
fields:
  ID:
    name: Media ID
    description: Media ID
    required: true
    example: SWR3
  type:
    name: Mediatype
    description: Type
    required: true
    example: radio
  device:
    name: Device
    description: Speaker
    required: true
    example: Soundbar
mode: restart
icon: mdi:music
description: ""

7 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 106624

Trending Articles