Jeg løste det med å samle følgende i en linje:
{% if now().weekday() in (0,1,2,3,4) %}
{% if now().hour >=6 and now().hour <22 %}
additional_costs: '{% set s = {
"grid_day": 0.4310,
"grid_night_weekend": 0.3685,
"grid_yearly_cost": 2400,
"psub_monthly_cost": 49,
"psub_kwh_cost": 0.0695
}
%}
{% if now().weekday() in (0,1,2,3,4) and now().hour >=6 and now().hour <22 %}
{% set fixed_cost = (((s.grid_yearly_cost+(12*s.psub_monthly_cost))/365)/24)|float %}{{(s.grid_day+s.psub_kwh_cost)+fixed_cost|float }}
{% else %}
{% set fixed_cost = (((s.grid_yearly_cost+(12*s.psub_monthly_cost))/365)/24)|float %}{{(s.grid_night_weekend+s.psub_kwh_cost)+fixed_cost|float }}
{% endif %}'