Using Home Assistant to count self sufficient days
For some time I have wanted to track when we generated enough solar power to make us self sufficient. This led to a debate on Mastodon about what self sufficient means. I think it is when more power is generated than is imported from the grid. Others believe it is when more is generated than the house consumes.
I posted a survey on Mastodon and it came out 50/50. No help there. The problem is, my solar iBoost is recorded against house consumption, yet the power is coming from the solar panels.
To cover both bases I made two counters in Home Assistant. One for the grid and one for consumption
self_sustained_consumption and self_sustained_grid
I followed these instructions to make the counters
Mine look like this in the Home Assistant GUI
I then made two automations that will trigger at 23:55 each night. I doubt the last five minutes of the day will swing it one way or the other. The first automation compares the solar generation against the grid import
alias: Solar - Self Sustained Counter (Grid)
description: Solar - Self Sustained Counter (Grid)
trigger:
- platform: time
at: "23:55:00"
condition:
- condition: numeric_state
entity_id: sensor.lux_solar_output_daily
above: sensor.lux_power_from_grid_daily
action:
- service: counter.increment
data: {}
target:
entity_id: counter.self_sustained_grid
mode: single
The second compares the solar generation to the house consumption
alias: Solar - Self Sustained Counter (Consumption)
description: Solar - Self Sustained Counter (Consumption)
trigger:
- platform: time
at: "23:55:00"
condition:
- condition: numeric_state
entity_id: sensor.lux_solar_output_daily
above: sensor.lux_home_consumption_daily
action:
- service: counter.increment
data: {}
target:
entity_id: counter.self_sustained_consumption
mode: single
I then needed a way to display the counters. I made a combined bar card using a custom bar card. I have made two, I am not sure which one I prefer yet. I can track the consumption number prior to today (30th April 2023), but not the grid import. I only have the last 7 days worth of data and we have been self sufficient for all 7 days.
This is the YAML for this card
entities:
- entity: counter.self_sustained_consumption
name : Days Self Sustained (Consumption)
severity:
- color: red
from: 0
to: 10
- color: orange
from: 11
to: 29
- color: blue
from: 30
to: 39
- color: green
from: 40
to: 365
- entity: counter.self_sustained_grid
name : Days Self Sustained (Grid)
severity:
- color: red
from: 0
to: 10
- color: orange
from: 11
to: 29
- color: blue
from: 30
to: 39
- color: green
from: 40
to: 365
title: Self Sustained
direction: up
height: 200px
stack: horizontal
type: custom:bar-card
This is the second Custom Bar Card
This is the YAML code for this card
entities:
- entity: counter.self_sustained_consumption
name: Days Self Sustained (Consumption)
type: custom:bar-card
max: 365
severity:
- color: red
from: 0
to: 10
- color: orange
from: 11
to: 29
- color: blue
from: 30
to: 39
- color: green
from: 40
to: 365
- entity: counter.self_sustained_grid
name: Days Self Sustained (Grid)
type: custom:bar-card
max: 365
severity:
- color: red
from: 0
to: 10
- color: orange
from: 11
to: 29
- color: blue
from: 30
to: 39
- color: green
from: 40
to: 365
type: entities
The maximum value does not need to be 365 days. Plainly there is no chance of being self sufficient every day. I will change this next autumn when I know what a good target number will be.