Counting occurence of a specific character in an input_text

I have an input_text.entityname1

I want to evaluate this in a condition:

 - condition: template
   value_template: "{{ count(states('input_text.entityname1')  ????   ) >= 2 }}"

Now, I understand that ‘count’ is likely not correct, but I can’t figure out how to do this:
I want to count the number of times a specific character occurs in my input_text.entityname1

the entity can contain something like

  • text3,text1,text2
  • text4,text5
  • text6, text7

I want to count the number of times the comma occurs.
So in the first example I get 2, and in second example I get 1, resulting in True for the first example.

Help appreciated.

{{ states('input_text.entityname1').split(',') | length - 1 }}
1 Like