Invalid data , float as brightness

I’m trying to set a brightness value to the value of a sensor object through an automation.
I’m getting following error though:
Invalid data for call_service at pos 1: expected float for dictionary value @ data['brightness_pct']

In developer tools > template, when i input:
{{states('sensor.werkplaats_brightness') | float}} i get 0.0 (or 100.0), this seams correct as a float?

The automation i have is:

- id: '1564394290026'
  alias: Werkplaats sensor verlichting aan
  trigger:
  - entity_id: binary_sensor.sensor_werkplaats
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - below: '1'
    condition: numeric_state
    entity_id: sensor.magazijn_partitie_status
  action:
  - data:
      brightness_pct: '{{states(''sensor.werkplaats_brightness'') | float}}'
      entity_id: light.werkplaats
    service: light.turn_on
1 Like

Change:

- data:

to:

- data_template:
1 Like

Also replace your double single quotes with double quotes.

From

brightness_pct: '{{states(''sensor.werkplaats_brightness'') | float}}'

to

brightness_pct: '{{states("sensor.werkplaats_brightness") | float}}'
1 Like

Thank you both! Seems to be working now :slight_smile: