Error with Light Template

Hello everyone,
My first post here, thanks all for the impressive amount of content.

I’m reaching out as I’ve been trying to create a light template. The idea of the template is to combine a Shelly 1 plus switch (installed behind the wall switch) and a Zigbee Ikea Tradfri led pannel into 1 single entity. The on/off of this entity would be the on/off attribute of the Shelly switch and the brightness + the colour temperature would be the brightness + colour temperature of the Ikea Tradfri pannel.

So far, so good, I’ve been able to turn on/off the Shelly switch. I’ve not tried the colour temperature yet, but when I try to change the brightness using my template I get the following error:

Here is the code of my template:

light:
  - platform: template
    lights:
      template_sh_lig_officeli_ceiling_combined:
        friendly_name: “OFFICE LI - CEILING COMBINED”
        unique_id: template_sh_lig_officeli_ceiling_combined
        value_template: >-
          {% if is_state('light.sh_lig_burli', 'on') %}
            on
          {% else %}
            off
          {% endif %}
        level_template:  >-
          {% if is_state('light.office_li_ceiling_panel_level_light_color_on_off', 'on') %}
            {{ (states.light.office_li_ceiling_panel_level_light_color_on_off.attributes.brightness)|int }}
          {% else %}
            0
          {% endif %}
        turn_on:
          service: light.turn_on
          entity_id: light.sh_lig_burli
        turn_off:
          service: light.turn_off
          entity_id: light.sh_lig_burli
        set_level:
          service: light.turn_on
          data_template:
            entity_id: light.office_li_ceiling_panel_level_light_color_on_off
            brightness: “{{ brightness }}”

Anyone could help to identify what is wrong with my brightness?

Thanks in advance!

Don’t use fancy quotes. Should be:

brightness: "{{ brightness }}"

Also you can simplify your value_template from this:

        value_template: >-
          {% if is_state('light.sh_lig_burli', 'on') %}
            on
          {% else %}
            off
          {% endif %}

To this:

        value_template: "{{ is_state('light.sh_lig_burli', 'on') }}"

Also you should heed this warning:

https://www.home-assistant.io/docs/configuration/templating/#states

For this template:

        level_template:  >-
          {% if is_state('light.office_li_ceiling_panel_level_light_color_on_off', 'on') %}
            {{ (states.light.office_li_ceiling_panel_level_light_color_on_off.attributes.brightness)|int }}
          {% else %}
            0
          {% endif %}

Change it to:

        level_template:  >-
          {% if is_state('light.office_li_ceiling_panel_level_light_color_on_off', 'on') %}
            {{ state_attr('light.office_li_ceiling_panel_level_light_color_on_off', 'brightness')|int }}
          {% else %}
            0
          {% endif %}

Thanks a lot! That did the trick! I believe the error was the fancy quotes. But I applied also the other suggestions.

Now the next step will be to look at the colour temperature, when I have a bit of time.