I have four automations that change the tariff based on time of day. Peak is easy, it’s always from 4 to 9 PM. Super Off Peak gets a little more complicated as it’s always after midnight but the end time depends on the day. Off Peak is the most complex one that depends on day of the week and if it is a holiday or not.
I defined three tariffs and added them to my Energy dashboard as Import and Export, three each for a total of 6
These were added in the configuration YAML under utility_meter and use the sensors energy.import and energy.export:
utility_meter:
daily_energy:
source: sensor.energy_import
name: Daily Import Meter
cycle: daily
tariffs:
- SDGE_OffPeak
- SDGE_SuperOffPeak
- SDGE_Peak
daily_energy_export:
source: sensor.energy_export
name: Daily Export Meter
cycle: daily
tariffs:
- SDGE_OffPeak
- SDGE_SuperOffPeak
- SDGE_Peak
The automations then select the corresponding tariff as the active one for export and import, and it also sets a helper I use to display the current price. The price used by each Tariff is defined in the Energy dashboard. I used to manually update them every time the rates changed, but now I am using a separate helper and have a dashboard with all the rates easily accessible.
I still have to manually select Winter vs Summer, but this should be easy to automate, just haven’t spent time on it yet.
I track the Holidays using the Holidays HACS integration which allows you to pick which holidays you care about, and then it puts them in a calendar where you get an entity with a number. If the number is 0, it means the holiday is today. This is used in my conditions below. HA added native Holiday support in 2024.1 so I need to look into moving this there as this integration will no longer be supported.
alias: Set Peak Tariff
description: ""
trigger:
- platform: time
at: "16:00:00"
condition: [ ]
action:
- service: select.select_option
data:
option: SDGE_Peak
target:
entity_id: select.daily_energy_export
- service: select.select_option
data:
option: SDGE_Peak
target:
entity_id: select.daily_energy
- service: input_number.set_value
data:
value: 51.2
target:
entity_id: input_number.current_electricity_rate
mode: single
alias: Set Super Off Peak Tariff
description: ""
trigger:
- platform: time
at: "00:00:00"
condition: [ ]
action:
- service: select.select_option
data:
option: SDGE_SuperOffPeak
target:
entity_id: select.daily_energy_export
- service: select.select_option
data:
option: SDGE_SuperOffPeak
target:
entity_id: select.daily_energy
- service: input_number.set_value
data:
value: 12.38
target:
entity_id: input_number.current_electricity_rate
mode: single
alias: Set Off Peak (every day after 2 and 9 PM)
description: ""
trigger:
- platform: time
at: "21:00:00"
- platform: time
at: "14:00:00"
condition: [ ]
action:
- service: select.select_option
data:
option: SDGE_OffPeak
target:
entity_id: select.daily_energy_export
- service: select.select_option
data:
option: SDGE_OffPeak
target:
entity_id: select.daily_energy
- service: input_number.set_value
data:
value: 38.17
target:
entity_id: input_number.current_electricity_rate
mode: single
alias: Set Off Peak Conditional Weekday Mornings
description: ""
trigger:
- platform: time
at: "06:00:00"
condition:
- condition: and
conditions:
- condition: time
before: "16:00:00"
after: "06:00:00"
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: not
conditions:
- condition: state
entity_id: calendar.sdge_holidays
state: "0"
action:
- service: select.select_option
data:
option: SDGE_OffPeak
target:
entity_id: select.daily_energy_export
- service: select.select_option
data:
option: SDGE_OffPeak
target:
entity_id: select.daily_energy
- service: input_number.set_value
data:
value: 38.17
target:
entity_id: input_number.current_electricity_rate
mode: single
alias: Set Super Off Peak in March and April weekdays
description: ""
trigger:
- platform: time
at: "10:00:00"
condition:
- condition: state
entity_id: calendar.sdge_rates
state: March and April Super Off Peak
attribute: message
enabled: false
- condition: and
conditions:
- condition: template
value_template: "{{ now().month in [3,4] }}"
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: numeric_state
entity_id: calendar.sdge_holidays
above: 0
action:
- service: select.select_option
data:
option: SDGE_SuperOffPeak
target:
entity_id: select.daily_energy_export
- service: select.select_option
data:
option: SDGE_SuperOffPeak
target:
entity_id: select.daily_energy
- service: input_number.set_value
data:
value: 12.38
target:
entity_id: input_number.current_electricity_rate
mode: single
After all that, I now get separate readings for each import/export tariff in my Energy dashboard:
I’ve also been putting power meters (mostly zigbee smart outlets) on large devices to track individual consumption. Using this as a starting guide to get the Unaccounted reading and using Powercalc to get a lot of the static measurements into sensors, I had not spent a lot of time with this integration and it’s really powerful.