Shelly: allow float totals

This commit is contained in:
andig 2022-12-30 13:54:29 +01:00
parent bf41bec141
commit e2cf83908e
2 changed files with 4 additions and 4 deletions

View file

@ -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")
}

View file

@ -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
}
}