diff --git a/evcc.dist.yaml b/evcc.dist.yaml index 4f536c0dc..b0e7b6b9f 100644 --- a/evcc.dist.yaml +++ b/evcc.dist.yaml @@ -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 diff --git a/tariff/awattar.go b/tariff/awattar.go index 117a98504..cdb917210 100644 --- a/tariff/awattar.go +++ b/tariff/awattar.go @@ -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) } diff --git a/tariff/elering.go b/tariff/elering.go index 893e1070b..c5a12f224 100644 --- a/tariff/elering.go +++ b/tariff/elering.go @@ -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) } diff --git a/tariff/embed.go b/tariff/embed.go new file mode 100644 index 000000000..5b171e220 --- /dev/null +++ b/tariff/embed.go @@ -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) +}