diff --git a/core/poller/unidev/unidev.go b/core/poller/unidev/unidev.go index a5992836..3f8d9e40 100644 --- a/core/poller/unidev/unidev.go +++ b/core/poller/unidev/unidev.go @@ -47,9 +47,10 @@ func (value *FlexInt) UnmarshalJSON(b []byte) error { *value = FlexInt(i) return nil case string: - j, err := strconv.Atoi(i) + // If it's a string like the word "auto" just set the integer to 0 and proceed. + j, _ := strconv.Atoi(i) *value = FlexInt(j) - return err + return nil default: return errors.New("Cannot unmarshal to FlexInt") } diff --git a/core/poller/unidev/unidev_test.go b/core/poller/unidev/unidev_test.go index 5c4986f9..7f077978 100644 --- a/core/poller/unidev/unidev_test.go +++ b/core/poller/unidev/unidev_test.go @@ -12,6 +12,7 @@ func TestFlexInt(t *testing.T) { a := assert.New(t) five := []byte(`{"channel": "5"}`) seven := []byte(`{"channel": 7}`) + auto := []byte(`{"channel": "auto"}`) type reply struct { Channel FlexInt `json:"channel"` } @@ -20,4 +21,6 @@ func TestFlexInt(t *testing.T) { a.EqualValues(FlexInt(5), r.Channel) a.Nil(json.Unmarshal(seven, &r)) a.EqualValues(FlexInt(7), r.Channel) + a.NotNil(json.Unmarshal(auto, &r)) + a.EqualValues(FlexInt(0), r.Channel) }