Help with Group and entity_id

Hello to everyone!! :smiley:
i need some help with group and template.
I want to exclude all entity inside the group.stanze, but this template won’t work…

{% for state in states.binary_sensor -%}
 {% if state.state == 'on' and state.entity_id not in expand ( 'group.stanze' ) %}  
   {{ state.name }} 
 {%- endif -%} 
{%- endfor -%}

Thanks a lot
Stefano