Tutorial: set the Tiered rate billing mode in the Home assistant

How to set the Tiered electricity price billing mode in the Home Assistant

Abstract: use one energy meter (brand IAMMETER) to show how to set the Tiered electricity price billing mode in the Home assistant.

Please note: this is a universal tutorial about setting the Tiered electricity price billing template in the Home Assistant. It does not ask to use a specific brand of energy meter.

Video tutorial: set the tiered rate billing mode in the home assistant

This is the effect of displaying the Tiered electricity price billing information in the dashboard.

20221218223145

 

Integrate Energy meter

In this chapter, we use IAMMETER`s energy meter as the example hardware. This tutorial is not related to a specific brand, you can use your own energy meter in your hand.

Add the repository of IAMMETER from the HACS

Click HACS, search "IAMMETER".

image-20221104114959701

image-20221104115111335

image-20221104115145017

 

Add Energy meter

Setting->"Device & Service"

image-20221219103436776

image-20221104115920426

image-20221104120238430

image-20221209160914651

 

image-20221209160952222

image-20221209161015246

 

Add the Tiered electricity price billing template from a Yaml file.

click "File editor"

image-20221209161145643

add a new YAML, named "tiered.yaml"

image-20221219103916707

Add the following configuration in "tiered.yaml"

You can also download the "tiered.yaml" from the github here





# Example configuration entry
sensor:  
  - platform: template
    sensors:
#------Tiered electricity price------#
      energy_price_tier1:
        friendly_name: "Tier1 Price"
        value_template: "0.15"
        unit_of_measurement: '$'
      energy_price_tier2:
        friendly_name: "Tier2 Price"
        value_template: "0.19"
        unit_of_measurement: '$'
      energy_price_tier3:
        friendly_name: "Tier3 Price"
        value_template: "0.28"
        unit_of_measurement: '$'
      energy_price_tier4:
        friendly_name: "Tier4 Price"
        value_template: "0.32"
        unit_of_measurement: '$'
      energy_tier1:
        friendly_name: "Tier1 Energy"
        value_template: "100"
        unit_of_measurement: 'kWh'
      energy_tier2:
        friendly_name: "Tier2 Energy"
        value_template: "200"
        unit_of_measurement: 'kWh'
      energy_tier3:
        friendly_name: "Tier3 Energy"
        value_template: "300"
        unit_of_measurement: 'kWh'
      energy_tiered_price_current: 
        friendly_name: "Current Tiered Price"
        unit_of_measurement: '$'
        value_template: >-
          {% if states('sensor.meter_energy_monthly') > states('sensor.energy_tier3') %}
            {{ states('sensor.energy_price_tier4') }}
          {% elif states('sensor.meter_energy_monthly') > states('sensor.energy_tier2') %}
            {{ states('sensor.energy_price_tier3') }}
          {% elif states('sensor.meter_energy_monthly') > states('sensor.energy_tier1') %}
            {{ states('sensor.energy_price_tier2') }}
          {% else %}
            {{ states('sensor.energy_price_tier1') }}
          {% endif %}
      energy_tiered_current: 
        friendly_name: "Current Tiered"
        value_template: >-
          {% if states('sensor.meter_energy_monthly') > states('sensor.energy_tier3') %}
            {{ "tier4" }}
          {% elif states('sensor.meter_energy_monthly') > states('sensor.energy_tier2') %}
            {{ "tier3" }}
          {% elif states('sensor.meter_energy_monthly') > states('sensor.energy_tier1') %}
            {{ "tier2" }}
          {% else %}
            {{ "tier1" }}
          {% endif %}
      daily_energy_tier_money:
        unit_of_measurement: '$'
        value_template: "{{ ( (states('sensor.meter_energy_daily')|float) * (states('sensor.energy_tiered_price_current')|float) ) | round(2) }}"       
      monthly_energy_tier1_money:
        unit_of_measurement: '$'
        value_template: >-
          {% if states('sensor.meter_energy_monthly') > states('sensor.energy_tier1') %}
            {{ ( states('sensor.energy_tier1')|float * states('sensor.energy_price_tier1')|float ) | round(2) }}
          {% else %}
            {{ ( states('sensor.meter_energy_monthly')|float * states('sensor.energy_price_tier1')|float ) | round(2) }}
          {% endif %}
      monthly_energy_tier2_money:
        unit_of_measurement: '$'
        value_template: >-
          {% if states('sensor.meter_energy_monthly') > states('sensor.energy_tier2') %}
            {{ ( (states('sensor.energy_tier2')|float - states('sensor.energy_tier1')|float ) * states('sensor.energy_price_tier2')|float + states('sensor.monthly_energy_tier1_money')|float ) | round(2) }}
          {% elif states('sensor.meter_energy_monthly') > states('sensor.energy_tier1') %}
            {{ ( (states('sensor.meter_energy_monthly')|float -states('sensor.energy_tier1')|float ) * states('sensor.energy_price_tier2')|float + states('sensor.monthly_energy_tier1_money')|float ) | round(2) }}
          {% else %}
            {{ 0 }}
          {% endif %}
      monthly_energy_tier3_money:
        unit_of_measurement: '$'
        value_template: >-
          {% if states('sensor.meter_energy_monthly') > states('sensor.energy_tier3') %}
            {{ ( (states('sensor.energy_tier3')|float -states('sensor.energy_tier2')|float ) * states('sensor.energy_price_tier3')|float + states('sensor.monthly_energy_tier2_money')|float ) | round(2) }}
          {% elif states('sensor.meter_energy_monthly') > states('sensor.energy_tier2') %}
            {{ ( (states('sensor.meter_energy_monthly')|float -states('sensor.energy_tier2')|float ) * states('sensor.energy_price_tier3')|float + states('sensor.monthly_energy_tier2_money')|float ) | round(2) }}
          {% else %}
            {{ 0 }}
          {% endif %}
      monthly_energy_tier4_money:
        unit_of_measurement: '$'
        value_template: >-
          {% if states('sensor.meter_energy_monthly') > states('sensor.energy_tier3') %}
            {{ ( (states('sensor.meter_energy_monthly')|float -states('sensor.energy_tier3')|float ) * states('sensor.energy_price_tier4')|float + states('sensor.monthly_energy_tier3_money')|float ) | round(2) }}
          {% else %}
            {{ 0 }}
          {% endif %}
      monthly_energy_tier_money:
        unit_of_measurement: '$'
        value_template: "{{ (states('sensor.monthly_energy_tier1_money')|float + states('sensor.monthly_energy_tier2_money')|float + states('sensor.monthly_energy_tier3_money')|float + states('sensor.monthly_energy_tier4_money')|float)|round(2) }}"
##  m1 : >100 E1 * P1
##       else E * P1
##  m2 : >200 (E2-E1) * P2 + m1
##       >100 (E-E1) * P2 + m1
##       else 0
##  m3 : >300 (E3-E2) *P3 + m2
##       >200 (E-E2) *P3 + m2
##       else 0
##  m4 :
##       >300 (E-E3) *P4 + m3
##       else 0
##  m  : m1 + m2 +m3 + m4
 
utility_meter:
  meter_energy_daily:
    source: sensor.meter_importenergy
    cycle: daily
  meter_energy_monthly:
    source: sensor.meter_importenergy
    cycle: monthly


CHECK CONFIGURATION, RESTART

image-20221209162317735

Configure the Dashboard(optional)

This chapter just gives a dashboard example to show the Tiered electricity price billing effect. It is not a necessary step for the Tiered electricity price billing, you can also use your own dashboard to display the Tiered electricity price effect.

image-20221219104254091

Add the following cards to Lovelace

Card1

image-20221219104337502





cards:
  - cards:
      - entity: sensor.meter_voltage
        max: 300
        min: 100
        name: voltage
        theme: default
        type: gauge
        needle: false
      - entity: sensor.meter_power
        max: 5000
        min: 0
        name: power
        theme: default
        type: gauge
        needle: false
    type: horizontal-stack
  - type: custom:apexcharts-card
    apex_config:
      chart:
        height: 300
    experimental:
      color_threshold: true
    graph_span: 8h
    show:
      last_updated: true
    header:
      standard_format: false
      show: true
      show_states: true
      colorize_states: true
    now:
      show: true
      color: red
      label: Now
    span:
      end: hour
    series:
      - entity: sensor.meter_power
        name: Power
        type: line
        group_by:
          func: avg
          duration: 1m
        stroke_width: 2
        show:
          extremas: true
          header_color_threshold: true
        color_threshold:
          - value: 100
            color: steelblue
          - value: 800
            color: midnightblue
          - value: 1500
            color: orange
          - value: 2000
            color: orangered
          - value: 3000
            color: red
  - type: custom:apexcharts-card
    apex_config:
      chart:
        height: 300
    experimental:
      color_threshold: true
    graph_span: 8h
    show:
      last_updated: true
    header:
      standard_format: false
      show: true
      show_states: true
      colorize_states: true
    now:
      show: true
      color: red
      label: Now
    span:
      end: hour
    series:
      - entity: sensor.meter_voltage
        name: Voltage
        stroke_width: 2
        group_by:
          func: avg
          duration: 1min
title: Home Energy Tiered Demo
type: vertical-stack


Card2

image-20221219104505958





cards:
  - type: custom:apexcharts-card
    apex_config:
      chart:
        height: 230
    graph_span: 7d
    span:
      end: day
    show:
      last_updated: true
    header:
      show: true
      show_states: true
      colorize_states: true
    series:
      - entity: sensor.meter_energy_daily
        type: column
        color: darkviolet
        group_by:
          func: max
          duration: 1d
      - entity: sensor.daily_energy_tier_money
        type: column
        group_by:
          func: max
          duration: 1d
  - type: custom:apexcharts-card
    apex_config:
      chart:
        height: 230
    graph_span: 3month
    span:
      end: year
    show:
      last_updated: true
    header:
      show: true
      show_states: true
      colorize_states: true
    series:
      - entity: sensor.meter_energy_monthly
        type: column
        color: darkviolet
        group_by:
          func: max
          duration: 1month
      - entity: sensor.monthly_energy_tier_money
        type: column
        color: slateblue
        group_by:
          func: max
          duration: 1month
  - type: custom:apexcharts-card
    header:
      show: true
      title: tier
      show_states: true
      colorize_states: true
    apex_config:
      chart:
        stacked: true
      dataLabels:
        enabled: true
        enabledOnSeries: true
    graph_span: 2d
    span:
      end: day
    show:
      last_updated: true
    series:
      - entity: sensor.monthly_energy_tier1_money
        name: tier1
        type: column
        color: darkviolet
        group_by:
          func: max
          duration: 1d
      - entity: sensor.monthly_energy_tier2_money
        name: tier2
        type: column
        color: slateblue
        group_by:
          func: max
          duration: 1d
      - entity: sensor.monthly_energy_tier3_money
        name: tier3
        type: column
        color: orangered
        group_by:
          func: max
          duration: 1d
      - entity: sensor.monthly_energy_tier4_money
        name: tier4
        type: column
        group_by:
          func: max
          duration: 1d
title: Energy
type: vertical-stack


Card3

image-20221219104557911





cards:
  - type: horizontal-stack
    cards:
      - animate: true
        entities:
          - entity: sensor.meter_voltage
        group_by: hour
        hour24: true
        hours_to_show: 12
        type: custom:mini-graph-card
      - animate: true
        entities:
          - entity: sensor.meter_power
        group_by: hour
        hour24: true
        hours_to_show: 12
        type: custom:mini-graph-card
  - type: horizontal-stack
    cards:
      - type: entity
        entity: sensor.meter_energy_monthly
        name: Current Tier
        state_color: false
      - type: entity
        entity: sensor.monthly_energy_tier_money
        name: Current Tiered Price
        state_color: false
        icon: mdi:currency-usd
  - type: horizontal-stack
    cards:
      - type: entity
        entity: sensor.energy_tiered_current
        name: Current Tier
        state_color: false
      - type: entity
        entity: sensor.energy_tiered_price_current
        name: Current Tiered Price
        state_color: false
        icon: mdi:currency-usd
  - type: horizontal-stack
    cards:
      - hours_to_show: 24
        graph: none
        type: sensor
        entity: sensor.energy_tier1
        name: Tier1
        detail: 1
        icon: mdi:numeric-1-box-outline
      - type: sensor
        entity: sensor.energy_tier2
        name: Tier2
        icon: mdi:numeric-2-box-outline
      - type: sensor
        entity: sensor.energy_tier3
        name: Tier3
        icon: mdi:numeric-3-box-outline
    title: Tiered electricity price list
  - type: horizontal-stack
    cards:
      - hours_to_show: 24
        graph: none
        type: sensor
        entity: sensor.energy_price_tier1
        name: Tier1
        detail: 1
        icon: mdi:numeric-1-box-outline
      - type: sensor
        entity: sensor.energy_price_tier2
        name: Tier2
        icon: mdi:numeric-2-box-outline
      - type: sensor
        entity: sensor.energy_price_tier3
        name: Tier3
        icon: mdi:numeric-3-box-outline
      - type: sensor
        entity: sensor.energy_price_tier4
        name: Tier4
        icon: mdi:numeric-4-box-outline
  - type: horizontal-stack
    cards:
      - aggregate_func: max
        animate: true
        entities:
          - entity: sensor.meter_energy_daily
        group_by: date
        hour24: true
        hours_to_show: 168
        show:
          graph: bar
        type: custom:mini-graph-card
  - type: horizontal-stack
    cards:
      - aggregate_func: max
        animate: true
        entities:
          - entity: sensor.daily_energy_tier_money
        group_by: date
        hour24: true
        hours_to_show: 168
        show:
          graph: bar
        type: custom:mini-graph-card
type: vertical-stack


image-20221219104705847

 

Reference

set the TOU(time of use) billing mode in the home assistant

How to use IAMMETER`s energy meter into the home assistant

IAMMETER supports more power tariff templates(fixed, tiered,time of use etc...)

Thread Status
0
1055
1
0
0

Sort replies by:
Looks like you are new here. Register for free, learn and contribute.