Page 1 of 1

Feature Request: Time-based Dual Tariff Electricity Pricing for Accurate Energy Cost Calculation

Posted: Saturday 27 December 2025 11:06
by pauljefferson
Hello,

First of all, thank you for the continued development of Domoticz. It has become a core part of my home automation system.

I would like to request an enhancement to the electricity cost configuration, specifically around dual (or multi-rate) tariffs.

While Domoticz supports dual tariff pricing, the time-of-day switching is not configurable, which makes it impossible to accurately model many real-world electricity contracts.


The Problem

Many electricity providers offer tariffs where the price depends on the time of day, not just a tariff flag.

Example:

• Off-peak rate: £0.065 / kWh between 00:00–05:00
• Peak rate: £0.22 / kWh outside those hours

Currently in Domoticz:

• Two prices can be defined
• The hours during which each price applies cannot be defined
• This prevents Domoticz from calculating accurate energy costs

This is especially problematic for EV charging, heat pumps, and battery storage that intentionally run during off-peak hours.


Proposed Feature / Solution

Add support for time-based tariff definitions.

Suggested approach:

• Allow users to define one or more time ranges
• Assign a price per kWh to each time range

Example configuration:

• 00:00–05:00 → £0.065 / kWh
• 05:00–00:00 → £0.22 / kWh

Optional future extensions:

• Multiple time bands per day
• Different pricing for weekdays vs weekends
• Seasonal tariff schedules


Benefits

• Accurate energy cost tracking
• Better support for time-of-use electricity tariffs
• Improved usefulness of statistics and dashboards
• Reduced need for external scripts or manual correction


Use Case

In my setup, a significant portion of electricity usage is deliberately shifted to off-peak hours. While Domoticz records energy consumption correctly, the financial cost is incorrect due to the lack of time-based pricing, limiting the usefulness of long-term reporting.


Closing

I believe this feature would significantly improve Domoticz’s energy monitoring capabilities and benefit many users on dual-rate or time-of-use tariffs.

Thank you for your consideration. I would be happy to test or provide feedback if needed.

Best regards,
[Paul Jefferson]

Re: Feature Request: Time-based Dual Tariff Electricity Pricing for Accurate Energy Cost Calculation

Posted: Saturday 27 December 2025 12:05
by waltervl
Hi Paul, when enabling the Domoticz dynamic tariff option you can load the current tarif into a device and use that for cost calculation. Also you can load future tarifs into a user variable and use that for planning you usage or planning charge your battery.
There are already some integrations that load energy tarifs automatically (like Enever, Dutch only) so costs are calculated and you can plan on day ahead tarifs (per hour).

See wiki https://wiki.domoticz.com/Application_S ... alculation

Re: Feature Request: Time-based Dual Tariff Electricity Pricing for Accurate Energy Cost Calculation

Posted: Saturday 27 December 2025 12:53
by waltervl
Here you have an example: viewtopic.php?t=42935

And here is an example dzvents script:
Prerequisite: A Dummy Custom Sensor of type Custom and set to costs created from the Dummy Hardware. Note down the exact name of this device (e.g., "Current Energy Tariff"). https://wiki.domoticz.com/Dummy_for_vir ... tom_Sensor

You can use this device in the Cost calculation settings in menu Setup-Settings, tab Counters.

Code: Select all

return {
    on = {
        timer = {
            -- Update the tariff every 30 minutes to prevent ugly time-out of sensor
            'every 30 minutes'
        }
    },
    execute = function(domoticz)
        -- Configuration variables
        local tariffDeviceName = 'Current Energy Tariff' -- Replace with your custom sensor name
        local highPrice = 0.313136                        -- Your high tariff price in EUR/kWh
        local lowPrice = 0.194744                         -- Your low tariff price in EUR/kWh

        -- Define tariff schedule: Low tariff between 22:00 (10 PM) and 07:00 (7 AM), and all weekend
        local isLowTariff = false
        if (domoticz.time.matches('between 22:00 and 07:00')) or (domoticz.day == 'Saturday') or (domoticz.day == 'Sunday') then
            isLowTariff = true
        end

        local currentPrice
        if isLowTariff then
            currentPrice = lowPrice
        else
            currentPrice = highPrice
        end

        -- Update the Domoticz custom sensor with the current price
        local tariffDevice = domoticz.devices(tariffDeviceName)
        -- Use updateCustomSensor(value) for custom sensors
        tariffDevice.updateCustomSensor(currentPrice)
        domoticz.log('Energy tariff updated to: ' .. currentPrice .. ' EUR/kWh', domoticz.LOG_INFO)
    end
}