Closed Vinisz closed 10 months ago
@Vinisz Like the utility_meter option, in a yaml file you can add (examples):
#########################
# IMPORT ENERGY METERS
#
energy_meter:
energy_meter_imported_daily:
unique_id: energy_meter_imported_daily
source: sensor.power_meter_consumption
name: Energy Meter - Imported Daily
cycle: daily
price_entity: sensor.electricity_price
tariffs:
- peak
- shoulder
- offpeak
energy_meter_imported_monthly:
unique_id: energy_meter_imported_monthly
source: sensor.power_meter_consumption
name: Energy Meter - Imported Monthly
cycle: monthly
price_entity: sensor.electricity_price
tariffs:
- peak
- shoulder
- offpeak
energy_meter_imported_yearly:
unique_id: energy_meter_imported_yearly
source: sensor.power_meter_consumption
name: Energy Meter - Imported Yearly
cycle: yearly
price_entity: sensor.electricity_price
tariffs:
- peak
- shoulder
- offpeak
#########################
# EXPORT ENERGY METERS
#
energy_meter_exported_daily:
unique_id: energy_meter_exported_daily
source: sensor.power_meter_exported
name: Energy Meter - Exported Daily
cycle: daily
price: 0.07
energy_meter_exported_monthly:
unique_id: energy_meter_exported_monthly
source: sensor.power_meter_exported
name: Energy Meter - Exported Monthly
cycle: monthly
price: 0.07
energy_meter_exported_yearly:
unique_id: energy_meter_exported_yearly
source: sensor.power_meter_exported
name: Energy Meter - Exported Yearly
cycle: yearly
price: 0.07
An example of a sensor for determing the current price for grid imports is:
# Updated 1 July 2023 for new Red Energy Rates
template:
- sensor:
# Current_Price_RedEnergy_TOU provides a backup method to allow selecting the 'Use an entity with current rate' in Energy Dashboard.
# If you set the prices here, remember to ALSO set them in the 'electricity_import_rate_???' and daily supply charge sensors.
- name: Electricity - Price
unique_id: electricity_price
unit_of_measurement: "AUD/kWh"
state: "
{%set Peak = 0.34078 %}
{%set WeekdayShoulder = 0.30679 %}
{%set OffPeak = 0.21978 %}
{%set H = as_timestamp(now())|timestamp_custom ('%-H')|float(0) %} {##Hour (24-hour clock) as a decimal number. 0, 1, 2, ... 23##}
{%set w = as_timestamp(now())|timestamp_custom ('%w')|float(0) %} {##HWeekday as a decimal number, where 0 is Sunday and 6 is Saturday. 0, 1, …, 6##}
{##0 for weekday, 1 for weekend##}
{% if (w == 0) or (w == 6) %} {% set weekday = 0 %}
{% else %} {% set weekday = 1 %}
{% endif %}
{% set charge = 0 %}
{##peak##}
{% if (weekday == 1) and (H >= 7) and (H <= 9) %} {{Peak}}
{% elif (weekday == 1) and (H >= 17) and (H <= 20) %} {{Peak}}
{##weekday shoulder##}
{% elif (weekday == 1) and (H >= 0) and (H <= 7) %} {{WeekdayShoulder}}
{% elif (weekday == 1) and (H >= 9) and (H <= 17) %} {{WeekdayShoulder}}
{% elif (weekday == 1) and (H >= 20) and (H <= 22) %} {{WeekdayShoulder}}
{##off peak##}
{% else %} {{OffPeak}}
{% endif %}
"
To get the 'select' sensor that this integration auto creates, when you use the Tariffs option, so it automatically updates to change to peak/shoulder/offpeak at the correct times, you'll need an automation ... like this:
automation:
### adjust the time triggers below to match when your standard electricity tariff changes (peak, shoulder, offpeak). Adjust the template in the action block as required to match your plan.
- alias: Set Energy Meter Rate
description: 'Set Energy Meter Rate'
trigger:
- platform: time
at: '07:00:30'
- platform: time
at: '09:00:30'
- platform: time
at: '17:00:30'
- platform: time
at: '20:00:30'
- platform: time
at: '22:00:30'
- platform: homeassistant
event: start
condition: []
action:
- service: select.select_option
data:
option: >-
{% set t = now() %}
{%- if (( t.hour >= 7 and t.hour < 9 ) or ( t.hour >= 17 and t.hour < 20 )) and
is_state('binary_sensor.workday_sensor', 'on') %}
peak
{%- elif (( t.hour >= 9 and t.hour < 17 ) or ( t.hour >= 20 and t.hour < 22 )) and
is_state('binary_sensor.workday_sensor', 'on') %}
shoulder
{%- else -%}
offpeak
{%- endif -%}
target:
entity_id:
- select.energy_meter_imported_daily
- select.energy_meter_imported_monthly
- select.energy_meter_imported_yearly
mode: single
I note that when using the tarrif option, it auto creates the sensors for daily / monthly / yearly etc with 3 sensors each for peak/shouler/offpeak. However there is no sensor for the total of the day/month/year.
i.e. if you want to lookup the total kWh imports for instance for the day / month or year, you can't see the total kWh, instead you'll see only the 3 seperate sensors tracking the usage of the peak/shoulder/offpeak, but no overall daily/monthly/yearly sensor showing the total kWh / $ for each of those periods.
I tried to improve documentation. I hope it is enough
Looks good, but how do I configure this ? seems not via the helpers in the GUI. Should I just add it to configurations.yaml file ?