Template that is a string and a number

A simple question. I have an sensor produces a string and a number as an output.

Im trying to create an ERROR sensor but cant seem to get it working.

{% set enabled1 = 'input_boolean.unit1_enabled'%}
{% set tsens1 = 'sensor.shelly_global_temp' %}
{% if (states(tsens1) == "unavailable" and states(enabled1) == 'on') or (states(tsens1) | int > 999 and states(enabled1) == 'on') %}
   error
{% else %} 
   Online
{% endif %}

Valid reported states are:

unknown
unavailable
(valid numerical temperature = 0 to 99)
(invalid numerical temperature = 999) typically due to a faulty probe.

When states(tsens1) | > 999 is a string the template generates an error.

How can I perform a mathematical operation on a string???

{% set enabled1 = is_state('input_boolean.unit1_enabled', 'on') %}
{% set tsens1 = states('sensor.shelly_global_temp') %}
{{ 'error' if enabled1 and (tsens1 == "unavailable" or tsens1 | int(0) >= 999)  else 'Online' }}

thx drew.

forgot the int (0)