Automation configuration error

Automation error:

Can anyone shed some insight on this error for me. Thanks in advance…

Invalid config for [automation]: template value should be a string for dictionary value @ data[‘action’][0][‘data’]. Got None. (See ?, line ?).

  alias: Percent Propane Yesterday Input Automation
  description: ''
  trigger:
  - platform: time
    at: '23:59:50'
  condition: []
  action:
  - service: input_number.set_value
    target:
      entity_id: input_number.yesterdays_input_number
    data:
      [value_template: '{{((''states(sensor.tank_percentage'') | float) }}']
  mode: single
- id: '1643898478033'
  alias: Set Todays Input Propane Percent Used
  description: ''
  trigger:
  - platform: time
    at: '23:59:00'
  condition: []
  action:
  - service: input_number.set_value
    target:
      entity_id: input_number.daily_propane_percent_used
    data:
      [value: '{% set propaneused = (states(''input_number.yesterdays_input_number'')
        | int) - (states(''sensor.tank_percentage'') | int), 0 %}{{ propaneused|max}}']
  mode: single

Why square brackets?

Tried that because the default was data: [value]

When I remove the square brackets I get this error…

Error while executing automation automation.percent_propane_today_input_automation: extra keys not allowed @ data[‘value_template’]

Percent Propane Yesterday Input Automation: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data[‘value_template’]

  alias: Percent Propane Yesterday Input Automation
  description: ''
  trigger:
  - platform: time
    at: '23:59:50'
  condition: []
  action:
  - service: input_number.set_value
    target:
      entity_id: input_number.yesterdays_input_number
    data:
      value_template: '{{((states(''sensor.tank_percentage'')) | float) }} '
  mode: single
- id: '1643898478033'
  alias: Set Todays Input Propane Percent Used
  description: ''
  trigger:
  - platform: time
    at: '23:59:00'
  condition: []
  action:
  - service: input_number.set_value
    target:
      entity_id: input_number.daily_propane_percent_used
    data:
      value: '{% set propaneused = (states(''input_number.yesterdays_input_number'')
        | int) - (states(''sensor.tank_percentage'') | int), 0 %}  {{ propaneused|max}}'
  mode: single

Is it the double single quotes ?

I was looking at that cuz I edited thru a vnc… I changed to this and get the same error???
I tested in developer template and the value is correct?

- id: '1643814344142'
  alias: Percent Propane Yesterday Input Automation
  description: ''
  trigger:
  - platform: time
    at: '23:59:50'
  condition: []
  action:
  - service: input_number.set_value
    target:
      entity_id: input_number.yesterdays_input_number
    data:
      value_template: '{{((states("sensor.tank_percentage")) | float) }}'
  mode: single
- id: '1643898478033'
  alias: Set Todays Input Propane Percent Used
  description: ''
  trigger:
  - platform: time
    at: '23:59:00'
  condition: []
  action:
  - service: input_number.set_value
    target:
      entity_id: input_number.daily_propane_percent_used
    data:
      value: '{% set propaneused = (states("input_number.yesterdays_input_number")
        | int) - (states("sensor.tank_percentage") | int), 0 %}{{ propaneused|max}}'
  mode: single

Change value_template to value, it supports templating (as you an see in you second automation. And check correct usage of double and single quotes. I use double quotes outside the template expression and single quotes inside

value: "{{ states('sensor.entity_id') }}"

Thanks. I think the value_template was the issue and I fixed the quotes. Now seems working.

1 Like