When creating an input_number
helper in Home Assistant, you explicitly define whether the value should be an Integer or a Float. However, in Jinja templates, accessing the helper like this:
{{ states('input_number.my_helper') }}
returns a string, not a number – even though the number type was clearly defined during setup.
- It’s not intuitive – especially for users who expect number inputs to behave like… numbers.
- It’s error-prone – you have to manually cast the value in every template using
| int
or| float
. - It causes unnecessary confusion and friction, especially for new users.
Suggested improvement:
When an input_number
is defined as int
or float
, Home Assistant should respect that type in templates and return it accordingly.
Options:
- Preferred:
states('input_number.xyz')
automatically returns the value as its actual type (int/float), based on the helper definition (if GUI provides the option to select). - Alternative (non-breaking): Introduce a new template helper like:
or a type-aware filter:{{ state_as('input_number.xyz', 'int') }}
{{ states('input_number.xyz') | typed }}
Current vs. Ideal Behavior:
{{ states('input_number.delay') }}
Currently returns:
"30"
← string
Should return:
30
← integer (if helper is defined as such)
Workaround today:
{{ states('input_number.delay') | int }}
…but this feels unnecessary and verbose, especially given the type is already defined in the helper configuration.
Why this change would help:
- Cleaner, safer templates
- Less type-casting everywhere
- More predictable behavior
- Better onboarding for new users