Change light brightness based on time and day

Hi all !

I’ve looked at @killsystem 's script for changing the brightness of my light based on the time and day.

Here’s what I came up with:

- id: '1537017023952'
  alias: Kitchen - LiFx Movement On
  trigger:
  - entity_id: binary_sensor.multisensor_motion_sensor_sensor_kitchen
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - below: '200'
    condition: numeric_state
    entity_id: sensor.multisensor_motion_sensor_luminance_kitchen
  action:
  - alias: ''
    data:
      entity_id: light.lifx_z_28dcd8_kitchen
      brightness: >
          {% set hour=states("sensor.time").split(':')[0] | int %}
          {% set dayOfWeek=now().weekday()  %}
          {%- if hour >= 0 and hour < 3 and dayOfWeek in [5,6] -%}
            150
          {%- elif hour >= 5 and hour < 6 and dayOfWeek in [0,1,2,3,4] -%}
            75
          {%- elif hour >= 6 and hour < 8 and dayOfWeek in [0,1,2,3,4] -%}
            180
          {%- elif hour >= 6 and hour < 8 and dayOfWeek in [5,6] -%}
            75
          {%- elif hour >= 8 and hour < 23  -%}
            255
          {%- elif hour >= 23 and hour < 24 and dayOfWeek in [4,5]  -%}
            255
          {%- elif hour >= 23 and hour < 24 and dayOfWeek in [0,1,2,3,6]  -%}
            150
          {%- else -%}
            1
          {%- endif %}
    service: light.turn_on

And I’m coming up with this error:
Error while executing automation automation.kitchen_lifx_movement_on. Invalid data for call_service at pos 1: expected int for dictionary value @ data['brightness']

`

Do you know what could be happening ?

Thanks in advance for your help !

You are using data_template here. Take a look at the template setup guide, everything you need is there.

Thank you very much, it works !

I am glad I could help you.
Please concider marking my answer as the working solution so that the thread gets marked as solved and other users find the most helpful answer quickly!