Energy Management in Home Assistant

I’ve just set up a utility meter since my rate here is stepped based on usage.

Since the “return to grid” is the net difference which is not accurate in your case, what if you configure the solar production and then add a grid consumption that is negative of the solar production (new entity = 0 - solar production kWh)? The monthly energy cost would be correct in that case…

You mean like demand metering ?

Similar, but rather than a higher charge for any peak usages in a month, my rates are based on any usage above a threshold for the billing cycle. My billing cycle is on or around the 10th so the number of days in the billing cycle varies, therefore the threshold kWh for that cycle varies.

from Yukon Energy…

“A demand meter looks very much like the meters that are installed at residential homes. Residential meters measure the amount of electricity consumed by a household, allowing utilities to determine how much that household should be charged for power on any given month. Demand meters are installed for all businesses. As well as measuring the amount of electricity used, these meters also record the peak consumption of power. It’s necessary for the utility to have this information, since Yukon business customers are required to pay not only an energy charge but also a demand charge for peak usage.”

BCHydro

Residential Conservation Rate

Most residential customers are charged under the Residential Conservation Rate. Residential customers under the Residential Conservation Rate receive service under rate schedule 1101 of the Electric Tariff.
Customers are charged one rate for electricity up to a certain threshold in each billing period, and a higher rate for all electricity use beyond that threshold. This “stepped” rate is designed to encourage conservation.

How your threshold is determined

On your bill, the threshold for the lower Step 1 rate is calculated by multiplying the number of days in the billing period by 22.1918 kWh per day.

Customer meters are read on different days so billing periods can vary from bill to bill. The 22.1918 kWh per day is the daily equivalent of 1,350 kWh for the average two month billing period.

For example, a 60-day billing period would have a Step 1 threshold of 1,332 kWh (60 days x 22.1918 kWh per day). A 58-day billing period would have a 1,287 kWh (58 days x 22.1918 kWh per day) Step 1 threshold.
image

I fuddeled through and set up some cost sensors using templates. You prob need to make cost sensors with if statements and then do a total. Mine has a diff rate over 2000 kWh but I do not think I will reach that. My billing is on the second of the month, so I am going to live with it. (I am not totally sure of cost yet from my provider, taking a guestimate)

template:
   sensor:
      - name: Minute Power Cost
        state_class: measurement
        unit_of_measurement: USD
        device_class: power
        icon: mdi:transmission-tower
        state: >
          {% set production = states('sensor.power_shop_123_1min') | int %}
         
          {{ (production * 0.00009) }}  
          
      - name: Month_Power
        state_class: measurement
        unit_of_measurement: USD
        device_class: power
        icon: mdi:transmission-tower
        state: >
          {% set production = states('sensor.power_shop_123_1mon') | int %}
         
          {{ (production * 0.09) }}

I am using sensor day for the energy tab so it calculates that. I actually need to add the basic $17 a month flat rate charge to my monthly cost.

I have mine set up this way:

utility_meter:
  monthly_energy:
    source: sensor.current_cost_kWh
    name: Monthly Energy
    cycle: monthly
    offset:
      days: 10
    tariffs:
      - step_1
      - step_2
template:
  - binary_sensor:
      - name: Current Cost Monthly Energy Tariff Limit
        state: {{ states('sensor.monthly_energy_step_1')|float >= states('sensor.number_of_days_in_this_month')|float * 22.1918 }}

image

and 2 automations:

alias: BCHydro Monthly Tariff Change
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.current_cost_monthly_energy_tariff_limit
    to: 'off'
    id: step_1
  - platform: state
    entity_id: binary_sensor.current_cost_monthly_energy_tariff_limit
    to: 'on'
    id: step_2
condition: []
action:
  - service: utility_meter.select_tariff
    target:
      entity_id: utility_meter.monthly_energy
    data:
      tariff: '{{trigger.id}}'
mode: single
alias: BCHydro Set Current Rate
description: Sets the BCHydro Current Rate when the Tariff level changes
trigger:
  - platform: state
    entity_id: utility_meter.monthly_energy
    to: step_1
    id: step_1_rate
  - platform: state
    entity_id: utility_meter.monthly_energy
    to: step_2
    id: step_2_rate
condition: []
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.bchydro_current_rate
    data_template:
      value: '{{ states("input_number.bchydro_" + trigger.id) }}'
mode: single

My basic charge is only $0.2080/day plus a transit levy of .$00624/day totaling only about $8/month

Good morning,

I do apologise if this has been covered elsewhere. Let me start by way of introduction. I use HomeAssistant in my own home, and I am a software developer working for Victron Energy. I would like to start working on an integration for the Victron GX-device, most likely through our existing modbus-TCP interface, but potentially also possible through MQTT if that is easier.

Is there any documentation explaining exactly what is required, or possible, for an integration that supports energy management? Or do I just start with an existing project, such as the Fronius one, and use that as an example?

Looking forward to this!

3 Likes

Existing projects do give guidance, but you need an entity that measures energy in kWh and meets the definition for long term statistics Sensor Entity | Home Assistant Developer Docs and has the state_class of total_increasing.

I think that is it :slight_smile:

1 Like

Hi!
Have a look here for developer documentation: https://developers.home-assistant.io/docs/development_index

I’d not recommend to use the current Fronius integration as example as it uses some deprecated HA functions (eg. yaml configuration).
That said going through mqtt is probably a good idea as it is well supported by HA (including discovery).
With Modbus you may run into troubles when you use pymodbus and the core Modbus integration requires a different pinned Version than yours at some point.

1 Like

How can I troubleshoot the Energy dashboard if something is not working? In my case the carbon footprint is not working/not shown in the Energy dashboard.

I have setup the CO2 Signal integration and the 2 created sensors of this integration work fine and show data. Within the Energy dashboard configuration I have added the CO2 Signal integration at “Grid carbon footprint” 3 weeks ago, but the data is still not visible in the Energy dashboard.

Thanks for that. Ideally it should detect the system automatically. We have mDNS as well as uPNP. Once it has detected the device, we can connect either to MQTT or modbus-tcp. Until recently modbus-tcp was preferred because the MQTT integration was somewhat CPU heavy.

An absolutely insane amount of things can be accessed through MQTT or modbus, and not every system will have everything. For a start, I will likely have to expose the system energy counters, which is currently logged only to our own telemetry platform (VRM) and not exposed to other systems.

Have you checked your region’s availability at electricityMap | Live CO₂ emissions of electricity consumption?


Also see https://github.com/tmrowco/electricitymap-contrib/wiki/Getting-started

@dbrunt , the region is available (the Netherlands), also visible on the electricitymap website. The sensors of CO2 Signal are giving the correct values, it just doesn’t work with the Energy Dashboard and I cannot find out why…

Guys this is driving me nuts, my battery sensors won’t show up no matter what I do, is this a bug or what’s going on?
utility meters:

inverter_battery_charged_today:
  source: sensor.solar_battery_charged_today
  cycle: daily
  tariffs:
    - peak
inverter_battery_discharged_today:
  source: sensor.solar_battery_discharged_today
  cycle: daily
  tariffs:
    - peak

Sensors where data comes from:

- platform: mqtt
  name: "Solar Battery Charged Today"  
  state_topic: "home/solar/battery/charged_today"
  state_class: measurement
  unit_of_measurement: "kWh"

- platform: mqtt
  name: "Solar Battery Discharged Today"
  state_topic: "home/solar/battery/discharged_today"
  state_class: measurement
  unit_of_measurement: "kWh"

customize.yaml

      sensor.solar_battery_charged_today:
        last_reset: "2021-08-05T00:00:00+00:00"
      sensor.solar_battery_discharged_today:
        last_reset: "2021-08-05T00:00:00+00:00"

Sensors nowhere to be seen:



Any ideas?

I have a meter with 2 tariffs however step_2 is not offered as that meter is currently paused.
Not sure what your issue is…


Sorry, can’t really help since my region is unavailable.

Can you show me your source:sensors to compare? Thanks

See post 845 above…

In case you haven’t tested this since you posted last, the Smart Meter Texas integration is working again. Just need to be on 2021.9.0 at least. I currently have my setup and working in the Energy dashboard.

I’ve done some coding to take a steam from an Enphase system and feed it into HA via mqtt - you may be able to modified it to suit your Victron GX-device if it has a mqtt stream.