Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
044d7f9
Merge pull request #34 from cabberley/dev_baseline
cabberley Jul 5, 2025
3c58c28
Merge pull request #35 from cabberley/dev_baseline
cabberley Jul 5, 2025
679a874
Changes to be committed:
cabberley Jul 8, 2025
040b1ad
Changes to be committed:
cabberley Jul 8, 2025
96c0e3e
Merge pull request #36 from cabberley/multi
cabberley Jul 8, 2025
e7e7e01
Changes to be committed:
cabberley Jul 8, 2025
ea54688
Merge pull request #37 from cabberley/multi
cabberley Jul 8, 2025
eb41bd7
Changes to be committed:
cabberley Jul 8, 2025
f604b25
Merge pull request #38 from cabberley/multi
cabberley Jul 8, 2025
6fa17ff
Changes to be committed:
cabberley Jul 9, 2025
ddd1953
Merge pull request #40 from cabberley/multi
cabberley Jul 9, 2025
30affa4
Changes to be committed:
cabberley Jul 10, 2025
c3bfb84
Merge pull request #41 from cabberley/multi
cabberley Jul 10, 2025
8b3a00b
Bump ruff from 0.12.2 to 0.12.3
dependabot[bot] Jul 11, 2025
3a5fed8
Update dependency ruff to v0.12.3
renovate[bot] Jul 11, 2025
78d758b
Changes to be committed:
cabberley Jul 13, 2025
7971e5d
Changes to be committed:
cabberley Jul 13, 2025
ddf3678
Merge pull request #44 from cabberley/multi
cabberley Jul 13, 2025
21ce520
Changes to be committed:
cabberley Jul 14, 2025
f56a59d
Merge pull request #45 from cabberley/multi
cabberley Jul 14, 2025
2f2bdd8
Merge pull request #43 from cabberley/renovate/ruff-0.x
cabberley Jul 14, 2025
4f9e38a
Merge pull request #42 from cabberley/dependabot/pip/ruff-0.12.3
cabberley Jul 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</h1>

<p align="center">
<href="https://github.com/cabberley/utility_meter_evolved/releases"><img src="https://img.shields.io/github/v/release/cabberley/utility_meter_evolved?display_name=tag&include_prereleases&sort=semver" alt="Current version"> <img alt="GitHub Release Date" src="https://img.shields.io/github/release-date/cabberley/utility_meter_evolved">
<a><href="https://github.com/cabberley/utility_meter_evolved/releases"><img src="https://img.shields.io/github/v/release/cabberley/utility_meter_evolved?display_name=tag&include_prereleases&sort=semver" alt="Current version"></a> <img alt="GitHub Release Date" src="https://img.shields.io/github/release-date/cabberley/utility_meter_evolved">
<img alt="GitHub" src="https://img.shields.io/github/license/cabberley/utility_meter_evolved"> <img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/cabberley/utility_meter_evolved/validate.yml">
<img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues/cabberley/utility_meter_evolved"> <img alt="GitHub User's stars" src="https://img.shields.io/github/stars/cabberley"> <img alt="GitHub Downloads (all assets, all releases)" src="https://img.shields.io/github/downloads/cabberley/utility_meter_evolved/total">

Expand All @@ -27,14 +27,15 @@ This custom HACS integration for Home Assistant provides an enhanced set of capa

Based on the current "Utility Meter" component code in the Home-Assistant/Core. Acknowledgements to [DGomes](https://github.com/dgomes) who is the Code Owner of the core utlity Meter who really did all the hard logic work for the Meter Utility.

The main enhancements that the Utility Meter Next Gen has added to the original Utility Meter include:
There are lots of enhancements that the Utility Meter Next Gen has added to the original Utility Meter include:

- **Create multiple period sensors, optionally with Tariffs and individual Calculation sensors from a single Source and Calculation Sensor**
- Creating Cron schedule patterns via the Frontend of HA, you no longer need to create them in configuration.yaml!
- Additional Predefined schedules that should accomodate the majority of people's needs.
- The addition of an optional secondary sensor/entity that will be used to calculate a value based on the Meters value.
- Option to create an additional Sensor for the Calculated Value, if you have added a sensor to create a calculated value.
- All settings of the Meter can be modified through the Frontend. The options reflect the schedule type you created the Meter with (Predefined or CRON).
- An option to create a "Total" Tariff that will not pause like a normal Tariff does. (You can create a sungle Sensor set that collects for each tariff period plus the total)
- An option to create a "Total" Tariff that will not pause like a normal Tariff does. (You can create a single Sensor set that collects for each tariff period plus the total)
- Additional extra attributes have been added to the Sensor, so you can see quickly the key information about the sensor and what it is doing.
- Additional attributes that don't change are not recorded in thhe Recorder DB to avoid unnecessary recorder data bloat.
- Calibration values can now be set and modified through the Utility Meter configuration.
Expand All @@ -43,25 +44,48 @@ These enhancements should provide a very versatile solution to simplify creating

## Installation

Add this [repository](https://github.com/cabberley/utility_meter_evolved) via your custom Repositories option in the HACS dashboard as an "Integration Type" and then find "Utility Meter Next Gen" in the repository list, download and restart your Home Assistant.
**The Utility Meter Next Gen is now available directly from HACS, no need to add the repository anymore!!**

Or preferably easier use the link below to add it to your system:
Go to the HACS Dashboard in your Home Assistant, and search for "Utility Meter Next Gen", download and restart your HA.

[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=cabberley&repository=utility_meter_evolved&category=integration)
OR

1. Add this [repository](https://github.com/cabberley/utility_meter_evolved) via your custom Repositories option in the HACS dashboard as an "Integration Type" and then find "Utility Meter Next Gen" in the repository list, download and restart your Home Assistant.
2. Use the link below to add it to your system:

> **NOTE: Currently waiting for this new integration to be added to the HACS repository of Custom Integrations.**
[![Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.](https://my.home-assistant.io/badges/hacs_repository.svg)](https://my.home-assistant.io/redirect/hacs_repository/?owner=cabberley&repository=utility_meter_evolved&category=integration)

## Using the Utility Meter Next Gen

After installing the integration, you should now find **Utility Meter Next Gen** in the **Create Helper** list under the Settings --> Devices & services --> Helpers dashboard.

Follow the instructions to setup your new Meter with an optional Caculation Sensor.

## Using the Multi Predefined reset cycle Meters

This great new feature will take the pain away from setting multiple individual Meters to track your usuage and $$. If you like to track your meters for various periods like every 5 minutes, 30 minutes, hourly, daily, monthly or yearly, this feature enables you to create a single config that will deliver:

- Individual sensors for each time period.
- Individual Tariff based sensors for each tariff for each time period.
- Create a separate Calculation Sensor for every Meter created.
- A single Select for the tariff selection that will pause/collect all the sensors in alignment with your Select choice.
- After creation, you can go back and change (add/remove) Predefiend Reset Cycles and if you created a Tariff based set change the list of Tariffs. You can also add or remove the Calculation Sensor if you created a Utility Meter with a Calculation source.

In addition to all of that, this special Multiple sensor config, always you to calibrate one of those periods. For example, those that are tracking their daily energy costs, may have a daily "service/connection" charge. With this Config, you can tell the setup to only apply the calibration calculation value to just the "Daily" meter.

When you create a new Utlity Meter using the new "Multi Predefined reset cycle Meters", it is very similar to creating a normal predefined recycle Meter with a few additional options.

1. After choosing your Source Sensors, you are then presented with the next step, select the various time periods you would like meters for. You can choose 1 or choose them all!
2. After submitting the Predefined list you are then able to optional add some other more granular settings.
3. The settings will be familiar to the normal Predefined Recycle Meter with the following changes:
1. For both the calibration sensors there is a new option to select which of the predefined cycles to apply it to.
2. For simplicity, the ability to set an Offset to the recycle times has been removed.

## Some Additional helpers

### Warning

**Do not change the "Entity ID" after creating your meter, it will break the Sennors that this integration creates**
**Do not change the "Entity ID" after creating your meter, it will break the Sensors that this integration creates**

### Selection of Sensors to Monitor

Expand Down Expand Up @@ -101,6 +125,3 @@ A good example of using the calibration sensor is if you are tracking the Cost o
- if your Consumption is being recorded as MWh and your Calculation Sensor is $/kWh then you want to convert your MWh to kWH to achieve this the multiplier should be set to 1000.
- if your Consumption is being recorded as Wh and your Calculation Sensor is $/kWh then you want to convert your MWh to kWH to achieve this the multiplier should be set to 0.0001.

### If you want to track one of the attributes like "Last period calculated value" as a Sensor?

If you want to track via another sensor the calculated attribute variable, I would suggest another Great HACS Custom Integration written by gjohansson-ST [Attribute as Sensor](https://github.com/gjohansson-ST/attribute_as_sensor) this integration can monitor an attribute in the Utility Meter Next Gen and surface it as a Sensor in its own right.
29 changes: 24 additions & 5 deletions custom_components/utility_meter_next_gen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from homeassistant.helpers.typing import ConfigType

from .const import (
CONF_CONFIG_CALIBRATE_APPLY,
CONF_CONFIG_CALIBRATE_CALC_APPLY,
CONF_CONFIG_CALIBRATE_CALC_VALUE,
CONF_CONFIG_CALIBRATE_VALUE,
CONF_CREATE_CALCULATION_SENSOR,
Expand Down Expand Up @@ -58,6 +60,7 @@
def validate_cron_pattern(pattern):
"""Check that the pattern is well-formed."""
try:
_LOGGER.debug("Testing cron pattern: %s", pattern)
CronSim(pattern, datetime(2020, 1, 1)) # any date will do
except CronSimError as err:
_LOGGER.error("Invalid cron pattern %s: %s", pattern, err)
Expand Down Expand Up @@ -85,7 +88,8 @@ def period_or_cron(config):
vol.Optional(CONF_NAME): cv.string,
vol.Optional(CONF_UNIQUE_ID): cv.string,
vol.Optional(CONF_METER_TYPE): vol.In(CONF_METER_TYPES),
vol.Optional(CONF_METER_OFFSET, default=CONF_METER_OFFSET_DURATION_DEFAULT): cv.ensure_list,
vol.Optional(CONF_METER_OFFSET,
default=CONF_METER_OFFSET_DURATION_DEFAULT): cv.ensure_list,
vol.Optional(CONF_METER_DELTA_VALUES, default=False): cv.boolean,
vol.Optional(CONF_METER_NET_CONSUMPTION, default=False): cv.boolean,
vol.Optional(CONF_METER_PERIODICALLY_RESETTING, default=True): cv.boolean,
Expand Down Expand Up @@ -291,23 +295,38 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->

_LOGGER.info("Migration to version %s successful", config_entry.version)

if config_entry.version == 3 or config_entry.version is None:
if config_entry.version == 3:
new = {**config_entry.options, CONF_CONFIG_CALIBRATE_CALC_VALUE: 0}
new = {**config_entry.options, CONF_CONFIG_CALIBRATE_VALUE: 0}
hass.config_entries.async_update_entry(config_entry, options=new, version=4)

_LOGGER.info("Migration to version %s successful", config_entry.version)

if config_entry.version == 4 or config_entry.version is None:
if config_entry.version == 4:
new = {**config_entry.options, CONF_CONFIG_CALIBRATE_CALC_VALUE: 0}
hass.config_entries.async_update_entry(config_entry, options=new, version=5)

_LOGGER.info("Migration to version %s successful", config_entry.version)

if config_entry.version == 5 or config_entry.version is None:
new = {**config_entry.options, CONF_CREATE_CALCULATION_SENSOR: CONF_CREATE_CALCULATION_SENSOR_DEFAULT}
if config_entry.version == 5:
new = {**config_entry.options,
CONF_CREATE_CALCULATION_SENSOR: CONF_CREATE_CALCULATION_SENSOR_DEFAULT}
hass.config_entries.async_update_entry(config_entry, options=new, version=6)

_LOGGER.info("Migration to version %s successful", config_entry.version)

if config_entry.version == 6:
new = {**config_entry.options,
CONF_CONFIG_CALIBRATE_CALC_APPLY: None}
hass.config_entries.async_update_entry(config_entry, options=new, version=7)

_LOGGER.info("Migration to version %s successful", config_entry.version)

if config_entry.version == 7:
new = {**config_entry.options,
CONF_CONFIG_CALIBRATE_APPLY: None}
hass.config_entries.async_update_entry(config_entry, options=new, version=8)

_LOGGER.info("Migration to version %s successful", config_entry.version)

return True
Loading
Loading