Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/control/optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def flexible_tariff_module(self) -> TypingOptional[ConfigurableFlexibleTariff]:
def flexible_tariff_module(self, value: TypingOptional[ConfigurableFlexibleTariff]):
if (value is None or
(self._flexible_tariff_module and value and
self._flexible_tariff_module.config.name != value.config.name)):
self._flexible_tariff_module.config != value.config)):
self.data.electricity_pricing.flexible_tariff.get = PricingGet()
self._reset_state(self.data.electricity_pricing.flexible_tariff)
Comment on lines 43 to 47
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Umstellung auf dataclasses für die config-Klassen und dann compare=False-Attribut benutzen.

self._flexible_tariff_module = value
Expand All @@ -56,7 +56,7 @@ def grid_fee_module(self) -> TypingOptional[ConfigurableGridFee]:
def grid_fee_module(self, value: TypingOptional[ConfigurableGridFee]):
if (value is None or
(self._grid_fee_module and value and
self._grid_fee_module.config.name != value.config.name)):
self._grid_fee_module.config != value.config)):
self.data.electricity_pricing.grid_fee.get = PricingGet()
self._reset_state(self.data.electricity_pricing.grid_fee)
self._grid_fee_module = value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
from dataclasses import dataclass, field


@dataclass
class AwattarTariffConfiguration:
def __init__(self,
country: str = "de",
net: bool = True,
fix: float = 0.000015,
proportional: float = 3,
tax: float = 20) -> None:
self.country = country
self.net = net
self.fix = fix
self.proportional = proportional
self.tax = tax
country: str = "de"
net: bool = True
fix: float = 0.000015
proportional: float = 3
tax: float = 20


@dataclass
class AwattarTariff:
def __init__(self,
name: str = "aWATTar/tado° HOURLY",
type: str = "awattar",
official: bool = True,
configuration: AwattarTariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or AwattarTariffConfiguration()
name: str = "aWATTar/tado° HOURLY"
type: str = "awattar"
official: bool = True
configuration: AwattarTariffConfiguration = field(default_factory=AwattarTariffConfiguration)
25 changes: 12 additions & 13 deletions packages/modules/electricity_pricing/flexible_tariffs/ekz/config.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from dataclasses import dataclass, field


@dataclass
class EkzTariffConfiguration:
def __init__(self):
self.country = "ch"
self.unit = "Rp"
self.update_hours = [18, 19]
country: str = "ch"
unit: str = "Rp"
update_hours: list[int] = field(default_factory=lambda: [18, 19])


@dataclass
class EkzTariff:
def __init__(self,
name: str = "EKZ (CH)",
type: str = "ekz",
official: bool = False,
configuration: EkzTariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or EkzTariffConfiguration()
name: str = "EKZ (CH)"
type: str = "ekz"
official: bool = False
configuration: EkzTariffConfiguration = field(default_factory=EkzTariffConfiguration)
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from dataclasses import dataclass, field


@dataclass
class EnergyChartsTariffConfiguration:
def __init__(self, country: str = "DE-LU", surcharge: float = 0):
self.country = country
self.surcharge = surcharge
country: str = "DE-LU"
surcharge: float = 0


@dataclass
class EnergyChartsTariff:
def __init__(self,
name: str = "Energy-Charts",
type: str = "energycharts",
official: bool = True,
configuration: EnergyChartsTariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or EnergyChartsTariffConfiguration()
name: str = "Energy-Charts"
type: str = "energycharts"
official: bool = True
configuration: EnergyChartsTariffConfiguration = field(default_factory=EnergyChartsTariffConfiguration)
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from typing import List, Dict
from dataclasses import dataclass, field
from typing import Any


@dataclass
class FixedHoursTariffConfiguration:
def __init__(self,
default_price: float = 0,
tariffs: List[Dict[str, any]] = None,
update_hours: List[int] = None) -> None:
self.default_price = default_price
self.tariffs = tariffs if tariffs is not None else []
self.update_hours = update_hours if update_hours is not None else list(range(24))
'''
default_price: float = 0
tariffs: list[dict[str, Any]] = field(default_factory=list)
update_hours: list[int] = field(default_factory=lambda: list(range(24)))
'''
Example configuration:
"tariffs": [
{
Expand All @@ -32,13 +30,9 @@ def __init__(self,
'''


@dataclass
class FixedHoursTariff:
def __init__(self,
name: str = "Feste Tarifstunden (z.b. §14a EnWG Modul3)",
type: str = "fixed_hours",
official: bool = False,
configuration: FixedHoursTariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or FixedHoursTariffConfiguration()
name: str = "Feste Tarifstunden (z.b. §14a EnWG Modul3)"
type: str = "fixed_hours"
official: bool = False
configuration: FixedHoursTariffConfiguration = field(default_factory=FixedHoursTariffConfiguration)
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from dataclasses import dataclass, field


@dataclass
class GroupeETariffConfiguration:
def __init__(self):
self.country = "ch"
self.unit = "Rp"
country: str = "ch"
unit: str = "Rp"


@dataclass
class GroupeETariff:
def __init__(self,
name: str = "Groupe E (CH)",
type: str = "groupe_e",
official: bool = False,
configuration: GroupeETariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or GroupeETariffConfiguration()
name: str = "Groupe E (CH)"
type: str = "groupe_e"
official: bool = False
configuration: GroupeETariffConfiguration = field(default_factory=GroupeETariffConfiguration)
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
from dataclasses import dataclass, field
from typing import Optional


@dataclass
class OctopusEnergyTariffConfiguration:
def __init__(self,
email: Optional[str] = None,
accountId: Optional[str] = None,
password: Optional[str] = None):
self.email = email
self.accountId = accountId
self.password = password
email: Optional[str] = None
accountId: Optional[str] = None
password: Optional[str] = None


@dataclass
class OctopusEnergyTariff:
def __init__(self,
name: str = "Octopus Energy Deutschland",
type: str = "octopusenergy",
official: bool = False,
configuration: OctopusEnergyTariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or OctopusEnergyTariffConfiguration()
name: str = "Octopus Energy Deutschland"
type: str = "octopusenergy"
official: bool = False
configuration: OctopusEnergyTariffConfiguration = field(default_factory=OctopusEnergyTariffConfiguration)
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
from dataclasses import dataclass, field
from typing import Optional


@dataclass
class OstromTariffConfiguration:
def __init__(self,
client_id: Optional[str] = None,
client_secret: Optional[str] = None,
zip: Optional[str] = None):
self.client_id = client_id
self.client_secret = client_secret
self.zip = zip
self.update_hours = [2, 8, 14, 20] # expected time to get next chunk of prices
client_id: Optional[str] = None
client_secret: Optional[str] = None
zip: Optional[str] = None
update_hours: list[int] = field(default_factory=lambda: [2, 8, 14, 20]) # expected time to get next chunk of prices


@dataclass
class OstromTariff:
def __init__(self,
name: str = "ostrom",
type: str = "ostrom",
official: bool = False,
configuration: OstromTariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or OstromTariffConfiguration()
name: str = "ostrom"
type: str = "ostrom"
official: bool = False
configuration: OstromTariffConfiguration = field(default_factory=OstromTariffConfiguration)
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
from dataclasses import dataclass, field
from typing import Optional


@dataclass
class RabotTariffConfiguration:
def __init__(self,
customer_number: Optional[str] = None,
contract_number: Optional[str] = None):
self.customer_number = customer_number
self.contract_number = contract_number
self.update_hours = [0] # Rabot publishes once daily at 00:00 for the following day
customer_number: Optional[str] = None
contract_number: Optional[str] = None
# Rabot publishes once daily at 00:00 for the following day
update_hours: list[int] = field(default_factory=lambda: [0])


@dataclass
class RabotTariff:
def __init__(self,
name: str = "Rabot",
type: str = "rabot",
official: bool = True,
configuration: RabotTariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or RabotTariffConfiguration()
name: str = "Rabot"
type: str = "rabot"
official: bool = True
configuration: RabotTariffConfiguration = field(default_factory=RabotTariffConfiguration)
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
from dataclasses import dataclass, field
from typing import Optional


@dataclass
class TibberTariffConfiguration:
def __init__(self, token: Optional[str] = None, home_id: Optional[str] = None):
self.token = token
self.home_id = home_id
self.update_hours = [14] # tibber publishes once daily before 14:00
'''
token: Optional[str] = None
home_id: Optional[str] = None
update_hours: list[int] = field(default_factory=lambda: [14]) # tibber publishes once daily before 14:00
'''
dynamische Netzentgelte müssen umgerechnet werden,
damit der Gesamtpreis nicht um den Normalpreis der Netzentgelte verzerrt wird.
'''
self.includes_grid_fee = True
includes_grid_fee: bool = True


@dataclass
class TibberTariff:
def __init__(self,
name: str = "Tibber",
type: str = "tibber",
official: bool = True,
configuration: TibberTariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or TibberTariffConfiguration()
name: str = "Tibber"
type: str = "tibber"
official: bool = True
configuration: TibberTariffConfiguration = field(default_factory=TibberTariffConfiguration)
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
from dataclasses import dataclass, field
from typing import Optional


class VoltegoToken():
def __init__(self,
access_token: Optional[str] = None,
expires_in: Optional[str] = None,
created_at: Optional[str] = None) -> None:
self.access_token = access_token # don't show in UI
self.expires_in = expires_in # don't show in UI
self.created_at = created_at # don't show in UI
@dataclass
class VoltegoToken:
access_token: Optional[str] = field(default=None, compare=False, repr=False) # don't show in UI
expires_in: Optional[str] = field(default=None, compare=False) # don't show in UI
created_at: Optional[str] = field(default=None, compare=False) # don't show in UI

Comment on lines +5 to 10

@dataclass
class VoltegoTariffConfiguration:
def __init__(self,
client_id: Optional[str] = None,
client_secret: Optional[str] = None,
token: VoltegoToken = None):
self.client_id = client_id
self.client_secret = client_secret
self.token = token or VoltegoToken()
client_id: Optional[str] = None
client_secret: Optional[str] = None
token: VoltegoToken = field(default_factory=VoltegoToken)


@dataclass
class VoltegoTariff:
def __init__(self,
name: str = "Voltego",
type: str = "voltego",
official: bool = True,
configuration: VoltegoTariffConfiguration = None) -> None:
self.name = name
self.type = type
self.official = official
self.configuration = configuration or VoltegoTariffConfiguration()
name: str = "Voltego"
type: str = "voltego"
official: bool = True
configuration: VoltegoTariffConfiguration = field(default_factory=VoltegoTariffConfiguration)
Loading
Loading