Calculate peak and off peak electricity spend

Hi all. I’m recently new to HA, and looking for a couple of pointers on working out how much I spend charging my EV during peak times and and off peak times separately.

I have a Shelly plus 1PM, which gives me the energy used charging. I am on Octopus energy and have a sensor with the current electricity rate. I also have a template binary sensor that tracks “is currently peak rate” by simply seeing if the current rate is lower or higher than a given value.

I can’t work out conceptually how to have one bucket for off peak spend and one for peak spend (using the utility meter helper?) and then depending on whether we’re in off peak or peak, the energy usage at that time is multiplied by the relevant rate and put in the relevant spend bucket.

I hope that makes sense. Looking for any pointers on how to achieve this.

Cheers

Makes perfect sense.

Read through the documents on the power meter helper. It’s exactly what you’re looking for. Look at the part about multiple tariffs. You should see some familiar parts based on what you described. If it doesn’t click come back with questions.

Hi Nathan

Thanks for the response. I’ve had the power meter helper working for my whole house usage and for the overall cost of the EV charging. I hadn’t spotted the part about multiple tariffs, and it creating a sensor for each one. Before I saw your response I actually come up with a very convoluted way of doing it:

``````- sensor:
- name: EV Charging Peak Cost delta
unique_id: ev_charging_peak_cost_deltas
state: >
{% set delta = (trigger.to_state.state | float) - (trigger.from_state.state | float) %}
{% if delta > 0 and is_state('binary_sensor.electricity_currently_peak_rate', 'on') %}
{{ delta * (states('sensor.octopus_energy_electricity_xxxxxxxxxx_xxxxxxxxxxxx_current_rate') | float) }}
{% else %}
0.0
{% endif %}
- name: EV Charging Off Peak Cost delta
unique_id: ev_charging_off_peak_cost_deltas
state: >
{% set delta = (trigger.to_state.state | float) - (trigger.from_state.state | float) %}
{% if delta > 0 and is_state('binary_sensor.electricity_currently_peak_rate', 'off') %}
{{ delta * (states('sensor.octopus_energy_electricity_xxxxxxxxxx_xxxxxxxxxxxx_current_rate') | float) }}
{% else %}
0.0
{% endif %}
trigger:
platform: state
entity_id:
- sensor.shellyplus1pm_xxxxxxxxxxxx_switch_0_energy
``````

I then created a couple of utility meters based on the deltas - one for peak cost and one for off-peak cost. Obviously the built-in method will be a lot more elegant, so I’ll redo it tomorrow, but the upside is that I learned about triggers!

thanks again

1 Like

Hi, what is “power meter helper” I have looked in helpers and only thing I see resembling power is the utility meter which doesnt seem to accomplish signaling an onpeak and offpeak cost to the energy dashboard.

just to make my requirement obvious… I have an on-peak and an off-peak energy cost, I would like the energy dashboard to use one cost during peak and another during offpeak during its cost calculations

Yes utility meter.

It accepts multiple tariffs and you use annautomationntonswitchnthebtariff according to your utility company rules.