Template-card | Badge Icon depending on state of two entities

Hello,

I am trying to change a badge icon and the badge icon color depending on the state of a shelly blu/door sensor. There are two sensors. One binary.sensor for open/close and a sensor for the tilt (e.g. a number >1).
My code looks like this:

    badge_icon: |
      {% if is_state ('sensor.fenster_bad_1_og_rotation', '> 1') %}
        mdi:window-open
      {% elif is_state ('binary_sensor.fenster_bad_1_og_window', 'on') %}
        mdi:window-open
      {% elif is_state ('binary_sensor.fenster_bad_1_og_window', 'off') %}
        mdi:window-closed       
      {% else %}  {% endif %}
    badge_color: |
      {% if is_state ('sensor.fenster_bad_1_og_rotation', '> 1') %}
        yellow
      {% elif is_state ('binary_sensor.fenster_bad_1_og_window', 'on') %}
        red        
      {% elif is_state ('binary_sensor.fenster_bad_1_og_window', 'off') %}
        grey
      {% else %} {% endif %}

I am struggeling with state of the tilt sensor and its state. Similiar code is working for me in a button card but not in this template card.

Any ideas?

OK I find out by myself. You need to tell the card that the state of the tilt sensor ist a number.

Something like this:

    badge_icon: |
      {% if states('sensor.fenster_bad_1_og_rotation') | int > 1 %}
        mdi:window-open
      {% elif is_state ('binary_sensor.fenster_bad_1_og_window', 'on') %}
        mdi:window-open
      {% elif is_state ('binary_sensor.fenster_bad_1_og_window', 'off') %}
        mdi:window-closed       
      {% else %}  {% endif %}
    badge_color: |
      {% if states('sensor.fenster_bad_1_og_rotation') | int > 1 %}
        orange
      {% elif is_state ('binary_sensor.fenster_bad_1_og_window', 'on') %}
        red        
      {% elif is_state ('binary_sensor.fenster_bad_1_og_window', 'off') %}
        grey
      {% else %} {% endif %}