Filtering event captured from android

Hi, im getting started with HA, im listening for an Android intent (headphone battery) but the problem is, when i poweroff headset, the battery level is sent as -1.
How can i filter this? and only allow numbers in range 0-100?
for reference basically I copied this:

Capturing bluetooth device battery level from android intent

Cheers

post your code so far please

Hello, thanks for your help. This is my current code. Im readong about filters now. Since my problem is that the attribute is set to ‘-1’ on disconnect, the numeric_state seems to be the right option.
Still no idea on how to tie those down.

automations.yaml

- id: '1641488324785'
  alias: Bateria auriculares BT
  description: ''
  trigger:
  - platform: event
    event_type: android.intent_received
    context:
      user_id:
      - 453e6b7d64204ceb9d2f1b106431e37c
  condition: []
  action:
  - device_id: dcbe52169baf3ac077c3d0e345ba5a64
    domain: mobile_app
    type: notify
    message: 'Bat lvl4 {{ trigger.event.data["android.bluetooth.device.extra.BATTERY_LEVEL"] }}'
    title: ha notifica
  mode: single

This is the invalid event I want to filter

{
    "event_type": "android.intent_received",
    "data": {
        "android.bluetooth.device.extra.BATTERY_LEVEL": "-1",
        "android.bluetooth.device.extra.DEVICE": "CA:BD:EF:01:13:FB",
        "intent": "android.bluetooth.device.action.BATTERY_LEVEL_CHANGED",
        "device_id": "da76d54287d24f75"
    },
    "origin": "REMOTE",
    "time_fired": "2022-01-06T16:24:14.445323+00:00",
    "context": {
        "id": "019f0e994747b656756c38bf089b6013",
        "parent_id": null,
        "user_id": "453e6b7d64204ceb9d2f1b106431e37c"
    }
}
  action:
  - device_id: dcbe52169baf3ac077c3d0e345ba5a64
    domain: mobile_app
    type: notify
    message: >
      {% set battery_level = trigger.event.data["android.bluetooth.device.extra.BATTERY_LEVEL"]%}
      {% if battery_level != -1%}
        'Bat lvl4 {{ battery_level }}'
      {% endif %}
    title: ha notifica
  mode: single

Thanks!!! I’ll try that as soon as I get back home, for what i understand it’s what i need. If I wanted to use is_number filter, is it possible? I can’t figure how to do it.