Skip to content

Commit

Permalink
[#31] Add cost computation
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Senart committed Feb 3, 2025
1 parent c8f1353 commit de334f8
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 103 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,15 @@ pricing:
- id: reduced
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.0550
- id: standard
- id: normal
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.20
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790
value_unit: "€"
base_unit: "kWh"
vat_id: standard
vat_id: normal
- start_date: "2023-07-01"
value: 0.05392
- start_date: "2023-08-01"
Expand Down Expand Up @@ -431,7 +431,7 @@ pricing:
value: 0.00837
value_unit: "€"
base_unit: "kWh"
vat_id: standard
vat_id: normal
- start_date: "2024-01-01"
value: 0.01637
```
Expand Down
248 changes: 248 additions & 0 deletions addons/gazpar2haws/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,251 @@ devices:
| devices[].timezone | Timezone of the GrDF data | No | Europe/Paris |
| devices[].last_days | Number of days of history data to retrieve | No | 365 days |
| devices[].reset | Rebuild the history. If true, the data will be reset before the first data retrieval. If false, the data will be kept and new data will be added | No | false |
## Cost configuration
Gazpar2HAWS is able to compute and publish cost history to Home Assistant.
The cost computation is based in gas prices defined in the configuration files.
The pricing configuration is broken into 5 sections:
- vat: Value added tax definition.
- consumption_prices: All the gas price history in €/kWh.
- subscription_prices: The subscription prices in €/month (or year).
- transport_prices: The fixed prices in €/month (or year) to transport the gas.
- energy_taxes: Various taxes on energy in €/kWh.
Below, many examples illustrates how to use pricing configuration for use cases from the simplest to the most complex.
Example 1: A fixed consumption price
---
The given price applies at the given date, after and before.
The default unit is € per kWh.
**Formula:**
```math
cost[€] = quantity[kWh] * price[€/kWh]
```


```yaml
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790 # Default unit is €/kWh.
```
Example 2: A fixed consumption price in another unit
---
*value_unit* is the price unit (default: €).
*base_unit* is the denominator unit (default: kWh).
**Formula:**
```math
cost[€] = \frac{quantity[kWh] * price[¢/MWh] * converter\_factor[¢->€]} {converter\_factor[MWh->kWh]}
```


```yaml
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 7790.0 # Unit is now ¢/MWh.
value_unit: "¢"
base_unit: "MWh"
```
Example 3: Multiple prices over time
---
```yaml
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790 # Default unit is €/kWh.
- start_date: "2024-01-01"
value: 0.06888 # Default unit is €/kWh.
```
Price is 0.07790 before 2024-01-01.
Price is 0.06888 on 2024-01-01 and after.
Example 4: Price is given excluding tax
---
The *normal* value added tax (*vat*) rate is 20%.
```yaml
vat:
- id: normal
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.20 # It is the tax rate in [0, 1.0] <==> [0% - 100%].
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790 # Default unit is €/kWh.
vat_id: "normal" # Reference to the vat rate that is applied for this period.
```
**Formula:**
```math
cost[€] = quantity[kWh] * price[€/kWh] * (1 + vat[normal])
```

Example 5: Subscription price
---

A fixed montly subscription is due over consumption.

Subscription *vat* tax may be different than the consumption *vat* tax.

```yaml
vat:
- id: normal
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.20 # It is the tax rate in [0, 1.0] <==> [0% - 100%].
- id: reduced
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.0550
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790 # Default unit is €/kWh.
vat_id: "normal" # Reference to the vat rate that is applied for this period.
subscription_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 19.83
value_unit: ""
base_unit: "month"
vat_id: "reduced"
```
**Formula:**
```math
cost[€] = quantity[kWh] * cons\_price[€/kWh] * (1 + vat[normal]) + sub\_price * (1 + vat[reduced])
```


Example 6: Transport price
---

A fixed yearly transport may be charged as well.

```yaml
vat:
- id: normal
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.20 # It is the tax rate in [0, 1.0] <==> [0% - 100%].
- id: reduced
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.0550
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790 # Default unit is €/kWh.
vat_id: "normal" # Reference to the vat rate that is applied for this period.
transport_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 34.38
value_unit: ""
base_unit: "year"
vat_id: reduced
```
**Formula:**
```math
cost[€] = quantity[kWh] * cons\_price[€/kWh] * (1 + vat[normal]) + trans\_price * (1 + vat[reduced])
```

Example 7: Energy taxes
---

Consumption may be taxed by additional taxes (known as energy taxes).

```yaml
vat:
- id: normal
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.20 # It is the tax rate in [0, 1.0] <==> [0% - 100%].
- id: reduced
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.0550
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790 # Default unit is €/kWh.
vat_id: "normal" # Reference to the vat rate that is applied for this period.
energy_taxes:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.00837
value_unit: ""
base_unit: "kWh"
vat_id: normal
```
**Formula:**
```math
cost[€] = quantity[kWh] * (cons\_price[€/kWh] + ener\_taxes[€/kWh])* (1 + vat[normal])
```

Example 8: All in one
---

In the price list, the first item properties are propagated to the next items in the list. If their values does not change, it is not required to repeat them.

```yaml
vat:
- id: reduced
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.0550
- id: normal
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.20
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790
value_unit: ""
base_unit: "kWh"
vat_id: normal
- start_date: "2023-07-01"
value: 0.05392
- start_date: "2023-08-01"
value: 0.05568
- start_date: "2023-09-01"
value: 0.05412
- start_date: "2023-10-01"
value: 0.06333
- start_date: "2023-11-01"
value: 0.06716
- start_date: "2023-12-01"
value: 0.07235
- start_date: "2024-01-01"
value: 0.06888
- start_date: "2024-02-01"
value: 0.05972
- start_date: "2024-03-01"
value: 0.05506
- start_date: "2024-04-01"
value: 0.04842
- start_date: "2025-01-01"
value: 0.07807
subscription_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 19.83
value_unit: ""
base_unit: "month"
vat_id: reduced
- start_date: "2023-07-01"
value: 20.36
transport_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 34.38
value_unit: ""
base_unit: "year"
vat_id: reduced
energy_taxes:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.00837
value_unit: ""
base_unit: "kWh"
vat_id: normal
- start_date: "2024-01-01"
value: 0.01637
```
23 changes: 3 additions & 20 deletions addons/gazpar2haws/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,21 @@ options:
- id: reduced
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.0550
- id: standard
- id: normal
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.20
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790
value_unit: ""
base_unit: "kWh"
vat_id: standard
vat_id: normal
- start_date: "2023-07-01"
value: 0.05392
- start_date: "2023-08-01"
value: 0.05568
- start_date: "2023-09-01"
value: 0.05412
- start_date: "2023-10-01"
value: 0.06333
- start_date: "2023-11-01"
value: 0.06716
- start_date: "2023-12-01"
value: 0.07235
- start_date: "2024-01-01"
value: 0.06888
- start_date: "2024-02-01"
value: 0.05972
- start_date: "2024-03-01"
value: 0.05506
- start_date: "2024-04-01"
value: 0.04842
- start_date: "2025-01-01"
value: 0.07807
subscription_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 19.83
Expand All @@ -75,7 +59,7 @@ options:
value: 0.00837
value_unit: ""
base_unit: "kWh"
vat_id: standard
vat_id: normal
- start_date: "2024-01-01"
value: 0.01637
schema:
Expand Down Expand Up @@ -121,4 +105,3 @@ schema:
value_unit: str? # Unit of the tax: €, ¢.
base_unit: str? # Base unit of the tax: Wh, kWh, MWh, m³, l
vat_id: str? # Identifier of the VAT rate.

23 changes: 3 additions & 20 deletions addons/gazpar2haws/config.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,21 @@ options:
- id: reduced
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.0550
- id: standard
- id: normal
start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.20
consumption_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 0.07790
value_unit: "€"
base_unit: "kWh"
vat_id: standard
vat_id: normal
- start_date: "2023-07-01"
value: 0.05392
- start_date: "2023-08-01"
value: 0.05568
- start_date: "2023-09-01"
value: 0.05412
- start_date: "2023-10-01"
value: 0.06333
- start_date: "2023-11-01"
value: 0.06716
- start_date: "2023-12-01"
value: 0.07235
- start_date: "2024-01-01"
value: 0.06888
- start_date: "2024-02-01"
value: 0.05972
- start_date: "2024-03-01"
value: 0.05506
- start_date: "2024-04-01"
value: 0.04842
- start_date: "2025-01-01"
value: 0.07807
subscription_prices:
- start_date: "2023-06-01" # Date of the price. Format is "YYYY-MM-DD".
value: 19.83
Expand All @@ -75,7 +59,7 @@ options:
value: 0.00837
value_unit: "€"
base_unit: "kWh"
vat_id: standard
vat_id: normal
- start_date: "2024-01-01"
value: 0.01637
schema:
Expand Down Expand Up @@ -121,4 +105,3 @@ schema:
value_unit: str? # Unit of the tax: €, ¢.
base_unit: str? # Base unit of the tax: Wh, kWh, MWh, m³, l
vat_id: str? # Identifier of the VAT rate.

Loading

0 comments on commit de334f8

Please sign in to comment.