Brightness value in Light Template

Hi, I have been doing some integrations between my Crestron system and HA via Node-RED. Most of my lights are in the Crestron system and originally I just wanted to add some Hue lights and control them from the Crestron system via Node-red. Then I started playing around with HA and looking for ways to do more integrations.
I’m using this Crestron/Node-RED module from songzh96, works well and is stable.:

And with the Node-RED integration in HA and Entity node it’s very easy to feed the sensors in Crestron to HA.

I have some light that are just on relay (no dimming) and those were also quite easy to integrate by creating light template in configuration.yaml and with this Node-RED flow I get feedback both ways between HA and Crestron.

light:
  - platform: template
    lights:
      anddyri_loftljos:
        friendly_name: "Anddyri loftljós"
        turn_on:
        turn_off:

Then it comes to the dimmable lights and here is where my lack of scripting knowledge stops me. How to create light template that can be used to send and receive brightness information to and from Node-RED. I have tried a lot of configurations that I have found in this forum but all fail. (btw, the new feature in the 0.115 update to be able reload Template Entities without rebooting is a life saver, thanks)
One of the config I tested is this one:

      herbergi_loftljos:
        friendly_name: "Herbergi loftljós"
        turn_on:
        turn_off:
        set_level:
          - service: input_number.set_value
            data:
              entity_id: light.herbergi_loftljos
              brightness: "{{ brightness }}"    

It gives me the brightness slider in HA but I get errors when trying to change the values.
Any ideas or recommendations?
Thanks