Licence + fixes
This commit is contained in:
parent
5126b9c3db
commit
0e2ce322c0
9
LICENCE
Normal file
9
LICENCE
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Copyright 2024 Adam Štrauch
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@ -22,21 +22,21 @@ def docs():
|
|||||||
docs = """
|
docs = """
|
||||||
Return spot prices for the whole day with all fees included.<br>
|
Return spot prices for the whole day with all fees included.<br>
|
||||||
<br>
|
<br>
|
||||||
Options:<br>
|
**Options:**<br>
|
||||||
date - date in format YYYY-MM-DD, default is today<br>
|
**date** - date in format YYYY-MM-DD, default is today<br>
|
||||||
hour - hour of the day, default is current hour, works only when date is today<br>
|
**hour** - hour of the day, default is current hour, works only when date is today<br>
|
||||||
monthly_fees - monthly fees, default is 509.24 (D57d, BezDodavatele)<br>
|
**monthly_fees** - monthly fees, default is 509.24 (D57d, BezDodavatele)<br>
|
||||||
daily_fees - daily fees, default is 4.18 (BezDodavatele)<br>
|
**daily_fees** - daily fees, default is 4.18 (BezDodavatele)<br>
|
||||||
kwh_fees_low - additional fees per kWh in low tariff, usually distribution + other fees, default is 1.62421 (D57d, BezDodavatele)<br>
|
**kwh_fees_low** - additional fees per kWh in low tariff, usually distribution + other fees, default is 1.62421 (D57d, BezDodavatele)<br>
|
||||||
kwh_fees_high - additional fees per kWh in high tariff, usually distribution + other fees, default is 1.83474 (D57d, BezDodavatele)<br>
|
**kwh_fees_high** - additional fees per kWh in high tariff, usually distribution + other fees, default is 1.83474 (D57d, BezDodavatele)<br>
|
||||||
sell_fees - selling energy fees, default is 0.45 (BezDodavatele)<br>
|
**sell_fees** - selling energy fees, default is 0.45 (BezDodavatele)<br>
|
||||||
num_cheapest_hours - number of cheapest hours to return, default is 8, use this to plan your consumption<br>
|
**num_cheapest_hours** - number of cheapest hours to return, default is 8, use this to plan your consumption<br>
|
||||||
low_tariff_hours - list of low tariff hours, default is 0,1,2,3,4,5,6,7,9,10,11,13,14,16,17,18,20,21,22,23 (D57d, ČEZ)<br>
|
**low_tariff_hours** - list of low tariff hours, default is 0,1,2,3,4,5,6,7,9,10,11,13,14,16,17,18,20,21,22,23 (D57d, ČEZ)<br>
|
||||||
<br>
|
<br>
|
||||||
Output:<br>
|
Output:<br>
|
||||||
spot - current spot prices on our market<br>
|
**spot** - current spot prices on our market<br>
|
||||||
total - total price for the day including all fees and VAT<br>
|
**total** - total price for the day including all fees and VAT<br>
|
||||||
sell - current spot prices minus sell_fees<br>
|
**sell** - current spot prices minus sell_fees<br>
|
||||||
<br>
|
<br>
|
||||||
The final price on the invoice is calculated as:<br>
|
The final price on the invoice is calculated as:<br>
|
||||||
monthly_fees + kWh consumption in low tariff * kwh_fees_low + kWh consumption in high tariff * kwh_fees_high<br>
|
monthly_fees + kWh consumption in low tariff * kwh_fees_low + kWh consumption in high tariff * kwh_fees_high<br>
|
||||||
@ -47,26 +47,22 @@ Except spot and sell prices all prices include VAT.<br>
|
|||||||
Integration into Home Assistant can be done in configuration.yaml file:<br>
|
Integration into Home Assistant can be done in configuration.yaml file:<br>
|
||||||
<br>
|
<br>
|
||||||
```
|
```
|
||||||
sensor:
|
rest:
|
||||||
- platform: rest
|
- resource: https://pricepower2.rostiapp.cz/price/day
|
||||||
resource: "https://pricepower2.rostiapp.cz/price/day"
|
scan_interval: 60
|
||||||
name: "energy_price"
|
sensor:
|
||||||
value_template: "{{ value_json.total.now|round(2) }}"
|
- name: "energy_price"
|
||||||
unit_of_measurement: "CZK/kWh"
|
value_template: "{{ value_json.total.now|round(2) }}"
|
||||||
- platform: rest
|
unit_of_measurement: "CZK/kWh"
|
||||||
resource: "https://pricepower2.rostiapp.cz/price/day"
|
- name: "energy_market_price"
|
||||||
name: "energy_market_price"
|
value_template: "{{ value_json.spot.now|round(2) }}"
|
||||||
value_template: "{{ value_json.spot.now|round(2) }}"
|
unit_of_measurement: "CZK/kWh"
|
||||||
unit_of_measurement: "CZK/kWh"
|
- name: "energy_market_price_sell"
|
||||||
- platform: rest
|
value_template: "{{ value_json.sell.now|round(2) }}"
|
||||||
resource: "https://pricepower2.rostiapp.cz/price/day"
|
unit_of_measurement: "CZK/kWh"
|
||||||
name: "energy_market_price_sell"
|
binary_sensor:
|
||||||
value_template: "{{ value_json.sell.now|round(2) }}"
|
- name: "energy_cheap_hour"
|
||||||
unit_of_measurement: "CZK/kWh"
|
value_template: "{{ value_json.cheapest_hours.is_cheapest }}"
|
||||||
- platform: rest
|
|
||||||
resource: "https://pricepower2.rostiapp.cz/price/day"
|
|
||||||
name: "energy_cheap_hour"
|
|
||||||
value_template: "{{ value_json.cheapest_hours.is_cheapest }}"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -85,6 +81,7 @@ def read_item(
|
|||||||
no_cache:bool = False,
|
no_cache:bool = False,
|
||||||
num_cheapest_hours:int = 8,
|
num_cheapest_hours:int = 8,
|
||||||
) -> DayPrice:
|
) -> DayPrice:
|
||||||
|
|
||||||
is_today = datetime.date.today() == date
|
is_today = datetime.date.today() == date
|
||||||
|
|
||||||
low_tariff_hours_parsed = [int(x.strip()) for x in low_tariff_hours.split(",")]
|
low_tariff_hours_parsed = [int(x.strip()) for x in low_tariff_hours.split(",")]
|
||||||
@ -96,12 +93,12 @@ def read_item(
|
|||||||
spot_hours_for_sell = {}
|
spot_hours_for_sell = {}
|
||||||
spot_hours_total = {}
|
spot_hours_total = {}
|
||||||
spot_data = get_energy_prices(date, no_cache=no_cache)
|
spot_data = get_energy_prices(date, no_cache=no_cache)
|
||||||
for hour, value in spot_data.items():
|
for key, value in spot_data.items():
|
||||||
kwh_fees = kwh_fees_low if int(hour) in low_tariff_hours_parsed else kwh_fees_high
|
kwh_fees = kwh_fees_low if int(key) in low_tariff_hours_parsed else kwh_fees_high
|
||||||
|
|
||||||
spot_hours[hour] = value / currency_ratio
|
spot_hours[key] = value / currency_ratio
|
||||||
spot_hours_total[hour] = (value / currency_ratio + kwh_fees) * VAT
|
spot_hours_total[key] = (value / currency_ratio + kwh_fees) * VAT
|
||||||
spot_hours_for_sell[hour] = value / currency_ratio - sell_fees
|
spot_hours_for_sell[key] = value / currency_ratio - sell_fees
|
||||||
|
|
||||||
spot = Price(hours=spot_hours, now=spot_hours[str(hour)] if is_today else None)
|
spot = Price(hours=spot_hours, now=spot_hours[str(hour)] if is_today else None)
|
||||||
|
|
||||||
@ -118,6 +115,7 @@ def read_item(
|
|||||||
kwh_fees_high=kwh_fees_high * VAT,
|
kwh_fees_high=kwh_fees_high * VAT,
|
||||||
sell_fees=sell_fees,
|
sell_fees=sell_fees,
|
||||||
low_tariff_hours=low_tariff_hours_parsed,
|
low_tariff_hours=low_tariff_hours_parsed,
|
||||||
|
hour=hour,
|
||||||
vat=VAT,
|
vat=VAT,
|
||||||
spot=spot,
|
spot=spot,
|
||||||
total=spot_total,
|
total=spot_total,
|
||||||
|
@ -22,6 +22,7 @@ class DayPrice:
|
|||||||
kwh_fees_high: float
|
kwh_fees_high: float
|
||||||
sell_fees: float
|
sell_fees: float
|
||||||
low_tariff_hours: List[int]
|
low_tariff_hours: List[int]
|
||||||
|
hour: int
|
||||||
vat: float
|
vat: float
|
||||||
spot: Price
|
spot: Price
|
||||||
total: Price
|
total: Price
|
||||||
|
Loading…
Reference in New Issue
Block a user