Not necessarily. It depends on how it’s ultimately used.
the dev tools template editor will try to show you the correct return type based on all the data provided to it. But even that gets it wrong sometimes because it tries to *guess" what it is.
However, even if the template returns a number per the dev tools editor if you ultimately use that template to get the state of an entity it will always be a string.
and that’s what you are doing in the sensor above - you are using the template to set the state of the sensor. So it will always be a string.
But if you use the same template to set the value of an attribute of the sensor then it will be whatever the template editor says it should be - in your case it will be a number. Because the syatem converts all states to strings but it doesn’t do that same conversiuon on the attributes and instead uses it’s true datatype.
you can actually see this in action even in the template you are using above.
{{ states('input_number.koi_pond_capacity') | int * states('input_number.water_change_percentage') | int / 100 | int }}
the reason why you have to use the “int” filter on both of those input_number states to be able to do math with them is because states are always strings even if they look like a number.
I think you can test it using the same template you are already using for your sensor above.
try this to create the same sensor with a new “number” attribute (the name of the attribute doesn’t matter - you can call it “xyz” if you want):
- platform: template
sensors:
water_change_amount_each_week:
friendly_name: "Water change amount each week"
value_template: >-
{{ states('input_number.koi_pond_capacity') | int * states('input_number.water_change_percentage') | int / 100 | int }}
attribute_templates:
number: "{{ states('input_number.koi_pond_capacity') | int * states('input_number.water_change_percentage') | int / 100 | int }}"
then in the template editor try to use the following to test the functionality:
{{ states('sensor.water_change_amount_each_week') / 2 }}
{{ state_attr('sensor.water_change_amount_each_week', 'number') / 2 }}
the first one will fail because you are trying to do math on the state which is a string but the second will work because the attribute is a number. Even tho the template used to create both is exactly the same.
interestingly tho the dev tool editor will still try to claim that both of those results are numbers even tho one is a string and the other isn’t because the editor just looks at what the value looks like it is not what the true data type of the value is.
I hope that is helpful.