Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template:
- - sensor:
- - name: "Elektrihinna Arvutus"
- state: >
- {% set peak_price_weekday = 0.0818 %}
- {% set peak_price_weekend = 0.0474 %}
- {% set day_price = 0.0529 %}
- {% set night_price = 0.0303 %}
- {% set monthly_fee = 19.84 %}
- {% set current_time = now() %}
- {% set current_hour = current_time.hour %}
- {% set current_day = current_time.strftime('%A') %}
- {% set total_cost = monthly_fee %}
- {% if current_day in ['Saturday', 'Sunday'] %}
- {% if current_hour >= 16 and current_hour < 20 %}
- {% set total_cost = total_cost + peak_price_weekend %}
- {% elif current_hour >= 7 and current_hour < 22 %}
- {% set total_cost = total_cost + day_price %}
- {% else %}
- {% set total_cost = total_cost + night_price %}
- {% endif %}
- {% else %}
- {% if (current_hour >= 9 and current_hour < 12) or (current_hour >= 16 and current_hour < 20) %}
- {% set total_cost = total_cost + peak_price_weekday %}
- {% elif current_hour >= 7 and current_hour < 22 %}
- {% set total_cost = total_cost + day_price %}
- {% else %}
- {% set total_cost = total_cost + night_price %}
- {% endif %}
- {% endif %}
- {{ total_cost | round(2) }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement