Data to url from automation

Hi,
I’m new to HA and I can’t send values to an url.
In configuration.yaml, I defined:

rest_command:
  send_power:
    url: https://someUrl.com
    method: POST
    payload: '{"power_solar": {{ power_solar }},"power_enedis": {{ power_enedis }}}'

In an automation, I try to assign values to the 2 variables:

alias: Production solaire
description: ""
trigger:
  - platform: time_pattern
    minutes: /5
condition: []
action:
  - service: rest_command.send_power
    data:
      power_solar: 50
      power_enedis: 100
mode: single

The url is called correctly but the variables are empty.
I do not understand why.

You’re missing quotes around the templates.

payload: '{ "power_solar": "{{ power_solar }}", "power_enedis": "{{ power_enedis }}" }'
1 Like