Checking Battery Levels with config-template-card

Hello. I am trying to use the config-template-card to check battery levels. I want it show the battery level if the battery is below a threshold value set by a helper.

Here is my code:

type: entities
entities:
  - type: custom:config-template-card
    variables:
      BATTTHRESHOLD: |
        battlevel => {
        if (battlevel < input_number.battery_threshold)
        {return 'Battery Low';}
        else 'hello'
        }
      CURRENTBATT: states['sensor.robovac_battery'].state
    entities: sensor.robovac_battery
    row:
      type: section
      label: Robovac Battery Alert
title: Battery Level Alert
state_color: true
show_header_toggle: false

Hi,

Here is what I’m using, I have two separate pieces of code, one only shows below a specific percentage and is hidden with a conditional card, the other I have as a separate page so I can see all my devices when I want to:

title: Battery Levels
content: >
  {% set ignore_list = ['sensor.david_s_iphone_battery_level',
  'sensor.michelles_iphone_battery_level',
  'sensor.david_s_iphone_remote_battery_level'] %} {% set batteries =
  states.sensor
    | selectattr('attributes.device_class', 'defined')
    | selectattr('attributes.device_class', 'eq', 'battery')
    | rejectattr('entity_id', 'in', ignore_list)
    | rejectattr('state', 'in', ['unknown', 'unavailable'])
    | sort(attribute='state') %}
  {% for battery in batteries %}
    <span style="display: inline-block; margin-bottom: 5px;">
      <ha-icon icon="mdi:battery-{{ (states[battery.entity_id].state | int / 10) | int * 10 }}" style="color: 
      {% if states[battery.entity_id].state | int < 10 %}red
      {% elif states[battery.entity_id].state | int < 20 %}orange
      {% elif states[battery.entity_id].state | int < 50 %}yellow
      {% else %}green{% endif %};"></ha-icon>
      {{ states[battery.entity_id].name }}: {{ states[battery.entity_id].state }}%
    </span><br>
  {% endfor %}
theme: Mytheme

and for the below 35%

title: Low Battery Devices (<35%)
content: >
  {% set ignore_list = ['sensor.david_s_iphone_battery_level',
  'sensor.michelles_iphone_battery_level',
  'sensor.david_s_iphone_remote_battery_level'] %}

  {% set batteries = states.sensor
    | selectattr('attributes.device_class', 'defined')
    | selectattr('attributes.device_class', 'eq', 'battery')
    | rejectattr('entity_id', 'in', ignore_list)
    | rejectattr('state', 'in', ['unknown', 'unavailable'])
    | selectattr('state', 'le', '35')
    | sort(attribute='state') %}

  {% for battery in batteries %}
    <span style="display: inline-block; margin-bottom: 5px;">
      <ha-icon icon="mdi:battery-{{ (states[battery.entity_id].state | int / 10) | int * 10 }}" style="color: 
      {% if states[battery.entity_id].state | int < 10 %}red
      {% elif states[battery.entity_id].state | int < 20 %}orange
      {% elif states[battery.entity_id].state | int < 50 %}yellow
      {% else %}green{% endif %};"></ha-icon>
      {{ states[battery.entity_id].name }}: {{ states[battery.entity_id].state }}%
    </span><br>
  {% endfor %}
theme: Mytheme