Whats wrong with my code?

I call my scripts from the folder \scripts, and i have other script in the folder which works fine.

I am creating a new script to mute my TV using the below code

alias: LG_TV_Mute
sequence:

  • data:
    packet:
    • JgBgAAABKpIUERQQFTUUERQRFBEUERQQFDY…

below is the error, can some help me out. I am a noob to yaml, but I think have the indentations correct

Invalid config for [script]: [data] is an invalid option for [script]. Check: script->script->mute->sequence->0->data. (See /config/configuration.yaml, line 164). Please check the docs at Scripts - Home Assistant

Try like this, working for me with the Broadlink component.

aircon_off:
  alias: Aircon Off
  sequence:
  - data:
      { "packet" : [ "JgBkAWMAAScREBRAyEBASMBEREBARERAREBEREBAREBEQEBEyDzESAA0FAAAAAA" ]}
    service: switch.broadlink_send_packet_192_168_1_130
1 Like

Here’s my code, in case it helps:

scripts.yaml:

...
kitchen_hood_operation_toggle:
  sequence:
    - service: switch.broadlink_send_packet_10_0_0_250
      data:
        packet:
        - "JgBQAAABKpMUEhMSExIUEhMSExMTEhMSFDcTNxM3FDYUNhQ3EzcUNhQSExIUERQSExIUEhMSFBEUNxM3FDYUNhQ3EzcUNhQ2FAAFFQABKkkUAA0FAAAAAAAAAAA="
...

configuration.yaml:

...
script: !include scripts.yaml
...

(ommit the ellipses (…) ofc )

2 Likes

Thanks Kanga_who, it works for me too :slight_smile:

1 Like

In general a good principle is to define the service first and put the data after that. As in @krash example.

Much more readable :slight_smile:

2 Likes

I agree, however, I had no end of issues getting the script to work with the Broadlink component initially myself, so when I got that code to work I left it be.