Zwave js action with template

Hi,
I’m new to HA and have been Googling for an hour with no luck.

I have the following automation.

- id: '1656580020595'
  alias: Study Light - From OH
  description: ''
  trigger:
  - platform: mqtt
    topic: cmnd/zwave/node27/switch1
  condition: []
  action:
  - type: turn_on
    device_id: bbd32c5818b022d4c3c880f89253f975
    entity_id: light.study_lights
    domain: light
    brightness_pct: 100
  mode: single

This works but obviously always sets the brightness to 100. What I actually want to do is set the brightness to the payload of the trigger.

I created a MQTT action and confirmed the value of ‘{{trigger.payload}}’ is what I want.

The problem is, nothing I try let’s me set brightness_pct to a template.

Some pages said I need to use data_template instead of data, but there’s no data key anywhere in my automation that I can replace.

When I try the below, I get an error saying
Message malformed: expected float for dictionary value @ data['brightness_pct']

- id: '1656580020595'
  alias: Study Light - From OH
  description: ''
  trigger:
  - platform: mqtt
    topic: cmnd/zwave/node27/switch1
  condition: []
  action:
  - type: turn_on
    device_id: bbd32c5818b022d4c3c880f89253f975
    entity_id: light.study_lights
    domain: light
    brightness_pct: '{{trigger.payload}}'
  mode: single

How do I achieve this?

I got there.
I had to change the action format entirely to what’s below

service: light.turn_on
data_template:
  entity_id: light.study_lights_dimmer
  brightness_pct: '{{trigger.payload}}'
1 Like