Based on Tauron koszty a taryfa g13 - Node-RED - ArturHome describing the counting of electricity consumption in the 3 zone Polish energy provider Tauron G13 tariff, I made changes to take into account the discontinuation of utility_meter.select_tariff support and add support for Energy dashboard for actual energy price.
At first, in binary_sensors.yaml we will define working days and holidays. For the G13 tariff, free days (off peak tariff) are Saturday, Sunday, and holidays falling on weekdays.
- platform: workday
country: PL
workdays: [mon, tue, wed, thu, fri].
excludes: [sat, sun, holiday]
add_holidays:
- "2023-01-06"
- "2023-04-10"
- "2023-05-01"
- "2023-05-03"
- "2023-06-08"
- "2023-08-15"
- "2023-12-25"
- "2023-12-26"
As the source of the consumed current, I adopted sensor.electricity_meter_total_forward_active_energy, which contains information from the meter about the amount of energy consumed from the operator. In my installation I use Zamel MEW-01 meter for this: MONITOR ENERGII ELEKTRYCZNEJ WI-FI 3F+N TYP: MEW-01
This meter in sensor.elecricity_meter_total_forward_active_energy gives me the value of energy consumed at a given moment after deducting the production from the solar installation, so it is the real consumption at a given moment. The data is sent to HA via Supla Cloud integration to HA mqtt broker.
In configuration.yaml I create meters that count our energy by time tariff:
utility_meter:
energy_mew_daily_usage:
source: sensor.electricity_meter_total_forward_active_energy
name: energy_mew_daily_usage
cycle: daily
tariffs:
- morning_peak
- afternoon_peak
- offpeak
energy_mew_monthly_usage:
source: sensor.electricity_meter_total_forward_active_energy
name: energy_mew_monthly_usage
cycle: monthly
tariffs:
- morning_peak
- afternoon_peak
- offpeak
energy_mew_yearly_usage:
source: sensor.electricity_meter_total_forward_active_energy
name: energy_mew_yearly_usage
cycle: yearly
tariffs:
- morning_peak
- afternoon_peak
- offpeak
energy_mew_daily_reverse:
source: sensor.electricity_meter_total_reverse_active_energy
name: energy_mew_daily_reverse
cycle: daily
tariffs:
- morning_peak
- afternoon_peak
- offpeak
energy_mew_monthly_zwrot:
source: sensor.electricity_meter_total_reverse_active_energy
name: energy_mew_monthly_reverse
cycle: monthly
tariffs:
- morning_peak
- afternoon_peak
- offpeak
energy_mew_yearly_reverse:
source: sensor.electricity_meter_total_reverse_active_energy
name: energy_mew_yearly_reverse
cycle: yearly
tariffs:
- morning_peak
- afternoon_peak
- offpeak
In addition, I tally up my costs by day/month/year. Costs quoted include Tauron 2023 market price (excludes first 2 MWh with lower tariff) and all fees (included energy transfer) with tax: https://www.tauron.pl/-/media/offer-documents/produkty/prad-z-serwisantem-dokumenty/ts/wyciag-typu-g-z-taryfy-td-sa-na-rok-2021.ashx
In configuration.yaml I add template sensor with energy cost:
sensor:
- platform: template
sensors:
# Energy daily cost
mew_daily_cost_morning:
friendly_name: 'MEW Daily Cost Morning'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.energy_mew_daily_usage_morning_peak')|float * 1.1455) - (states('sensor.energy_mew_daily_reverse_morning_peak')|float * 0.8585 * 0.8))| round(2) }}"
mew_daily_cost_afternoon:
friendly_name: 'MEW Daily Cost Afternoon'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.energy_mew_daily_usage_afternoon_peak')|float * 1.3388) - (states('sensor.energy_mew_daily_reverse_afternoon_peak')|float * 0.8585 * 0.8))| round(2) }}"
mew_daily_cost_offpeak:
friendly_name: 'MEW Daily Cost Offpeak'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.energy_mew_daily_usage_offpeak')|float * 0.9409) - (states('sensor.energy_mew_daily_reverse_offpeak')|float * 0.8585 * 0.8))| round(2) }}"
mew_daily_cost_total:
friendly_name: 'MEW Daily Cost Total'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.mew_daily_cost_morning')|float + states('sensor.mew_daily_cost_afternoon')|float + states('sensor.mew_daily_cost_offpeak')|float) | round(2)) }}"
mew_daily_usage_total:
friendly_name: 'MEW Daily Usage Total'
unit_of_measurement: 'kWh'
device_class: 'energy'
value_template: "{{ ((states('sensor.energy_mew_daily_usage_morning_peak')|float + states('sensor.energy_mew_daily_usage_afternoon_peak')|float + states('sensor.energy_mew_daily_usage_offpeak')|float - states('sensor.energy_mew_daily_reverse_morning_peak')|float - states('sensor.energy_mew_daily_reverse_afternoon_peak')|float - states('sensor.energy_mew_daily_reverse_offpeak')|float) | round(2)) }}"
# Energy monthly cost
mew_monthly_cost_morning:
friendly_name: 'MEW Monthly Cost Morning'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.energy_mew_monthly_usage_morning_peak')|float * 1.1455) - (states('sensor.energy_mew_monthly_reverse_morning_peak')|float * 0.8585 * 0.8))| round(2) }}"
mew_monthly_cost_afternoon:
friendly_name: 'MEW Monthly Cost Afternoon'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.energy_mew_monthly_usage_afternoon_peak')|float * 1.3388) - (states('sensor.energy_mew_monthly_reverse_afternoon_peak')|float * 0.8585 * 0.8))| round(2) }}"
mew_monthly_cost_offpeak:
friendly_name: 'MEW Monthly Cost Offpeak'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.energy_mew_monthly_usage_offpeak')|float * 0.9409) - (states('sensor.energy_mew_monthly_reverse_offpeak')|float * 0.8585 * 0.8))| round(2) }}"
mew_monthly_cost_total:
friendly_name: 'MEW Monthly Cost Total'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.mew_monthly_cost_morning')|float + states('sensor.mew_monthly_cost_afternoon')|float + states('sensor.mew_monthly_cost_offpeak')|float ) | round(2)) }}"
mew_monthly_usage_total:
friendly_name: 'MEW Monthly Usage Total'
unit_of_measurement: 'kWh'
device_class: 'energy'
value_template: "{{ ((states('sensor.energy_mew_monthly_usage_morning_peak')|float + states('sensor.energy_mew_monthly_usage_afternoon_peak')|float + states('sensor.energy_mew_monthly_usage_offpeak')|float - states('sensor.energy_mew_monthly_reverse_morning_peak')|float - states('sensor.energy_mew_monthly_reverse_afternoon_peak')|float - states('sensor.energy_mew_monthly_reverse_offpeak')|float) | round(2)) }}"
# Energy monthly cost
mew_yearly_cost_morning:
friendly_name: 'MEW Yearly Cost Morning'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.energy_mew_yearly_usage_morning_peak')|float * 1.1455)- (states('sensor.energy_mew_yearly_reverse_morning_peak')|float * 0.8585 * 0.8))| round(2) }}"
mew_yearly_cost_afternoon:
friendly_name: 'MEW Yearly Cost Afternoon'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.energy_mew_yearly_usage_afternoon_peak')|float * 1.3388) - (states('sensor.energy_mew_yearly_reverse_afternoon_peak')|float * 0.8585 * 0.8))| round(2) }}"
mew_yearly_cost_offpeak:
friendly_name: 'MEW Yearly Cost Offpeak'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.energy_mew_yearly_usage_offpeak')|float * 0.9409) - (states('sensor.energy_mew_yearly_reverse_offpeak')|float * 0.8585 * 0.8))| round(2) }}"
mew_yearly_cost_total:
friendly_name: 'MEW Yearly Cost Total'
unit_of_measurement: 'PLN'
device_class: 'monetary'
value_template: "{{ ((states('sensor.mew_yearly_cost_morning')|float + states('sensor.mew_yearly_cost_afternoon')|float + states('sensor.mew_yearly_cost_offpeak')|float ) | round(2)) }}"
mew_yearly_usage_total:
friendly_name: 'MEW Yearly Usage Total'
unit_of_measurement: 'kWh'
device_class: 'energy'
value_template: "{{ ((states('sensor.energy_mew_yearly_usage_morning_peak')|float + states('sensor.energy_mew_yearly_usage_afternoon_peak')|float + states('sensor.energy_mew_yearly_usage_offpeak')|float - states('sensor.energy_mew_yearly_reverse_morning_peak')|float - states('sensor.energy_mew_yearly_reverse_afternoon_peak')|float - states('sensor.energy_mew_yearly_reverse_offpeak')|float) | round(2)) }}"
mew_current_price:
friendly_name: 'MEW Current Price'
unit_of_measurement: 'PLN/kWh'
device_class: 'energy'
value_template: 0
Finally, we need to create an automation that will switch tariffs for us, so that the created meter will receive data broken down by the hours of the tariff.
Triggers are hours of tariff change, based on winter time tariff, i.e. from 7.00 to 13.00. the morning tariff is switched on, from 16.00 to 21.00. the peak tariff (for the winter season). During the remaining hours, i.e. from 13.00 to 16.00., and on weekends and holidays, the off-peak tariff is in effect.
Winter time is from 1 October to 31 March. Morning tariff is from 7.00 to 13.00, afternoon tariff is from 16.00 to 21.00. Summer time is from 1 April to 30 September. Morning tariff is from 7.00 to 13.00, afternoon tariff is from 19.00 to 22.00. All other time - from 13.00 to 16.00 in winter / from 13.00 to 19.00 in summer and from 13.00 to 19.00 winter / 22.00 to 7.00 in summer + ale weekends and public holidays is night tariff (off peak).
This automation switching tariff based on Winter tariff. You must change it manually into Summer time.
In automations.yaml you must create this automation:
- id: switch_energy_tariffs
alias: Switch energy tariffs
trigger:
- platform: time
at: 07:00:00
- platform: time
at: '13:00:00'
- platform: time
at: '16:00:00'
- platform: time
at: '21:00:00'
action:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- condition: time
after: 07:00:00
before: '13:00:00'
sequence:
- service: select.select_option
data:
option: morning_peak
target:
entity_id:
- select.energy_mew_daily_usage
- select.energy_mew_monthly_usage
- select.energy_mew_yearly_usage
- service: python_script.set_state
data_template:
entity_id: sensor.mew_current_price
state: "{{ 1.1455 }}"
- conditions:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- condition: time
after: '16:00:00'
before: '21:00:00'
sequence:
- service: select.select_option
data:
option: afternoon_peak
target:
entity_id:
- select.energy_mew_daily_usage
- select.energy_mew_monthly_usage
- select.energy_mew_yearly_usage
- service: python_script.set_state
data_template:
entity_id: sensor.mew_current_price
state: "{{ 1.3388 }}"
default:
- service: select.select_option
data:
option: offpeak
target:
entity_id:
- select.energy_mew_daily_usage
- select.energy_mew_monthly_usage
- select.energy_mew_yearly_usage
- service: python_script.set_state
data_template:
entity_id: sensor.mew_current_price
state: "{{ 0.9409 }}"
Then we are free to create a card where we present the results for daily usage and costs. Of course you can also create card form month or year:
type: entities
entities:
- entity: sensor.energy_mew_daily_usage_morning_peak
name: Morning consumption
- entity: sensor.mew_daily_cost_morning
name: Morning cost
- entity: sensor.energy_mew_daily_usage_afternoon_peak
name: Afternoon consumption
- entity: sensor.mew_daily_cost_afternoon
name: Afternoon cost
- entity: sensor.energy_mew_daily_usage_offpeak
name: Night consumption
- entity: sensor.mew_daily_cost_offpeak
name: Night cost
- entity: sensor.mew_daily_cost_total
name: Total cost
title: Energy daily usage and cost
If you can use actual price for calculating costs in Energy dashboard, go to dashboard, chose grid consumption entity and chose “Use entity with current price” and set sensor.mew_current_price.