func (c *Camera) SetNightLightMode(mode string) (response *EventStreamResponse, err error) {
	msg := "failed to set night light brightness"
	if mode != "rainbow" && mode != "rgb" {
		return nil, errors.WithMessage(errors.New("mode can only be \"rainbow\" or \"rgb\""), msg)
	}
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        fmt.Sprintf("cameras/%s", c.DeviceId),
		PublishResponse: true,
		Properties: NightLightProperties{
			NightLight: BaseNightLightProperties{
				Mode: mode,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}
SetNightLightMode set the night light mode. Valid values are: "rainbow" or "rgb".
package arlo
import (
	"fmt"
	"time"
	"github.com/pkg/errors"
)
func (c *Camera) SetVolume(volume int) (response *EventStreamResponse, err error) {
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        fmt.Sprintf("cameras/%s", c.DeviceId),
		PublishResponse: true,
		Properties: SpeakerProperties{
			Speaker: VolumeProperties{
				Mute:   false,
				Volume: volume,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	msg := "failed to set audio volume"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}
func (c *Camera) Mute() (response *EventStreamResponse, err error) {
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        fmt.Sprintf("cameras/%s", c.DeviceId),
		PublishResponse: true,
		Properties: SpeakerProperties{
			Speaker: VolumeProperties{
				Mute: true,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	msg := "failed to mute audio"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}
func (c *Camera) UnMute() (response *EventStreamResponse, err error) {
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        fmt.Sprintf("cameras/%s", c.DeviceId),
		PublishResponse: true,
		Properties: SpeakerProperties{
			Speaker: VolumeProperties{
				Mute: false,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	msg := "failed to un-mute audio"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}
func (c *Camera) Play(trackId string, position int) error {
	if trackId == "" {
		trackId = "2391d620-e491-4412-99f6-e9a40d6046ed"
	}
	if position < 0 {
		position = 0
	}
	payload := EventStreamPayload{
		Action:          "playTrack",
		Resource:        "audioPlayback/player",
		PublishResponse: false,
		Properties:      PlayTrackProperties{trackId, position},
		From:            fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:              c.ParentId,
	}
	msg := "failed to play audio"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return errors.WithMessage(err, msg)
	}
	if err := b.NotifyEventStream(payload, msg); err != nil {
		return errors.WithMessage(err, msg)
	}
	return nil
}
func (c *Camera) Pause() error {
	payload := EventStreamPayload{
		Action:          "pause",
		Resource:        "audioPlayback/player",
		PublishResponse: false,
		From:            fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:              c.ParentId,
	}
	msg := "failed to pause audio"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return errors.WithMessage(err, msg)
	}
	if err := b.NotifyEventStream(payload, msg); err != nil {
		return errors.WithMessage(err, msg)
	}
	return nil
}
func (c *Camera) Next() error {
	payload := EventStreamPayload{
		Action:          "nextTrack",
		Resource:        "audioPlayback/player",
		PublishResponse: false,
		From:            fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:              c.ParentId,
	}
	msg := "failed to skip audio"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return errors.WithMessage(err, msg)
	}
	if err := b.NotifyEventStream(payload, msg); err != nil {
		return errors.WithMessage(err, msg)
	}
	return nil
}
func (c *Camera) Shuffle(on bool) (response *EventStreamResponse, err error) {
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        "audioPlayback/config",
		PublishResponse: true,
		Properties: ShuffleProperties{
			Config: BaseShuffleProperties{
				ShuffleActive: on,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	var msg string
	if on {
		msg = "failed to enable shuffle"
	} else {
		msg = "failed to disable shuffle"
	}
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}
func (c *Camera) Continuous() (response *EventStreamResponse, err error) {
	return c.SetLoopBackMode("continuous")
}
func (c *Camera) SingleTrack() (response *EventStreamResponse, err error) {
	return c.SetLoopBackMode("singleTrack")
}
func (c *Camera) SetLoopBackMode(loopbackMode string) (response *EventStreamResponse, err error) {
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        "audioPlayback/config",
		PublishResponse: true,
		Properties: LoopbackModeProperties{
			Config: BaseLoopbackModeProperties{
				LoopbackMode: loopbackMode,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	msg := "failed to set loop back mode to %s"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, fmt.Sprintf(msg, loopbackMode))
	}
	return b.makeEventStreamRequest(payload, msg)
}
func (c *Camera) GetAudioPlayback() (response *EventStreamResponse, err error) {
	payload := EventStreamPayload{
		Action:          "get",
		Resource:        "audioPlayback",
		PublishResponse: false,
		From:            fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:              c.ParentId,
	}
	msg := "failed to get audio playback"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}
func (c *Camera) EnableSleepTimer(sleepTime int64  , sleepTimeRel int) (response *EventStreamResponse, err error) {
	if sleepTime == 0 {
		sleepTime = 300 + (time.Now().UnixNano() / 1000000)  
	}
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        "audioPlayback/config",
		PublishResponse: true,
		Properties: SleepTimerProperties{
			Config: BaseSleepTimerProperties{
				SleepTime:    sleepTime,
				SleepTimeRel: sleepTimeRel,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	msg := "failed to enable sleep timer"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}
func (c *Camera) DisableSleepTimer(sleepTimeRel int) (response *EventStreamResponse, err error) {
	if sleepTimeRel == 0 {
		sleepTimeRel = 300
	}
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        "audioPlayback/config",
		PublishResponse: true,
		Properties: SleepTimerProperties{
			Config: BaseSleepTimerProperties{
				SleepTime:    0,
				SleepTimeRel: sleepTimeRel,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	msg := "failed to disable sleep timer"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}
func (c *Camera) NightLight(on bool) (response *EventStreamResponse, err error) {
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        fmt.Sprintf("cameras/%s", c.DeviceId),
		PublishResponse: true,
		Properties: NightLightProperties{
			NightLight: BaseNightLightProperties{
				Enabled: on,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	var msg string
	if on {
		msg = "failed to turn night light on"
	} else {
		msg = "failed to turn night light off"
	}
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}
func (c *Camera) SetNightLightBrightness(level int) (response *EventStreamResponse, err error) {
	payload := EventStreamPayload{
		Action:          "set",
		Resource:        fmt.Sprintf("cameras/%s", c.DeviceId),
		PublishResponse: true,
		Properties: NightLightProperties{
			NightLight: BaseNightLightProperties{
				Brightness: level,
			},
		},
		From: fmt.Sprintf("%s_%s", c.UserId, TransIdPrefix),
		To:   c.ParentId,
	}
	msg := "failed to set night light brightness"
	b := c.arlo.Basestations.Find(c.ParentId)
	if b == nil {
		err := fmt.Errorf("basestation (%s) not found for camera (%s)", c.ParentId, c.DeviceId)
		return nil, errors.WithMessage(err, msg)
	}
	return b.makeEventStreamRequest(payload, msg)
}