Sensor counting by state and overall devices

Hey,
I’m trying to make something that looks like a SWAKES Sensor counter, but I can’t figure it out by myself.
image

I want to count the number of entities within a group that I have and show also how many of them are in the ‘On’ state
For example:
I have group.cameras with 3 entities of my cameras, 2 of them are ‘On’ state and 1 is ‘Off’ state
So I want to show up in my dashboard 3/2 (3 is the total number of entities within the group, and 2 is the number of ‘On’ devices within the group).

How do I do that? I want to count my lights and some devices I have.

*Note that I have tried the following method:
Dashboard card

          - type: custom:template-card
            entity: sensor.ac_counter
            name: Cameras

The sensor declaration in 'templates.yaml’

- sensor:
    - name: ac_counter
      state: >-
        {{ expand(state_attr('group.ac_counter', 'entity_id') )
          | selectattr('state', 'eq', 'on') 
          | list 
          | count
        }}

The group declaration in groups.yaml

ac_counter:
  name: Test
  entities:
    - climate.ofir_a_c
    - switch.switcher_v4_yair
    - media_player.mibox4_2
    - binary_sensor.zigbee2mqtt_running

The current situation is that the card showing me ‘Unavailable’ instead of ‘3/4’.
Thanks for helping me out!