README.md
May 2, 2026 · View on GitHub
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
| Sensor | Required | Supported units |
|---|---|---|
| Electricity price | Yes | currency/kWh, currency/MWh, currency/Wh (any currency) |
| Energy consumption | Recommended | kWh, Wh, MWh |
| Power consumption | Alternative | W, 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
Install using HACS (recommended)
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:
After installation, please restart Home Assistant. To add Dynamic Energy Cost to your Home Assistant instance, use this My button:
Manual configuration steps
Semi-Manual Installation with HACS
- In Home Assistant go to HACS integrations section.
- Click on the 3 dots in the top right corner.
- Select "Custom repositories".
- Add the URL (https://github.com/martinarva/dynamic_energy_cost) to the repository.
- Select the integration category.
- Click the "ADD" button.
- Now you are able to download the integration.
Manual Installation
- Download the latest release of Dynamic Energy Cost and extract its contents.
- Copy the
dynamic_energy_costfolder into thecustom_componentsdirectory located typically at/config/custom_components/in your Home Assistant directory. - Restart Home Assistant to recognize the newly added custom component.
Add Integration
- Navigate to Settings > Devices & Services.
- Click Add Integration and search for "Dynamic Energy Cost".
- 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_resetfor 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
Update manually
To update the integration to a newer version:
- Download the latest release of Dynamic Energy Cost and extract its contents.
- Go to your Home Assistant instance.
- Make sure to make a backup first.
- Overwrite the
dynamic_energy_costfolder into thecustom_componentsdirectory located typically at/config/custom_components/. - Reboot Home Assistant.
Contribute
Contributions are welcome.
- Bug reports with exact sensor setup, screenshots, and logs are extremely helpful.
- If you use a
Wsensor 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
kWhsensor or aWsensor - the source sensor entities involved
- screenshots or logs that show the current behavior
GitHub issues: Dynamic Energy Cost issues