Skip to content

Commit

Permalink
reintroduce channel check
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Thierolf authored and andig committed Sep 1, 2022
1 parent 5d5c752 commit f804035
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions meter/shelly/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func (d *Connection) CurrentPower() (float64, error) {
}

switch {
case len(res.Meters) > 0:
case len(res.Meters) > 0 && d.channel < len(res.Meters):
power = res.Meters[d.channel].Power
case len(res.EMeters) > 0:
case len(res.EMeters) > 0 && d.channel < len(res.EMeters):
power = res.EMeters[d.channel].Power
default:
return 0, errors.New("invalid channel, missing power meter")
Expand Down

0 comments on commit f804035

Please sign in to comment.