README.md

May 2, 2026 · View on GitHub


Dynamic Energy Cost icon

Dynamic Energy Cost

HACS integration for Home Assistant

dynamic_energy_cost usage GitLocalize License Latest release

Track your real electricity costs in Home Assistant. Point this integration at a price sensor and a power or energy sensor and it creates cost sensors that follow your actual dynamic tariff — whether that comes from Nord Pool, Amber, Tibber, or any other source.

What you get

  • Real-time cost (power path) — see what you're paying right now, in currency per hour
  • Interval cost sensors — 15-minute, hourly, daily, weekly, monthly, and yearly accumulated costs
  • Manual reset sensor — never resets automatically; perfect for tracking a single EV charging session or appliance run
  • Automatic unit conversion — price in EUR/MWh or EUR/Wh? Energy in Wh or MWh? Power in kW or MW? The integration detects and converts automatically
  • Customizable sensor selection — choose which cost sensors to create during setup; change it later via the options flow
  • Source device integration — cost sensors appear directly under your source device (heat pump, EV charger, etc.)

What you need

SensorRequiredSupported units
Electricity priceYescurrency/kWh, currency/MWh, currency/Wh (any currency)
Energy consumptionRecommendedkWh, Wh, MWh
Power consumptionAlternativeW, kW, MW

Use an energy sensor whenever one is available — it is more accurate and works like the HA Energy Dashboard. A power sensor is supported as a fallback but remains an approximation since it integrates instantaneous readings over time.

Only one consumption sensor (energy or power) can be configured per entry.

Installation

If you do not have HACS installed yet visit https://hacs.xyz for installation instructions.

To add the this repository to HACS in your Home Assistant instance, use this My button:

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

After installation, please restart Home Assistant. To add Dynamic Energy Cost to your Home Assistant instance, use this My button:

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

Manual configuration steps

Semi-Manual Installation with HACS

  1. In Home Assistant go to HACS integrations section.
  2. Click on the 3 dots in the top right corner.
  3. Select "Custom repositories".
  4. Add the URL (https://github.com/martinarva/dynamic_energy_cost) to the repository.
  5. Select the integration category.
  6. Click the "ADD" button.
  7. Now you are able to download the integration.

Manual Installation

  1. Download the latest release of Dynamic Energy Cost and extract its contents.
  2. Copy the dynamic_energy_cost folder into the custom_components directory located typically at /config/custom_components/ in your Home Assistant directory.
  3. Restart Home Assistant to recognize the newly added custom component. Open your Home Assistant instance and show your service developer tools with a specific action selected.

Add Integration

  1. Navigate to Settings > Devices & Services.
  2. Click Add Integration and search for "Dynamic Energy Cost".
  3. Select the Dynamic Energy Cost integration to initiate setup.

Configuration

When setting up the integration, you will go through two steps:

Step 1 — Source sensors:

  • Electricity Price Sensor: Sensor that provides the current electricity price (for example Nordpool, Amber, ... fixed price, day/night).
  • Power/Energy Usage Sensor: Power sensors can measure in W, kW, or MW (converted automatically). Energy sensors can use kWh, Wh, or MWh (converted automatically). Prefer the energy sensor option when both are available.

Step 2 — Sensor selection:

  • Choose which cost sensors to create. All sensors are selected by default.
  • For power sensors, the Real Time Cost sensor is automatically included when any interval sensor is selected.
  • You can change this selection later via Settings → Devices & Services → Configure.

Tips

  • Use a price sensor that already represents the final price you want to track.
  • If you need tariffs, standing charges, VAT, or other custom logic, build that into a template sensor first and feed the result into this integration.
  • Energy-based sensors include attributes for total energy used (kWh) and average energy price, useful for optimizing usage during cheaper hours.
  • Interval cost sensors expose last_reset for compatibility with HA statistics consumers.

Services

Reset cost

Reset an energy cost sensor to 0. Useful in automations or via Developer Tools → Services.

service: dynamic_energy_cost.reset_cost
target:
  entity_id: sensor.your_sensor_entity_id

Calibrate

Set the value of a cost sensor to a specific number.

action: dynamic_energy_cost.calibrate
target:
  entity_id: sensor.your_sensor_entity_id
data:
  value: "100"

Scope

Dynamic Energy Cost is intentionally focused on turning a price sensor and a consumption sensor into cost sensors.

It is not intended to be a full contract or utility billing engine. In particular, these are better handled outside the integration with template sensors, helpers, or automations:

  • standing charges
  • tariff blending / VAT / fixed margins
  • gas unit conversion (m3 -> kWh)
  • solar self-consumption or export deduction logic
  • plan comparison against a different fixed-price contract

Updating

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

Update manually

To update the integration to a newer version:

  1. Download the latest release of Dynamic Energy Cost and extract its contents.
  2. Go to your Home Assistant instance.
  3. Make sure to make a backup first. Open your Home Assistant instance and show an overview of your backups.
  4. Overwrite the dynamic_energy_cost folder into the custom_components directory located typically at /config/custom_components/.
  5. Reboot Home Assistant. Open your Home Assistant instance and show your service developer tools with a specific action selected.

Contribute

Contributions are welcome.

  • Bug reports with exact sensor setup, screenshots, and logs are extremely helpful.
  • If you use a W sensor path, please mention that explicitly when reporting issues.
  • Translation help is welcome via GitLocalize.

Thanks to everyone who has reported bugs, tested edge cases, opened pull requests, and kept using the integration.

Support

For setup help, usage questions, and general discussion, use the Home Assistant Community topic: Dynamic Energy Cost

Use GitHub issues for concrete bugs and actionable feature requests.

When opening a bug report, please include:

  • integration version
  • Home Assistant version
  • whether you use a kWh sensor or a W sensor
  • the source sensor entities involved
  • screenshots or logs that show the current behavior

GitHub issues: Dynamic Energy Cost issues