Licence + fixes

This commit is contained in:
Adam Štrauch 2024-08-08 10:36:30 +02:00
parent 5126b9c3db
commit 0e2ce322c0
Signed by: cx
GPG Key ID: 7262DAFE292BCE20
3 changed files with 46 additions and 38 deletions

9
LICENCE Normal file
View 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.

View File

@ -22,21 +22,21 @@ def docs():
docs = """
Return spot prices for the whole day with all fees included.<br>
<br>
Options:<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>
monthly_fees - monthly fees, default is 509.24 (D57d, 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_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>
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>
**Options:**<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>
**monthly_fees** - monthly fees, default is 509.24 (D57d, 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_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>
**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>
<br>
Output:<br>
spot - current spot prices on our market<br>
total - total price for the day including all fees and VAT<br>
sell - current spot prices minus sell_fees<br>
**spot** - current spot prices on our market<br>
**total** - total price for the day including all fees and VAT<br>
**sell** - current spot prices minus sell_fees<br>
<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>
@ -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>
<br>
```
sensor:
- platform: rest
resource: "https://pricepower2.rostiapp.cz/price/day"
name: "energy_price"
value_template: "{{ value_json.total.now|round(2) }}"
unit_of_measurement: "CZK/kWh"
- platform: rest
resource: "https://pricepower2.rostiapp.cz/price/day"
name: "energy_market_price"
value_template: "{{ value_json.spot.now|round(2) }}"
unit_of_measurement: "CZK/kWh"
- platform: rest
resource: "https://pricepower2.rostiapp.cz/price/day"
name: "energy_market_price_sell"
value_template: "{{ value_json.sell.now|round(2) }}"
unit_of_measurement: "CZK/kWh"
- platform: rest
resource: "https://pricepower2.rostiapp.cz/price/day"
name: "energy_cheap_hour"
value_template: "{{ value_json.cheapest_hours.is_cheapest }}"
rest:
- resource: https://pricepower2.rostiapp.cz/price/day
scan_interval: 60
sensor:
- name: "energy_price"
value_template: "{{ value_json.total.now|round(2) }}"
unit_of_measurement: "CZK/kWh"
- name: "energy_market_price"
value_template: "{{ value_json.spot.now|round(2) }}"
unit_of_measurement: "CZK/kWh"
- name: "energy_market_price_sell"
value_template: "{{ value_json.sell.now|round(2) }}"
unit_of_measurement: "CZK/kWh"
binary_sensor:
- name: "energy_cheap_hour"
value_template: "{{ value_json.cheapest_hours.is_cheapest }}"
```
"""
@ -85,6 +81,7 @@ def read_item(
no_cache:bool = False,
num_cheapest_hours:int = 8,
) -> DayPrice:
is_today = datetime.date.today() == date
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_total = {}
spot_data = get_energy_prices(date, no_cache=no_cache)
for hour, value in spot_data.items():
kwh_fees = kwh_fees_low if int(hour) in low_tariff_hours_parsed else kwh_fees_high
for key, value in spot_data.items():
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_total[hour] = (value / currency_ratio + kwh_fees) * VAT
spot_hours_for_sell[hour] = value / currency_ratio - sell_fees
spot_hours[key] = value / currency_ratio
spot_hours_total[key] = (value / currency_ratio + kwh_fees) * VAT
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)
@ -118,6 +115,7 @@ def read_item(
kwh_fees_high=kwh_fees_high * VAT,
sell_fees=sell_fees,
low_tariff_hours=low_tariff_hours_parsed,
hour=hour,
vat=VAT,
spot=spot,
total=spot_total,

View File

@ -22,6 +22,7 @@ class DayPrice:
kwh_fees_high: float
sell_fees: float
low_tariff_hours: List[int]
hour: int
vat: float
spot: Price
total: Price