diff --git a/pkg/alpacago/calibrator.go b/pkg/alpacago/calibrator.go index d4cc235..cb1bd9e 100644 --- a/pkg/alpacago/calibrator.go +++ b/pkg/alpacago/calibrator.go @@ -24,6 +24,19 @@ const ( CalibratorError ) +func (s CalibratorState) String() string { + name := []string{"not_present", "off", "not_ready", "ready", "unknown", "error"} + + i := uint8(s) + + switch { + case i <= uint8(Error): + return name[i] + default: + return strconv.Itoa(int(i)) + } +} + const ( // This device does not have a cover that can be closed independently CoverNotPresent CoverState = iota @@ -115,9 +128,9 @@ GetStatus() @see https://ascom-standards.org/api/#/ASCOM%20Methods%20Common%20To%20All%20Devices/get__device_type___device_number__calibratorstate @see https://ascom-standards.org/Help/Platform/html/T_ASCOM_DeviceInterface_CalibratorStatus.htm */ -func (c *CoverCalibrator) GetStatus() (CalibratorState, error) { +func (c *CoverCalibrator) GetStatus() (string, error) { status, err := c.Alpaca.GetInt32Response("covercalibrator", c.DeviceNumber, "calibratorstate") - return CalibratorState(status), err + return CalibratorState(status).String(), err } /* diff --git a/pkg/alpacago/calibrator_test.go b/pkg/alpacago/calibrator_test.go index 261a48e..ac679d9 100644 --- a/pkg/alpacago/calibrator_test.go +++ b/pkg/alpacago/calibrator_test.go @@ -122,7 +122,7 @@ func TestNewCalibratorCoverGetStatus(t *testing.T) { t.Errorf("got %q", err) } - if got != CalibratorReady && got != CalibratorNotReady { + if got != "ready" && got != "not_ready" && got != "unknown" { t.Errorf("got %v, but expected the calibrator to be ready", got) }