Skip to content

Custom Integration for Home Assistant to score how energy is utilized based on price point

License

Notifications You must be signed in to change notification settings

knudsvik/EnergyScore

Repository files navigation

hacs_badge analytics_badge GitHub Activity codecov_badge License BuyMeCoffee

An EnergyScore integration provides three sensors; EnergyScore, Cost and Potential Savings.

EnergyScore is a metric that scores how well you are utilizing changing energy prices throughout the last 24 hours. The EnergyScore will be 0% if you use all of your energy in the most expensive hour, 100% in the cheapest hour, but most likely somewhere in between depending on how well you are able to match your energy use with cheap prices. This integration will not try to optimize your energy use, but is complementary to those like PowerSaver or PriceAnalyzer.

The cost sensor provides the current day cost while the potential savings sensor compares actual current day cost with what the cost would be if all energy was consumed in the cheapes hour of the day. This is thus the potential savings that can be achieved if energy usage is optimised.

Visualisation alternatives available in the visualisation.md file.

You can set up several EnergyScore integrations,e.g. one on your total energy usage, another for EV charging or maybe one for your boiler or dishwasher. EnergyScore and Potential Savings sensors both have a quality attribute with a score from 0 to 1 depending on the available data. If a sensor has price and energy data for 18 hours of the last 24, the quality will be 0.75. The higher the quality is, the more you can trust the sensors.

Smart Home Junkie has made a nice YouTube video on his channel about this integration. For questions and discussion, please see this thread on the Home Assistant Community Forum.

Get started

Installation

Install EnergyScore via HACS by using the My Button below or alternatively search for it in HACS integrations. Remember to restart Home Assistant afterwards.

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Configuration

EnergyScore sensors can be added directly from the user interface by using the My Button below or alternatively by browsing to your integrations page and adding it manually. It may take up to two hours to get enough data to calculate the EnergyScore.

Open your Home Assistant instance and start setting up a new integration.

Attribute Description
Name Name of the integration instance. This will provide name for the sensors to use in the frontend, but can be changed later. "Boiler" will give sensors: sensor.boiler_energyscore, sensor.boiler_cost and sensor.boiler_potential_savings (which can all be changed later).
Energy entity A total (cumulative) energy entity, e.g. from Tibber or PowerCalc integrations or a state from a device. It can be both an entity that resets at given intervals or one that keeps increasing indefinetely. If several is available, it is recommended to choose one with high update frequency.
Price entity A price entity which provides the current hourly energy price as the state, e.g. from Nordpool or Tibber integrations.

Advanced configuration

Some more options are available for advanced use and can be set up after initial setup by clicking the configure button in the integration.

Attribute Description Default
Energy Treshold Energy less than the treshold (during one hour) will not contribute to the EnergyScore 0
Rolling Hours The period of time an EnergyScore should be scored on 24

YAML Configuration

Alternatively, this integration can be configured and set up manually via YAML instead. To enable the Integration sensor in your installation, add the following to your configuration.yaml file:

sensor:
  - platform: energyscore
    name: Heater
    energy_entity: sensor.heater_energy
    price_entity: sensor.nordpool_electricity_price
    unique_id: 23115006-9C33-4DBD-BF01-498058F61BEC

Configuration variables

Attribute Data type Type Description
name string Required Name of the integration instance. This will provide name for the sensors to use in the frontend, but can be changed later if a unique_id is provided. "Boiler" will give sensors: sensor.boiler_energyscore, sensor.boiler_cost and sensor.boiler_potential_savings.
energy_entity string Required A total (cumulative) energy entity, e.g. from Tibber or PowerCalc integrations or a state from a device. It can be both an entity that resets at given intervals or one that keeps increasing indefinetely. If several is available, it is recommended to choose one with high update frequency.
price_entity string Required TA price entity which provides the current hourly energy price as the state, e.g. from Nordpool or Tibber integrations.
unique_id string Required Unique id to be able to configure the entity in the UI.
energy_treshold float Optional Energy less than the treshold (during one hour) will not contribute to the EnergyScore (default = 0).
rolling_hours int Optional The number of hours the EnergyScore should be calculated from (default=24, min=2, max=168).

Debugging

The integration can be debugged in several ways.

From user interface

Go to your integrations dashboard (My Button below), choose an EnergyScore sensor to be debugged, click the three dots and then Enable debug logging.

Open your Home Assistant instance and show your integrations.

Always-on by use of YAML

The following code in your configuration.yaml will provide continuous information on EnergyScore sensor updates in the Home Assistant log.

logger:
  logs:
    custom_components.energyscore: debug

Service call

You can start debugging with a service call:

service: logger.set_level
data:
  custom_components.energyscore: debug

Contributions are welcome!

If you want to contribute to this please read the Contribution guidelines