JAH
-
Innlegg
2 -
Ble med
-
Besøkte siden sist
Innholdstype
Profiler
Forum
Blogger
Nedlastninger
Artikler
Regler
Hendelser
Galleri
Store
Innlegg skrevet av JAH
-
-
Hei
Jeg trenger litt hjelp med additional costs.
Har søkt litt rundt, kopiert litt kode og kommet frem til dette, som baserer seg på Elvia og min strøm leverandør.
I configuration.yaml :
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.6950 } %} {% if now().weekday() in (0,1,2,3,4) %} {% if 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 %} {% endif %}'
Det ser ut om koden etter "else" ikke blir kjørt, så får ikke noe verdi i helga.
Nordpool sensor for Home Assistant
i Home Assistant
Skrevet
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 %}'