How to create template for the fan

I’m new to home assistant and try to learn create a template. So far I learn a lot from here. I found a template here but don’t know how to add the fan. Can you help me out/ Thanks .

  • name: Family Room Summary
    <<: &area_family_room
    state: “{{ expand(area_entities(this.name[:-7])) |selectattr ( ‘domain’ , ‘eq’ , ‘fan’ ) | selectattr ( ‘domain’ , ‘eq’ , ‘light’ ) | selectattr ( ‘state’ , ‘eq’ , ‘on’ ) | list | count > 0 }}”
    attributes:
    lights_count: “{{ expand(area_entities(this.name[:-7])) | selectattr ( ‘domain’ , ‘eq’ , ‘light’ ) | list | count }}”
    lights_on: “{{ expand(area_entities(this.name[:-7])) | selectattr ( ‘domain’ , ‘eq’ , ‘light’ ) | selectattr ( ‘state’ , ‘eq’ , ‘on’ ) | list | count }}”
    lights_off: “{{ expand(area_entities(this.name[:-7])) | selectattr ( ‘domain’ , ‘eq’ , ‘light’ ) | selectattr ( ‘state’ , ‘eq’ , ‘off’ ) | list | count }}”
    fans_count: “{{ expand(area_entities(this.name[:-7])) | selectattr ( ‘domain’ , ‘eq’ , ‘light’ ) | list | count }}”
    fans_on: “{{ expand(area_entities(this.name[:-7])) | selectattr ( ‘domain’ , ‘eq’ , ‘light’ ) | selectattr ( ‘state’ , ‘eq’ , ‘on’ ) | list | count }}”
    fans_off: “{{ expand(area_entities(this.name[:-7])) | selectattr ( ‘domain’ , ‘eq’ , ‘light’ ) | selectattr ( ‘state’ , ‘eq’ , ‘off’ ) | list | count }}”

Please see this post on how to post code in the forum.

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16