Frontend-to-Script Variable Syntax

I’m having some trouble using variables in between frontend and scripts, anyone able to see what I’m getting wrong about the syntax?

Frontend:

type: 'custom:rgb-light-card'
entity: light.living_room_all
colors:
  - type: call-service
    service: script.1612752588267
    data:
      group_name: Living Room All
      scene_name: Living Room Tiki
      adapt_toggle: switch.adapt_livingroom

Script:

alias: Activate Hue Scene with Variable
mode: single
icon: 'mdi:cog'
fields:
  group_name:
    description: Hue Group
    example: Living Room All
  scene_name:
    description: Hue Scene Name
    example: Living Room Tiki
  adapt_toggle:
    description: Which Adaptive to Turn Off
    example: switch.adapt_livingroom
sequence:
  - service: hue.hue_activate_scene
    data:
      group_name: '{{ group_name }}'
      scene_name: '{{ scene_name }}'
  - service: switch.turn_off
    entity_id: switch.adapt_livingroom
colors:
  - type: call-service
    service: script.1612752588267
    service_data:  ####<------  Here ###

Ah, thank you. Why is the syntax seemingly different for all of these types of calls? Is there anywhere that clearly delineates data vs service_data vs data_template and when/why to use which?

data: is used to pass data to a service.

data_template used to have to be specified if you were using a template in your data:. This was simplified recently. Now you can and should just use data: for data with and without templates.

For whatever reason the front end developers chose to use service_data: for data to be passed to services from Lovelace, I have no idea why.

In short:

Use data: in your automation and script config,
Use service_data: in Lovelace.

Amazing, thank you.

1 Like