Belgium’s/Flanders capacity consumption
I created a blueprint to calculate capacity consumption in Flanders. I used some automations since late 2022. Since April 2023, I have had a digital meter and all calculations are reasonably correct (accurate to ±50 Wh).
As some colleagues have requested the automation, I made a blueprint of it. And hopefully I can help more persons with it.
What’s present:
- Monthly tracking of maximum consumption for the month (choice to start from 0 or 2.5kWh)
- Total last year average (keep in mind minimum of 2.5kWh)
- Maximum peak of the month (reset monthly)
- Current actual consumption converted to an hour
- Warning and alarm boolean in case of excessive consumption
The blueprint uses a lot of helpers to keep track of the data. Not all helpers are mandatory.
Attention, everything is in kWh !!!
To start, a utility meter must be created where the current consumption of the digital meter must be linked and set to reset every 15min.
The following helpers (input_numbers) are mandatory:
- Maximum : maximum consumption of the current month (resets to 0 every month)
- Each month : maximum consumption of each month
The following helpers (input_numbers) are optional:
- Actual : current quarter consumption converted to hourly value
- Average : average consumption of the last 12 months
The following helpers (input_booleans) are optional:
- Warning : if the quarter consumption reaches the warning threshold, the boolean comes high
- Alarm : if the quarter consumption reaches the alarm threshold, the boolean comes high
Blueprint or GitHub
blueprint:
name: Belgium's/Flanders capacity consumption
description: Calculates the maximum capacity consumption per month and the average of the last year
domain: automation
input:
utility_sensor:
name: Utility meter quarterly consumption *
description: Create a utility meter where the actual consumption of electricity is reset every 15 minutes
selector:
entity:
domain: sensor
device_class: energy
minimum:
name: Minimum value quarter consumption *
description: Minimum defined quarter consumption
default: 2.5
selector:
number:
min: 0
max: 10
step: 0.1
unit_of_measurement: kWh
reset_minimum:
name: Reset with minimum defined quarter consumption *
description: Reset monthly data with the minimum defined quarter consumption (off=0 | on=quarter consumption)
default: true
selector:
boolean:
maximum_helper:
name: Maximum *
description: Numerical helper for maximum consumption for the actual month (kWh)
selector:
entity:
domain: input_number
actual_helper:
name: Actual (optional)
description: Numerical helper for actual consumption for the current quarter (kWh)
default: []
selector:
entity:
domain: input_number
average_helper:
name: Average (optional)
description: Numerical helper for average consumption for the last year (kWh)
default: []
selector:
entity:
domain: input_number
month_01_helper:
name: January *
description: Numerical helper for maximum consumption for the month of January (kWh)
selector:
entity:
domain: input_number
month_02_helper:
name: February *
description: Numerical helper for maximum consumption for the month of February (kWh)
selector:
entity:
domain: input_number
month_03_helper:
name: March *
description: Numerical helper for maximum consumption for the month of March (kWh)
selector:
entity:
domain: input_number
month_04_helper:
name: April *
description: Numerical helper for maximum consumption for the month of April (kWh)
selector:
entity:
domain: input_number
month_05_helper:
name: May *
description: Numerical helper for maximum consumption for the month of May (kWh)
selector:
entity:
domain: input_number
month_06_helper:
name: June *
description: Numerical helper for maximum consumption for the month of June (kWh)
selector:
entity:
domain: input_number
month_07_helper:
name: July *
description: Numerical helper for maximum consumption for the month of July (kWh)
selector:
entity:
domain: input_number
month_08_helper:
name: August *
description: Numerical helper for maximum consumption for the month of August (kWh)
selector:
entity:
domain: input_number
month_09_helper:
name: September *
description: Numerical helper for maximum consumption for the month of September (kWh)
selector:
entity:
domain: input_number
month_10_helper:
name: October *
description: Numerical helper for maximum consumption for the month of October (kWh)
selector:
entity:
domain: input_number
month_11_helper:
name: November *
description: Numerical helper for maximum consumption for the month of November (kWh)
selector:
entity:
domain: input_number
month_12_helper:
name: December *
description: Numerical helper for maximum consumption for the month of December (kWh)
selector:
entity:
domain: input_number
warning_value:
name: Warning value (optional)
description: Activate warning boolean helper from this value
default: 2.0
selector:
number:
min: 0
max: 50
step: 0.1
unit_of_measurement: kWh
warning_helper:
name: Warning (optional)
description: Boolean helper for warning consumption for the current quarter is above the limit (boolean)
default: []
selector:
entity:
domain: input_boolean
alarm_value:
name: Alarm value (optional)
description: Activate alarm boolean helper from this value
default: 2.5
selector:
number:
min: 0
max: 50
step: 0.1
unit_of_measurement: kWh
alarm_helper:
name: Alarm (optional)
description: Boolean helper for alarm consumption for the current quarter is above the limit (boolean)
default: []
selector:
entity:
domain: input_boolean
variables:
minimum_value: !input minimum
warning_value: !input warning_value
alarm_value: !input alarm_value
utility_sensor: !input utility_sensor
maximum_helper: !input maximum_helper
average_helper: !input average_helper
actual_helper: !input actual_helper
month_01_helper: !input month_01_helper
month_02_helper: !input month_02_helper
month_03_helper: !input month_03_helper
month_04_helper: !input month_04_helper
month_05_helper: !input month_05_helper
month_06_helper: !input month_06_helper
month_07_helper: !input month_07_helper
month_08_helper: !input month_08_helper
month_09_helper: !input month_09_helper
month_10_helper: !input month_10_helper
month_11_helper: !input month_11_helper
month_12_helper: !input month_12_helper
warning_helper: !input warning_helper
alarm_helper: !input alarm_helper
reset_minimum: !input reset_minimum
reset_minimum_value: "{{ minimum_value if reset_minimum else 0 }}"
month_01_value: "{{ (states[month_01_helper].state | float(default=0)) if (states[month_01_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_02_value: "{{ (states[month_02_helper].state | float(default=0)) if (states[month_02_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_03_value: "{{ (states[month_03_helper].state | float(default=0)) if (states[month_03_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_04_value: "{{ (states[month_04_helper].state | float(default=0)) if (states[month_04_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_05_value: "{{ (states[month_05_helper].state | float(default=0)) if (states[month_05_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_06_value: "{{ (states[month_06_helper].state | float(default=0)) if (states[month_06_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_07_value: "{{ (states[month_07_helper].state | float(default=0)) if (states[month_07_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_08_value: "{{ (states[month_08_helper].state | float(default=0)) if (states[month_08_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_09_value: "{{ (states[month_09_helper].state | float(default=0)) if (states[month_09_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_10_value: "{{ (states[month_10_helper].state | float(default=0)) if (states[month_10_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_11_value: "{{ (states[month_11_helper].state | float(default=0)) if (states[month_11_helper].state | float(default=0)) > minimum_value else minimum_value }}"
month_12_value: "{{ (states[month_12_helper].state | float(default=0)) if (states[month_12_helper].state | float(default=0)) > minimum_value else minimum_value }}"
capacity_hour_utility: "{{ states[utility_sensor].state | float(default=0) * 4 }}"
capacity_hour_helper: "{{ states[maximum_helper].state | float(default=0) }}"
capacity_hour_max: "{{ capacity_hour_utility > capacity_hour_helper }}"
capacity_average: "{{ (month_01_value + month_02_value + month_03_value + month_04_value + month_05_value + month_06_value + month_07_value + month_08_value + month_09_value + month_10_value + month_11_value + month_12_value ) / 12 }}"
average_enabled: "{{ average_helper | length > 0 }}"
actual_enabled: "{{ actual_helper | length > 0 }}"
warning_enabled: "{{ warning_helper | length > 0 }}"
warning_state: "{{ capacity_hour_utility > warning_value }}"
alarm_enabled: "{{ alarm_helper | length > 0 }}"
alarm_state: "{{ capacity_hour_utility > alarm_value }}"
trigger:
# Reset maximum en month value (Only reset when the new month is in progress as 1 minute to avoid problems and overlap)
- platform: time
at: "00:01:00"
id: RESET
# Calculate the MAX
- platform: state
entity_id: !input utility_sensor
id: UTILITY_CHANGE
# Calculate average
- platform: state
entity_id: !input maximum_helper
id: MAXIMUM_CHANGE
action:
choose:
# RESET
- conditions:
- condition: trigger
id: RESET
sequence:
- if:
- condition: template
value_template: "{{ now().day == 1 }}"
then:
- choose:
- conditions:
- condition: template
value_template: "{{ now().month == 1 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_01_helper
- conditions:
- condition: template
value_template: "{{ now().month == 2 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_02_helper
- conditions:
- condition: template
value_template: "{{ now().month == 3 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_03_helper
- conditions:
- condition: template
value_template: "{{ now().month == 4 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_04_helper
- conditions:
- condition: template
value_template: "{{ now().month == 5 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_05_helper
- conditions:
- condition: template
value_template: "{{ now().month == 6 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_06_helper
- conditions:
- condition: template
value_template: "{{ now().month == 7 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_07_helper
- conditions:
- condition: template
value_template: "{{ now().month == 8 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_08_helper
- conditions:
- condition: template
value_template: "{{ now().month == 9 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_09_helper
- conditions:
- condition: template
value_template: "{{ now().month == 10 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_10_helper
- conditions:
- condition: template
value_template: "{{ now().month == 11 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_11_helper
- conditions:
- condition: template
value_template: "{{ now().month == 12 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ reset_minimum_value }}"
target:
entity_id: !input month_12_helper
# UTILITY CHANGE
- conditions:
- condition: trigger
id: UTILITY_CHANGE
sequence:
- if:
- condition: template
value_template: "{{ capacity_hour_max }}"
then:
- choose:
- conditions:
- condition: template
value_template: "{{ now().month == 1 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_01_helper
- conditions:
- condition: template
value_template: "{{ now().month == 2 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_02_helper
- conditions:
- condition: template
value_template: "{{ now().month == 3 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_03_helper
- conditions:
- condition: template
value_template: "{{ now().month == 4 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_04_helper
- conditions:
- condition: template
value_template: "{{ now().month == 5 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_05_helper
- conditions:
- condition: template
value_template: "{{ now().month == 6 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_06_helper
- conditions:
- condition: template
value_template: "{{ now().month == 7 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_07_helper
- conditions:
- condition: template
value_template: "{{ now().month == 8 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_08_helper
- conditions:
- condition: template
value_template: "{{ now().month == 9 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_09_helper
- conditions:
- condition: template
value_template: "{{ now().month == 10 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_10_helper
- conditions:
- condition: template
value_template: "{{ now().month == 11 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_11_helper
- conditions:
- condition: template
value_template: "{{ now().month == 12 }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input month_12_helper
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input maximum_helper
- parallel:
- if:
- condition: template
value_template: "{{ actual_enabled }}"
then:
- service: input_number.set_value
data:
value: "{{ capacity_hour_utility }}"
target:
entity_id: !input actual_helper
- if:
- condition: template
value_template: "{{ warning_enabled }}"
then:
- if:
- condition: template
value_template: "{{ warning_state }}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: !input warning_helper
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: !input warning_helper
- if:
- condition: template
value_template: "{{ alarm_enabled }}"
then:
- if:
- condition: template
value_template: "{{ alarm_state }}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: !input alarm_helper
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: !input alarm_helper
# AVERAGE
- conditions:
- condition: trigger
id: MAXIMUM_CHANGE
- condition: template
value_template: "{{ average_enabled }}"
sequence:
- service: input_number.set_value
data:
value: "{{ capacity_average }}"
target:
entity_id: !input average_helper
mode: parallel
max: 3