Help needed with sensor strftime templating

value_template: >
    {% set expand(lights) = [
      ('light.1_big_light'),
      ('light.2_big_light_2'),
      ('light.3_big_light_3'),
      ] %}
    {{ expand(lights) | selectattr('state','eq','on') | list | count }}

Thank you for your quick response. I suspect that I am doing something wrong. I am getting an error TemplateSyntaxError: expected token ‘end of statement block’, got ‘(’

You should have only replaced lights in this line {{ expand(lights) | selectattr('state','eq','on') | list | count }}. {% set lights = ... should have remained the same.

my template behaves strangely and shows zero. Tell me, if you create a sensor, will its behavior be the same?

It’s most likely your lights, not the template.