Trying to template a sensor to count all sensors that matching specific name

Trying to template a sensor to count all sensors that matching specific name.
For example - multisensor or _temperature

tried to figure it out myself using regex template but didn’t succeed…
{{ states(‘multisensor’ | regex_search(find, ignorecase=False)) | count }}

{% set ns = namespace(count=0) %}
{% for state in states.sensor if 'multisensor' in state.object_id %}
  {% set ns.count = ns.count + 1 %}
{% endfor %}
{{ ns.count }}
1 Like

Thank you!