Skip to content

Prices and costs ​

Are calculated costs recalculated when I change the price, and how do I change it from a certain date? ​

In short: Not automatically. A new price applies from the date under "Valid from", and costs that are already booked stay as they are. From v0.7.0, you can recalculate them afterwards with the "Recalculate costs from date" action.

SourceAnalytix books costs continuously. With every new value from the source, it multiplies the consumption since the last value by the price that applied during that time and adds the result to the costs of day, week, month, quarter and year. It remembers each price together with its start time in the state sourceanalytix.0.priceHistory.<category>. That is why a new price doesn't change costs that are already booked.

Change the price from a certain date (from v0.7.0) ​

  1. Open the instance settings of SourceAnalytix and go to the "Price definitions" tab.
  2. In the row of your tariff, enter the new price under "Price per unit" and the date it applies from under "Valid from". The date can be in the future.
  3. Save. The adapter restarts.
  4. Until that date, SourceAnalytix calculates with the old price, and from 0:00 on that date with the new one. At the day rollover, sourceanalytix.0.priceDefinitions.<category>.currentPrice also shows the new price, and the log says "Unit price for … changed from … to … (valid from date reached)".

"Valid from" works the same way for "Price per month". If you switch providers, enter the new price in the same price definition. That keeps the price history together, and you don't change anything on the sources.

WARNING

With every price change, also enter a new date under "Valid from". If you leave the date of the last change, the new price replaces the old one in the price history from that date. A date before the last price change only takes effect up to that change, and after it the later price applies again. If "Valid from" is empty, the new price applies from the moment you save.

From v0.7.0, the dialog marks "Price per unit", "Price per month" and "Valid from" in red and shows "Price changed but "Valid from" did not …" as soon as you change a price without adjusting the date. You can still save, in case you are only fixing a typo. After saving, a warning also appears in the log. If you replaced the old price by mistake: enter the old price again and save, then enter the new price with its own "Valid from" date and save.

Recalculate costs that are already booked (from v0.7.0) ​

If a price applied earlier than the date you entered it, set the correct date under "Valid from" and save. Then open the source on the "Overview" tab and choose the "Recalculate costs from date" action with the same date. The action is only available for sources with "Costs", and you start it for each source separately. What exactly it does and where its limits are is described under Repair costs.

Up to v0.6.x: There is no recalculation. Booked costs stay at the old price, even in the current period.

See also: How is a price definition structured (categories, basic fee, decimal mark)? · How can I read and set prices as states?

How do I include a monthly basic fee? ​

In short: Enter the basic fee in the price definition under "Price per month" and switch on "Include basic fee" on the source. "Costs" must also be on for the source. Divide an annual basic fee by 12 first.

SourceAnalytix books the basic fee as a full monthly amount on the first of each month. In the first month, it books it on the day the price takes effect. That is why the monthly value contains the whole basic fee from the 1st on. Quarter and year contain the sum of their months. Day and week only contain it if the first of the month falls within them.

An example with a basic fee of €12, valid since January 1, on March 15:

PeriodBasic fee in it
Day, week€0
Month€12
Quarter€36
Year€36

If you enter the basic fee for the first time without "Valid from", it applies from January 1 of the current year. The annual value then immediately contains all months since January.

How to do it (from v0.7.0) ​

  1. In the instance settings, on the "Price definitions" tab, enter the "Price per month" for your tariff and save. The adapter restarts.
  2. For a new source, tick "Include the basic fee of this price definition" in the wizard, in the "Price" step.
  3. For an existing source, tick "Include basic fee" in its source detail under "Settings" and click "⚡ Apply".
  4. Check the state sourceanalytix.0.<device>.currentYear.costs.03_currentMonth. It now contains the basic fee.

Several sources with the same price definition ​

Every source with "Include basic fee" books the full basic fee. If several sources belong to one connection, for example your main household supply and a sub-meter, it would otherwise be counted more than once. In that case, switch it on for one source only.

From v0.7.0, SourceAnalytix points this out in several places (#1268):

  • The wizard leaves the checkmark off if another source with the same price definition already books the basic fee, and shows "… already books the basic fee of this price definition. If it is on here too, it counts twice."
  • The "Problems" tab shows "Basic fee is booked twice" with the "Switch off here" button.
  • At startup, the log says The basic fee of price definition <name> is included by <n> sources … and is counted once per source.

If each source really has its own connection with its own basic fee, leave the checkmark on for all of them.

If you change the basic fee, "Valid from" works as it does for the price per unit, see Change the price from a certain date. The "Recalculate costs from date" action includes the basic fee.

Up to v0.6.x: The checkmark is called "Including basic rate" and is in the SourceAnalytix settings of the datapoint under "Calculation settings".

See also: How is a price definition structured (categories, basic fee, decimal mark)? · Costs stay 0

How do I use a dynamic electricity price (Tibber, Awattar)? ​

In short: In the price definition, set "Price source" to "State value" and choose the datapoint with the current price under "Price state". SourceAnalytix remembers every price change with its time and values each bit of consumption at the price that applied at that moment.

How to do it (from v0.7.0) ​

  1. In the instance settings, open the "Price definitions" tab and add a row or change your existing one.
  2. Under "Price source", choose "State value", and under "Price state" the datapoint of your electricity price adapter.
  3. Save. The adapter restarts and writes Loaded unit price <price> for <category> from <datapoint> to the log.
  4. Assign the price definition to your sources, see How do I assign prices and create my own tariffs (e.g. heat pump)?.

IMPORTANT

The datapoint must deliver the price in your currency per unit of the price definition, for example 0.28 for 28 cents per kWh. SourceAnalytix multiplies the value directly by the consumption. If your adapter delivers cents, convert it first, for example with an alias.

Whenever the datapoint changes, the log says "Unit price for … changed from … to …". If it has no valid value at startup, SourceAnalytix logs a warning and calculates with the last fixed price you entered, or with 0 if there is none, until the first valid price arrives. It ignores an invalid new value and keeps the current price.

How the costs are split ​

If a price change falls between two values from the source, SourceAnalytix splits the consumption by time. Example: 1 kWh was consumed between 13:50 and 14:10, and at 14:00 the price drops from €0.30 to €0.20. The first half then costs €0.15 and the second €0.10, €0.25 in total. The more often your source sends, the closer this gets to the real consumption.

Where the costs are stored ​

  • SourceAnalytix keeps the running costs from day to year in sourceanalytix.0.<device>.dynamicCostMemory. After a restart it carries on from there and doesn't revalue the consumption so far at the current price.
  • All prices with their time are in sourceanalytix.0.priceHistory.<category>.
  • The current price is shown in sourceanalytix.0.priceDefinitions.<category>.currentPrice.

WARNING

"Recalculate costs from date" only knows the consumption per period and spreads it evenly over the period. For a price that changes hourly, the result is only an approximation and is usually less accurate than the costs booked as you go. With dynamic prices, only use the action to fix an error.

See also: How can I read and set prices as states? · Values or costs far too high

How do I bill a day/night tariff (high/low rate)? ​

In short: In the price definition, set "Price source" to "Tariff selector". A datapoint then switches between two prices, and SourceAnalytix values the consumption of your single meter at the price that currently applies. It doesn't split the consumption itself into high and low rate.

How to do it (from v0.7.0) ​

  1. Provide a switch datapoint that is, for example, true during one tariff and false otherwise. SourceAnalytix doesn't know the times of day. A script or a schedule, for example, sets the datapoint.
  2. In the instance settings, on the "Price definitions" tab, choose "Tariff selector" under "Price source".
  3. Under "Price per unit", enter the price that applies when the switch datapoint is not active, and under "Active tariff price" the price for the active state.
  4. Under "Price state", choose the switch datapoint.
  5. Save. The adapter restarts.

When the datapoint counts as active:

"Active selector value"Active when the datapoint …
enteredhas exactly this value, for example NT or 2
emptyis true, a number other than 0, or a text other than 0, false, off, no, closed and empty

Every switch is recorded in the price history with its time, and the log says "Unit price for … changed from … to …". If a switch falls between two values from the source, SourceAnalytix splits the consumption by time, as described under dynamic electricity price.

TIP

If your meter provides separate meter readings for high and low rate, you can create both as separate sources instead, each with a price definition with a fixed price. Then you also get the consumption per tariff.

Showing the consumption per tariff from a single meter is planned (#1273).

See also: How is a price definition structured (categories, basic fee, decimal mark)?

How do I assign prices and create my own tariffs (e.g. heat pump)? ​

In short: There is no default price. Every source has exactly one price definition. For your own tariff, for example for the heat pump, add another row on the "Price definitions" tab and select it on the source.

How to do it (from v0.7.0) ​

  1. In the instance settings, open the "Price definitions" tab and add a row.
  2. Under "Category", enter a unique name, for example Waermepumpe. You use this name later to select the tariff.
  3. Choose the "Cost Type" ("Costs" for consumption from the grid, "Earnings" for feed-in), the "Unit" you want to calculate in, the "Price source" and the "Price per unit", and if needed the "Price per month".
  4. Save. The adapter restarts.
  5. For a new source, choose the tariff in the wizard in the "Price" step. Only price definitions whose unit matches the source can be selected.
  6. For an existing source, choose it in the source detail under "Settings" in "Price definition" and click "⚡ Apply".

Several sources may use the same price definition. If it books a basic fee, read Several sources with the same price definition. All fields of the table are explained under How is a price definition structured (categories, basic fee, decimal mark)?.

Costs per kilometer or in a custom unit ​

The price always applies per unit of the price definition. For costs per kilometer, choose the unit km and a source that delivers an odometer reading in km or m. From v0.7.0, there is the unit piece for a price per piece. Which units are available is listed under Which units are supported (energy, volume, weight, length)?.

WARNING

Don't rename a category while sources use it. The sources then can't find their price definition and stop calculating. The log says Selected Type <name> does not exist in Price Definitions, and the "Problems" tab shows "Price definition no longer exists". The price history is also tied to the old name. After a rename, choose the new price definition on every source.

Up to v0.6.x: The table of price definitions is also in the instance settings. You assign them on the datapoint under "Select price definition", see Where do I configure SourceAnalytix for a datapoint?.

See also: Which unit do I set on the datapoint (kWh instead of Wh, m³ instead of liters)? · How do I track PV yield, feed-in and earnings?

Knowledge has no value unless you use and share it