Skip to content

Instantly share code, notes, and snippets.

@k0ff33
Last active October 1, 2025 11:49
Show Gist options
  • Save k0ff33/113b943f7ed8a9ae3de8bf6333bc48bd to your computer and use it in GitHub Desktop.
Save k0ff33/113b943f7ed8a9ae3de8bf6333bc48bd to your computer and use it in GitHub Desktop.
Home Assistant: PGE G12 2025 Energy price integration
# G12 Tariff Configuration - Poland
# Summer (Apr 1 - Sep 30): Day 06:00-15:00, 17:00-22:00 | Night 15:00-17:00, 22:00-06:00
# Winter (Oct 1 - Mar 31): Day 06:00-13:00, 15:00-22:00 | Night 13:00-15:00, 22:00-06:00
- sensor:
# G12 Tariff Mode - Single source of truth for tariff logic
- name: 'G12 Tariff Mode'
unique_id: g12_tariff_mode
icon: >
{% set h = now().hour %}
{% set m = now().month %}
{% set is_winter = m in [10, 11, 12, 1, 2, 3] %}
{% if is_winter %}
{% set is_night = (h >= 13 and h < 15) or (h >= 22 or h < 6) %}
{% else %}
{% set is_night = (h >= 15 and h < 17) or (h >= 22 or h < 6) %}
{% endif %}
{{ 'mdi:moon-waning-crescent' if is_night else 'mdi:white-balance-sunny' }}
state: >
{% set h = now().hour %}
{% set m = now().month %}
{% set is_winter = m in [10, 11, 12, 1, 2, 3] %}
{% if is_winter %}
{% set is_night = (h >= 13 and h < 15) or (h >= 22 or h < 6) %}
{% else %}
{% set is_night = (h >= 15 and h < 17) or (h >= 22 or h < 6) %}
{% endif %}
{{ 'night' if is_night else 'day' }}
attributes:
season: >
{% set m = now().month %}
{{ 'summer' if (m >= 4 and m <= 9) else 'winter' }}
# Current electricity price based on G12 tariff schedule - depends on tariff mode
- name: 'G12 Energy Price'
unique_id: grid_energy_price_g12
unit_of_measurement: 'PLN/kWh'
icon: mdi:cash
state: >
{{ 0.70 if is_state('sensor.g12_tariff_mode', 'night') else 1.16 }}
attributes:
season: "{{ state_attr('sensor.g12_tariff_mode', 'season') }}"
@k0ff33
Copy link
Author

k0ff33 commented Oct 1, 2025

Add template: !include templates.yaml to configuration.yaml.

Then use grid_energy_price_g12 in Energy tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment