Skip to content

Commit

Permalink
fix relay number validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lyimmi committed Sep 4, 2023
1 parent 49e97ee commit c3b7c37
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion device.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (d *Device) readStates() (map[RelayNumber]State, error) {

// changeState changes the state of one or all of the relays on the device
func (d *Device) changeState(s State, ch RelayNumber) error {
if (ch < 0 || ch > d.relayCount) && ch != R_ALL {
if (ch <= 0 || ch > d.relayCount) && ch != R_ALL {
return fmt.Errorf("%w must be 1-%d", ErrInvalidRelayNumber, d.relayCount)
}

Expand Down

0 comments on commit c3b7c37

Please sign in to comment.