As mentioned to Adam Jackson on Decarbonize Software 2023 the other day, here is a quick note on how to create a live consumption carbon intensity rating widget (sorry a bit of a mouthful) on your Home Assistant dashboard.
Pre-requisites:
- You have an instance of Home Assistant already configured
- HACS is already set up on your Home Assistant instance. Otherwise instructions can be found here: https://hacs.xyz/docs/setup/download
- You are signed up to Octopus Energy provider and have requested a Octopus Home Mini - if you are not yet an Octopus Energy customer, feel free to use my referral code iron-sun-306 for £50 off your first bill
I was recently really excited to get an Octopus Home Mini. Compared to a smart meter that only reports on aggregated readings over 30 minutes blocks, the Home Mini allows for 10 seconds to 1 minute old readings which can significantly help improve smart home automation in the house. Let's face it, there is nearly no automation relevant over 30 minutes old data when it comes to energy. I have solar panels, and in a country like the UK, the sun really comes and goes and automations would need to be based on 1 to 5 minutes averages to stay relevant.
Anyway, getting up to 1 minute old consumption carbon rating can be achieve with these simple steps:
1. Install CO2 Signal Home Assistant Integration
This is available via the integration tab in Home Assistant.
CO2 Signal Home Assistant Integration
2. Install Octopus Integration and enable the Home Mini
This requires the installation of HACS first.
Octopus Home Assistant Integration
3. Set up a template that combines the values from both
Configuration
In your configuration.yaml, add the following line (to create your templates in a dedicated file - that is neater)
template: !include templates.yaml
Create that template.yaml
file (alongside your configuration.yaml
) and add the following content:
template:
- sensor:
- name: "Current hourly Electricity Carbon Emission Rating"
unit_of_measurement: "gCO2eq/h"
state: >
{% set currentco2rating = states('sensor.co2_signal_co2_intensity') | float %}
{% set liveusage = states('sensor.octopus_energy_electricity_22j0484346_1013001886662_current_demand') | float %}
{% set totalRating = currentco2rating * liveusage/1000 %}
{% if totalRating > 0 %}
{{ totalRating | round(1, default=0) }}
{%- else -%}
0
{%- endif %}
Note to create your own template, you can use the Template Editor under the template tab of the Developer Tools to test it.
Dashboard
You can then set up a dashboard with your current consumption or rating using the sensor card, to help you compare your consumption. The sensor card shows both the current value as well as the history over the past configured period (for me it is set to last 24h).
You could also add gauges to create some red/amber/green zones to at a glance understand how you are currently doing.
Here I am starting the battery charging when the power is at its lowest carbon intensity for the day:
This shows that when the consumption is negative, we are keeping our rating positive to a minimum of zero.
Finally this show charging the car when the power is at its lowest of the day (similar to charging the battery):
Wrap up
Adding your carbon intensity to your dashboard and combining it to your consumption makes it easy to see whether our consumption is carbon aware, i.e. whether it uses more energy cleaner, in other words, when the electricity production comes primarily from renewable energy.
EDIT 26/03/24: Thank you Ronan Glemain (@ronanglemain) for the correction tips, especially around fixing the unit of measure (from gCO2eq/kWh to gCO2eq/h) - Template has been updated though images still currently the original with the mistaken unit
Top comments (0)