Blueprint wheel inventor

Hello, so I wanted to test the (then) new blueprint feature and wanted to create one. Helpful folks on Reddit helped me a lot but I still miss a little bit to make it work. I’m aware that I’m probably not the first to make it and I want to know what I am doing wrong (so I could do better next time). The idea is simple: certain sees movement and a turns on and sets its colour and brightness to values from text helper that contains a JSON ({"red":255,"green":0,"blue":0,"brightness":255} right now). After no longer sees movement, it waits for seconds and then in seconds dims the to zero brightness.
The blueprint is as follows:

blueprint:
  name: Light Management
  description: Turns light on on given signal
  domain: automation
  input:
    motion_sensor:
      name: Motion Sensor
      description: Motion sensor that will cause the light to turn on
      selector:
        entity:
          domain: binary_sensor
          device_class: motion
    target_light:
      name: Light
      description: Light that will be affected
      selector:
        target:
          entity:
            domain: light
    default_values:
      name: Default Light Values
      description: Light values used to light up this light
      selector:
        text: 
    transition_time:
      name: Transition Time
      description: Time taken to dim the lights in seconds
      default: 60
      selector:
        number:
          min: 0
          max: 600
          step: 1
          mode: slider
          unit_of_measurement: seconds
    timeout:
      name: Motion timeout
      description: Time to leave the light on after last motion is detected.
      default: 120
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds
          
trigger:
  - platform: state
    entity_id: !input motion_sensor
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: !input motion_sensor
    from: 'on'
    to: 'off'
    for: !input timeout
action:
- variables:
    command: '{{ trigger.to_state.state }}'
    default_values: !input default_values
    # default_values should be input_text with json like
    # {"red":255,"green":0,"blue":0,"brightness":255}
- choose:
  - conditions:
    - '{{ command == "on" }}'
    sequence:
    - service: light.turn_on
      entity_id: !input target_light
      data:
        brightness: >
          {% set val =  states(default_values) | from_json %}
          # I guess my problem is here...
          {{ val.brightness | int }}
#        brightness: 255
        rgb_color: 
          - '{{ val.red | int }}'
          - '{{ val.green | int }}'
          - '{{ val.blue | int }}'
#          - 255
#          - 0
#          - 0
  - conditions:
    - '{{ command == "off" }}'
    sequence:
    - service: light.turn_off
      data:
        transition: !input transition_time
      entity_id: !input target_light

So, what do I do wrong? And is it better to use JSON data than template light? I tried that as well but was not able to actually set any colour or brightness to it so I went to backup solution of JSON.
Thank you for any help.