Skip to content

Commit

Permalink
Discovergy: re-add scale for power direction
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Jan 1, 2022
1 parent 3b7f4de commit a39ca3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion meter/discovergy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func init() {

type Discovergy struct {
dataG func() (interface{}, error)
scale float64
}

// NewDiscovergyFromConfig creates a new configurable meter
Expand All @@ -27,6 +28,7 @@ func NewDiscovergyFromConfig(other map[string]interface{}) (api.Meter, error) {
User string
Password string
Meter string
Scale float64
Cache time.Duration
}{
Cache: time.Second,
Expand Down Expand Up @@ -74,6 +76,7 @@ func NewDiscovergyFromConfig(other map[string]interface{}) (api.Meter, error) {

m := &Discovergy{
dataG: dataG,
scale: cc.Scale,
}

return m, nil
Expand All @@ -88,7 +91,7 @@ var _ api.Meter = (*Discovergy)(nil)
func (m *Discovergy) CurrentPower() (float64, error) {
res, err := m.dataG()
if res, ok := res.(discovergy.Reading); err == nil && ok {
return float64(res.Values.Power) / 1e3, nil
return m.scale * float64(res.Values.Power) / 1e3, nil
}
return 0, err
}
Expand Down

3 comments on commit a39ca3a

@premultiply
Copy link
Member

Choose a reason for hiding this comment

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

Muss man bei invertierter Nutzung dabei für die Energie ggf. auch ein anderes Zählregister verwenden?

@andig
Copy link
Member Author

@andig andig commented on a39ca3a Jan 1, 2022

Choose a reason for hiding this comment

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

Bei PV wirds eh nicht ausgewertet

@premultiply
Copy link
Member

Choose a reason for hiding this comment

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

Gut ok, hoffentlich stolpern wir dann nicht irgendwann darüber wenn es z. B. für so Features wie Energiesparanzeige doch mal benötigt wird ;)

Please sign in to comment.