Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug in price modifier template #16

Closed
KrzysztofHajdamowicz opened this issue Dec 21, 2024 · 3 comments
Closed

Bug in price modifier template #16

KrzysztofHajdamowicz opened this issue Dec 21, 2024 · 3 comments

Comments

@KrzysztofHajdamowicz
Copy link

Situation from right now, 21.12.2024, hour 21:20

https://tge.pl/energia-elektryczna-rdn?dateShow=20-12-2024&dateAction=prev
At 21.12.2024 21:20, that's between 21 and 22 price is 25gr/kWh
Integration without price modifier template shows correct 25gr/kWh.

When you apply price modifier template for Fixing 1 Rate

{% set s = {
    "VAT": 1.23,
    "offpeak_distribution_rate": 9.028,
    "peak_distribution_rate": 36.898,
    "market_access_fee": 8.8
    }
%}

{# Define peak periods for G12W tariff as a list of tuples (start_hour, stop_hour) #}
{% set peaks = [(6, 13), (15, 22)] %}

{# Determine if it's a weekend (offpeak all day) #}
{% set is_weekend = now().weekday() >= 5 %}

{# Check if the current time falls within any peak period #}
{% set is_peak = False %}
{% if not is_weekend %}
    {% for peak in peaks %}
        {% if now().hour >= peak[0] and now().hour < peak[1] %}
            {% set is_peak = True %}
        {% endif %}
    {% endfor %}
{% endif %}

{# Set distribution rate based on peak or offpeak time #}
{% set distribution_rate = s.peak_distribution_rate if is_peak else s.offpeak_distribution_rate %}

{# Final price calculation: convert current_price to PLN, add distribution rate, market access fee, and apply VAT #}
{{ (fixing1_rate + distribution_rate + s.market_access_fee)| float }}

Integration returns price 26,783, which is incorrect.
25 + 9.028 + 8.8 = 42,828

@KrzysztofHajdamowicz
Copy link
Author

OK, another permutation.

25gr/kWh + distribution rate = 34.028
Integration shows 25,903, looks like 9.028 is miscalculated inside integration. and shows at .903

@KrzysztofHajdamowicz
Copy link
Author

I can confirm that any value in s dictionary multiplied by x10 (so moving comma one place to the right) caused correct value displayed by integration

@PiotrMachowski
Copy link
Owner

This functionality works as designed - all calculations are performed in zł/MWh and MWh and templates should return values in the same units. Conversion to user-configured units is performed later.

Documentation and config flow improvements have been released in v1.1.2

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants