Shelly: allow float totals
This commit is contained in:
parent
bf41bec141
commit
e2cf83908e
2 changed files with 4 additions and 4 deletions
|
|
@ -184,9 +184,9 @@ func (d *Connection) TotalEnergy() (float64, error) {
|
|||
|
||||
switch {
|
||||
case d.channel < len(res.Meters):
|
||||
energy = float64(res.Meters[d.channel].Total) / 60
|
||||
energy = res.Meters[d.channel].Total / 60
|
||||
case d.channel < len(res.EMeters):
|
||||
energy = float64(res.EMeters[d.channel].Total) / 60
|
||||
energy = res.EMeters[d.channel].Total / 60
|
||||
default:
|
||||
return 0, errors.New("invalid channel, missing power meter")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ type Gen1SwitchResponse struct {
|
|||
type Gen1StatusResponse struct {
|
||||
Meters []struct {
|
||||
Power float64
|
||||
Total int64
|
||||
Total float64
|
||||
}
|
||||
// Shelly EM meter JSON response
|
||||
EMeters []struct {
|
||||
Power float64
|
||||
Total int64
|
||||
Total float64
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue