Tariffs: configure charges and taxes (#8088)
This commit is contained in:
parent
c398973357
commit
d1acca7d26
4 changed files with 29 additions and 7 deletions
|
|
@ -165,14 +165,20 @@ tariffs:
|
|||
- days: Sa,So
|
||||
price: 0.15 # EUR/kWh
|
||||
|
||||
# # or variable via tibber
|
||||
# or variable tariffs
|
||||
# type: tibber
|
||||
# token: "476c477d8a039529478ebd690d35ddd80e3308ffc49b59c65b142321aee963a4" # access token
|
||||
# homeid: "cc83e83e-8cbf-4595-9bf7-c3cf192f7d9c" # optional if multiple homes associated to account
|
||||
|
||||
# # or variable via awattar
|
||||
# type: awattar
|
||||
# region: de # optional, choose at for Austria
|
||||
# charges: # optional, additional charges per kWh
|
||||
# tax: # optional, additional tax (0.1 for 10%)
|
||||
|
||||
# type: elering
|
||||
# region: fi
|
||||
# charges: # optional, additional charges per kWh
|
||||
# tax: # optional, additional tax (0.1 for 10%)
|
||||
feedin:
|
||||
# rate for feeding excess (pv) energy to the grid
|
||||
type: fixed
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import (
|
|||
)
|
||||
|
||||
type Awattar struct {
|
||||
*embed
|
||||
mux sync.Mutex
|
||||
log *util.Logger
|
||||
uri string
|
||||
|
|
@ -30,6 +31,7 @@ func init() {
|
|||
|
||||
func NewAwattarFromConfig(other map[string]interface{}) (api.Tariff, error) {
|
||||
cc := struct {
|
||||
embed `mapstructure:",squash"`
|
||||
Cheap any // TODO deprecated
|
||||
Currency string
|
||||
Region string
|
||||
|
|
@ -47,9 +49,10 @@ func NewAwattarFromConfig(other map[string]interface{}) (api.Tariff, error) {
|
|||
}
|
||||
|
||||
t := &Awattar{
|
||||
log: util.NewLogger("awattar"),
|
||||
unit: cc.Currency,
|
||||
uri: fmt.Sprintf(awattar.RegionURI, strings.ToLower(cc.Region)),
|
||||
embed: &cc.embed,
|
||||
log: util.NewLogger("awattar"),
|
||||
unit: cc.Currency,
|
||||
uri: fmt.Sprintf(awattar.RegionURI, strings.ToLower(cc.Region)),
|
||||
}
|
||||
|
||||
// TODO deprecated
|
||||
|
|
@ -87,7 +90,7 @@ func (t *Awattar) run(done chan error) {
|
|||
ar := api.Rate{
|
||||
Start: r.StartTimestamp.Local(),
|
||||
End: r.EndTimestamp.Local(),
|
||||
Price: r.Marketprice / 1e3,
|
||||
Price: t.totalPrice(r.Marketprice / 1e3),
|
||||
}
|
||||
t.data = append(t.data, ar)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import (
|
|||
)
|
||||
|
||||
type Elering struct {
|
||||
*embed
|
||||
mux sync.Mutex
|
||||
log *util.Logger
|
||||
unit string
|
||||
|
|
@ -32,6 +33,7 @@ func init() {
|
|||
|
||||
func NewEleringFromConfig(other map[string]interface{}) (api.Tariff, error) {
|
||||
cc := struct {
|
||||
embed `mapstructure:",squash"`
|
||||
Currency string
|
||||
Region string
|
||||
}{
|
||||
|
|
@ -47,6 +49,7 @@ func NewEleringFromConfig(other map[string]interface{}) (api.Tariff, error) {
|
|||
}
|
||||
|
||||
t := &Elering{
|
||||
embed: &cc.embed,
|
||||
log: util.NewLogger("Elering"),
|
||||
unit: cc.Currency,
|
||||
region: strings.ToLower(cc.Region),
|
||||
|
|
@ -92,7 +95,7 @@ func (t *Elering) run(done chan error) {
|
|||
ar := api.Rate{
|
||||
Start: ts.Local(),
|
||||
End: ts.Add(time.Hour).Local(),
|
||||
Price: r.Price / 1e3,
|
||||
Price: t.totalPrice(r.Price / 1e3),
|
||||
}
|
||||
t.data = append(t.data, ar)
|
||||
}
|
||||
|
|
|
|||
10
tariff/embed.go
Normal file
10
tariff/embed.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package tariff
|
||||
|
||||
type embed struct {
|
||||
Charges float64 `mapstructure:"charges"`
|
||||
Tax float64 `mapstructure:"tax"`
|
||||
}
|
||||
|
||||
func (t *embed) totalPrice(price float64) float64 {
|
||||
return (price + t.Charges) * (1 + t.Tax)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue