Feature Request: Return input_number values as native int or float in templates instead of strings

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.

:white_check_mark: Suggested improvement:

When an input_number is defined as int or float, Home Assistant should respect that type in templates and return it accordingly.


:bulb: Options:

  1. 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).
  2. Alternative (non-breaking): Introduce a new template helper like:
    {{ state_as('input_number.xyz', 'int') }}
    
    or a type-aware filter:
    {{ states('input_number.xyz') | typed }}
    

:test_tube: Current vs. Ideal Behavior:

{{ states('input_number.delay') }}

:repeat: Currently returns: "30" ← string
:white_check_mark: Should return: 30 ← integer (if helper is defined as such)


:wrench: Workaround today:

{{ states('input_number.delay') | int }}

…but this feels unnecessary and verbose, especially given the type is already defined in the helper configuration.


:pray: Why this change would help:

  • Cleaner, safer templates
  • Less type-casting everywhere
  • More predictable behavior
  • Better onboarding for new users

Just a heads up, you can vote for your own FR. :white_check_mark:

1 Like

All states of all entities are strings. Even binary sensors that have a well defined boolean type.

Only attributes have other types.

This was a choice made way back in the early days. I understand it this would be difficult to change. Though it was changed for attributes (they all used to be strings too).