Absolute value (math)


I’m not sure if I’m doing something wrong, but I’d like to get the absolute value of a variable (e.g. sun elevation).

as per
Templating - Home Assistant (home-assistant.io) which says taht we can use Mathematical operation ( Template Designer Documentation — Jinja Documentation (3.0.x) (palletsprojects.com)) why won’t the template

states.sun.sun.attributes.elevation < ((states.variable.max_sun_position.state|float) * (0.96-((abs((now().month-6)*2))/100)))


Am I missing something?

Thank you for your input!

I don’t think abs is available as a function, abs(), only as a filter |abs.

state_attr('sun.sun', 'elevation') < states('variable.max_sun_position')|float * (0.96-(((now().month-6)*2)/100)|abs)

Amazing, thank you! I didn’t know the difference between filter and function, but now I guess I do. It worked as expected, so thanks a lot!