It depends on how those attributes are defined. Only a State Object’s state field must be a string. Attributes can be any type. I searched for that attribute name but it didn’t come up, so it must be some sort of custom integration. But, yeah, if they are strings, then they need to be converted to numbers first.
EDIT: If it’s not clear if the attribute is a string or number, the following can be put into the Template Editor:
{{ state_attr('sensor.afvalinfo_gft','days_until_collection_date') is number }}
Turned out that the indent of the called service was not correct. Configuation check did not notice.
Thank for your help. I learned more about using the template editor.
then I must have changed it accidentally when I copied pnbruckner’s template, because that did not work at first.
When I changed indent it worked, so then pnbruckner’s template was the solution appearanty.
Just to be clear, my template was only a way to check if the attribute was a string or a number (e.g., float or int.) I did not actually suggest a template for use directly in your automation.
I agree with @tom_l, the indentation of the automation in the original post was technically ok, although unusual.
It’s still not clear what you did to make it work for you, but since it does, we’re happy!