arlo

package module
v0.0.0-...-d68ae1f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 15 Imported by: 1

README

arlo-go

Go Report Card

Go package for interacting with Netgear's Arlo camera system.


Now in Go!

I love Go. That is why I decided to write this library! I am the creator of the first arlo library written in Python.

My goal is to bring parity to the Python version asap. If you know what you're doing in Go, I would appreciate any feedback on the general structure of the library, bugs found, contributions, etc.


It is by no means complete, although it does expose quite a bit of the Arlo interface in an easy to use Go pacakge. As such, this package does not come with unit tests (feel free to add them, or I will eventually) or guarantees. All contributions are welcome and appreciated!

Please, feel free to contribute to this repo or buy Jeff a beer! Donate


Generous Benefactors (Thank you!)

No beers for Jeff yet! 🍺


Awesomely Smart Contributors (Thank you!)
  • bwagner5 - Dec 8, 2019 - Migrated package from dep to go modules.

If You'd like to make a diffrence in the world and get your name on this most prestegious list, have a look at our help wanted section!


Filing an Issue

Please read the Issue Guidelines and Policies wiki page BEFORE you file an issue. Thanks.


Install

# Install latest stable package
$ go get github.com/jeffreydwalter/arlo-go
package main

import (
	"fmt"
	"log"
	"sync"
	"time"

	"github.com/jeffreydwalter/arlo-go"
)

const (
	USERNAME = "user@example.com"
	PASSWORD = "supersecretpassword"
)

func main() {

	// Instantiating the Arlo object automatically calls Login(), which returns an oAuth token that gets cached.
	// Subsequent successful calls to login will update the oAuth token.
	arlo, err := arlo.Login(USERNAME, PASSWORD)
	if err != nil {
		log.Printf("Failed to login: %s\n", err)
		return
	}
	// At this point you're logged into Arlo.

	now := time.Now()
	start := now.Add(-7 * 24 * time.Hour)

	// Get all of the recordings for a date range.
	library, err := arlo.GetLibrary(start, now)
	if err != nil {
		log.Println(err)
		return
	}

	// We need to wait for all of the recordings to download.
	var wg sync.WaitGroup

	for _, recording := range *library {

		// Let the wait group know about the go routine that we're about to run.
		wg.Add(1)

		// The go func() here makes this script download the files concurrently.
		// If you want to download them serially for some reason, just remove the go func() call.
		go func() {
			fileToWrite, err := os.Create(fmt.Sprintf("downloads/%s_%s.mp4", time.Unix(0, recording.UtcCreatedDate*int64(time.Millisecond)).Format(("2006-01-02_15.04.05")), recording.UniqueId))
            defer fileToWrite.Close()

            if err != nil {
                log.Fatal(err)
            }

			// The videos produced by Arlo are pretty small, even in their longest, best quality settings.
			// DownloadFile() efficiently streams the file from the http.Response.Body directly to a file.
			if err := arlo.DownloadFile(recording.PresignedContentUrl, fileToWrite); err != nil {
				log.Println(err)
			} else {
				log.Printf("Downloaded video %s from %s", recording.CreatedDate, recording.PresignedContentUrl)
			}

			// Mark this go routine as done in the wait group.
			wg.Done()
		}()
	}

	// Wait here until all of the go routines are done.
	wg.Wait()


    // The below example demonstrates how you could delete the cloud recordings after downloading them.
    // Simply uncomment the below code to start using it.

    // Delete all of the videos you just downloaded from the Arlo library.
	// Notice that you can pass the "library" object we got back from the GetLibrary() call.
	/* if err := arlo.BatchDeleteRecordings(library); err != nil {
		log.Println(err)
		return
	} */

	// If we made it here without an exception, then the videos were successfully deleted.
	/* log.Println("Batch deletion of videos completed successfully.") */
}

** (coming soon) For more code examples check out the wiki**

Documentation

Index

Constants

View Source
const (
	DeviceTypeArloQ       = "arloq"
	DeviceTypeArloBridge  = "arlobridge"
	DeviceTypeBasestation = "basestation"
	DeviceTypeCamera      = "camera"
	DeviceTypeLights      = "lights"
	DeviceTypeSiren       = "siren"

	TransIdPrefix = "web"
	BaseUrl       = "https://my.arlo.com/hmsweb"

	// TODO: Implement all of the following urls. There are many here I don't have devices for. :/
	ActiveAutomationUri           = "/users/devices/automation/active"
	AllMediaUri                   = "/users/music/all"
	AnalyticFeedbackUri           = "/users/library/%s/feedback"
	AssignBetaPlanUri             = "/users/assign/smartfeatures"
	AssignDeviceToServicePlanUri  = "/users/devices/provision"
	AutomationDefinitionsUri      = "/users/automation/definitions?uniqueIds=all"
	AutomationModeUri             = "/users/locations/%uniqueId/modes"
	AutomationScheduleUri         = "/users/locations/%uniqueId/schedules"
	BuyUri                        = "http:/www.arlo.com/en-us/products/default.aspx?utm_source=app_desktop&p=all&cid=app"
	CameraOrderUri                = "/users/devices/v2/displayOrder"
	CancelPlanUri                 = "/users/payment/plans/%paymentId/cancel"
	CancelQuotationUri            = "/users/payment/quotations/%paymentId/cancel/v1"
	CapabilitiesUri               = "/resources/capabilities/en/en_%t|i1000.json?t=%s"
	ChangeMobileOffersUri         = "/users/payment/offers/dataplans/change/v5"
	ChangePlanUri                 = "/users/%paymentId/changeplan"
	CheckAccountUri               = "/checkAccountUsage"
	CheckEmailUri                 = "/checkEmailUsage"
	ClaimDeviceUri                = "/users/devices/claimDevice"
	CommunityUri                  = "http:/www.arlo.com/community?utm_source=app_desktop&locale=en"
	ConfirmUserIdUri              = "/users/resend/confirm/email"
	CountryCodesUri               = "/static/countrycodes"
	CreatePaymentAccountUri       = "/users/payment/accounts"
	CreatePlanUri                 = "/users/payment/plans/%paymentId"
	DeleteAccountUri              = "/users/closeAccount"
	DeviceFeaturesUri             = "/users/devices/updateFeatures/feature/%uniqueId"
	DeviceProvisioningUri         = "/users/devices/states"
	DeviceStatisticsUri           = "/users/devices/%uniqueId/data/statistics?t=%s"
	DeviceSupportUri              = "/devicesupport"
	DeviceSupportV2Uri            = "/devicesupport/v2"
	DeviceUri                     = "/users/devices/%deviceId"
	DeviceZoneUri                 = "/users/devices/%uniqueId/activityzones/%zoneId"
	DeviceZonesUri                = "/users/devices/%uniqueId/activityzones"
	DevicesUpdateFeaturesUri      = "/users/devices/updateFeatures/feature"
	DevicesUri                    = "/users/devices/?t=%s"
	DonateRecordUri               = "/users/library/%uniqueId/donate"
	EditAutomationModeUri         = "/users/locations/%uniqueId/modes/%mode/devices/%i"
	EditUri                       = "/users/media"
	EmergencyCallDetailsUri       = "/users/emergency/%emergencyId/call"
	EmergencyLocationSaveUri      = "/users/emergency/locations/%emergencyId"
	EmergencyLocationsUri         = "/users/emergency/locations"
	EventsUri                     = "/users/devices/%uniqueId/events?fromDate=%s&toDate=%s"
	FavoriteUri                   = "/users/library/favorite"
	FieldLengthsUri               = "/static/fieldLengths"
	FriendsDeleteUri              = "/users/friends/remove"
	FriendsUri                    = "/users/friends"
	FullFrameSnapshotUri          = "/users/devices/fullFrameSnapshot"
	GPLUri                        = "https:/vzs3-prod-common.s3.amazonaws.com/license/GPLv1.html"
	HtmlChangeOffersUri           = "/users/payment/offers/html/v5/change"
	HtmlOffersUri                 = "/users/payment/offers/html/v5"
	HtmlPrelimQuotationUri        = "/users/payment/offers/quotation/html/v5"
	HtmlQuotationUri              = "/users/payment/confirmation/%paymentId"
	LibFeedbackUri                = "/library/feedback"
	LibraryStateUri               = "/users/library/state/v1"
	LocateDevicesUri              = "/locateDevice?discoveryToken=%s"
	LocationByZipUri              = "/users/payment/postalcodelookup"
	LocationUri                   = "/users/locations"
	LoginUri                      = "/login"
	LoginV2Uri                    = "/login/v2"
	LogoutUri                     = "/logout"
	MetadataUri                   = "/users/library/metadata/v2"
	MigrateZonesUri               = "/users/devices/%uniqueId/activityzones/migrate"
	MobileOffersUri               = "/users/payment/offers/dataplans/v5"
	ModifyBillingUri              = "/users/payment/billing/%paymentId"
	NotifyResponsesPushServiceUri = "/client/subscribe?token=%s"
	NotifyUri                     = "/users/devices/notify/%s"
	OffersDetailsUri              = "/users/payment/offersdetail"
	OffersDvrChangeUri            = "/users/payment/offers/arloq/html/v5/change"
	OffersDvrUri                  = "/users/payment/offers/arloq/html/v5"
	OffersUri                     = "/users/payment/offers/v3"
	PaymentBillingUri             = "/users/payment/billing/%paymentId"
	PaymentRenewUri               = "/users/payment/autoRenew/%paymentId"
	PaymentTermsLinkUri           = "/paymentTermsAndConditions?t=%s"
	PlacemeterUri                 = ""
	PlaylistMetaUri               = "/users/devices/%uniqueId/playlist/metadata"
	PlaylistUri                   = "/users/devices/%s/playlist?fromDate=%s&toDate=%s"
	PolicyUri                     = "/policy/v1/?t=%s"
	PreferencesUri                = "/users/preferences"
	ProfileUri                    = "/users/profile"
	PttNotifyUri                  = "/users/devices/notify/%parentId"
	PttUri                        = "/users/devices/%s/pushtotalk"
	RMAValidationUri              = "/users/devices/%restrictedDevice/apvalidation"
	RecordingsUri                 = "/users/library"
	RecycleUri                    = "/users/library/recycle"
	RegisterUserUri               = "/register"
	RemoveDeviceUri               = "/users/devices/v2/removeDevice"
	RenameDeviceUri               = "/users/devices/v2/renameDevice"
	RenewPlanUri                  = "/users/payment/plans/%paymentId/renew"
	RenewQuotationUri             = "/users/payment/quotations/%?/renew"
	RequestPasswordResetUri       = "/requestPasswordReset"
	ResetCountUri                 = "/users/library/reset?uniqueId=%s"
	ResetPasswordUri              = "/resetPassword"
	RestartDeviceUri              = "/users/devices/restart"
	SSORegisterUri                = "/ssoregister"
	SecretQuestionsUri            = "/static/secretquestions"
	ServicePlanUri                = "/users/serviceLevel/v3"
	SessionUri                    = "/users/session"
	SetAutomationModeUri          = "/users/locations/%uniqueId/modes/%mode"
	ShareUri                      = "/users/library/share"
	SmartAlertsUri                = "/users/devices/%uniqueId/smartalerts"
	SmartConfigUri                = "/user/smarthome/config"
	StartRecordUri                = "/users/devices/startRecord"
	StartStreamUri                = "/users/devices/startStream"
	StatesCodesUri                = "/static/usstatescodes"
	StopRecordUri                 = "/users/devices/stopRecord"
	StopStreamUri                 = "/users/devices/stopStream"
	StorageQuotaUri               = "/users/quota"
	SupportUri                    = "http:/www.arlo.com/support?utm_source=app_desktop&cc=en"
	TakeSnapshotUri               = "/users/devices/takeSnapshot"
	TempUnitUri                   = "/users/devices/%uniqueId/tempUnit"
	TermsLinkUri                  = "/termsAndConditionsLink?t=%s"
	TermsUri                      = "/termsAndConditions/?t=%s"
	TimeZonesUri                  = "/static/timezones"
	UnsubscribeUri                = "/client/unsubscribe"
	UpdateNameUri                 = "/user"
	UpdatePasswordUri             = "/users/changePassword"
	UpdateUserIdUri               = "/users/changeEmail"
	UserFrameSnapshotUri          = "/users/devices/userSnapshot"
	UsersEmailsUri                = "/users/emails"
	ValidateCouponUri             = "/users/payment/coupondetails"
	ValidateResetUri              = "/validatePasswordReset/%?"
	WakeupUri                     = "/users/devices/wakeup/%deviceId?t=%s"
)

Variables

View Source
var (
	FAILED_TO_PUBLISH     = errors.New("failed to publish")
	FAILED_TO_DECODE_JSON = errors.New("failed to decode json")
	FAILED_TO_SUBSCRIBE   = errors.New("failed to subscribe to seeclient")
)

Functions

func FromUnixMicro

func FromUnixMicro(µs int64) time.Time

func FromUnixMilli

func FromUnixMilli(ms int64) time.Time

Types

type Account

type Account struct {
	UserId        string `json:"userId"`
	Email         string `json:"email"`
	Token         string `json:"token"`
	PaymentId     string `json:"paymentId"`
	Authenticated uint32 `json:"authenticated"`
	AccountStatus string `json:"accountStatus"`
	SerialNumber  string `json:"serialNumber"`
	CountryCode   string `json:"countryCode"`
	TocUpdate     bool   `json:"tocUpdate"`
	PolicyUpdate  bool   `json:"policyUpdate"`
	ValidEmail    bool   `json:"validEmail"`
	Arlo          bool   `json:"arlo"`
	DateCreated   int64  `json:"dateCreated"`
}

Account is the account data.

type AppStore

type AppStore struct {
	Enforce       bool   `json:"enforce"`
	LatestVersion string `json:"latestVersion"`
	UpdateLink    string `json:"updateLink"`
}

type Arlo

type Arlo struct {
	Account      Account
	Basestations Basestations
	Cameras      Cameras
	// contains filtered or unexported fields
}

func Login

func Login(user string, pass string) (arlo *Arlo, err error)

func (*Arlo) BatchDeleteRecordings

func (a *Arlo) BatchDeleteRecordings(l *Library) error

Delete a batch of video recordings from arlo.

The GetLibrary() call response json can be passed directly to this method if you'd like to delete the same list of videos you queried for.

NOTE: {"data": [{"createdDate": r.CreatedDate, "utcCreatedDate": r.UtcCreatedDate, "deviceId": r.DeviceId}]} is all that's really required.

func (*Arlo) CheckSession

func (a *Arlo) CheckSession() (session *Session, err error)

func (*Arlo) DeleteRecording

func (a *Arlo) DeleteRecording(r *Recording) error

Delete a single video recording from arlo.

All of the date info and device id you need to pass into this method are given in the results of the GetLibrary() call.

NOTE: {"data": [{"createdDate": r.CreatedDate, "utcCreatedDate": r.UtcCreatedDate, "deviceId": r.DeviceId}]} is all that's really required.

func (*Arlo) DownloadFile

func (a *Arlo) DownloadFile(url string, w io.Writer) error

func (*Arlo) GetActiveAutomationDefinitions

func (a *Arlo) GetActiveAutomationDefinitions() error

GetActiveAutomationDefinitions gets the mode metadata (this API replaces the older GetModes(), which still works).

func (*Arlo) GetDevices

func (a *Arlo) GetDevices() (devices *Devices, err error)

GetDevices returns an array of all devices. When you call Login, this method is called and all devices are cached in the arlo object.

func (*Arlo) GetLibrary

func (a *Arlo) GetLibrary(fromDate, toDate time.Time) (library *Library, err error)

func (*Arlo) GetLibraryMetaData

func (a *Arlo) GetLibraryMetaData(fromDate, toDate time.Time) (libraryMetaData *LibraryMetaData, err error)

func (*Arlo) GetProfile

func (a *Arlo) GetProfile() (profile *UserProfile, err error)

GetProfile returns the user profile for the currently logged in user.

func (*Arlo) Logout

func (a *Arlo) Logout() error

func (*Arlo) SendAnalyticFeedback

func (a *Arlo) SendAnalyticFeedback(r *Recording) error

SendAnalyticFeedback is only really used by the GUI. It is a response to a prompt asking you whether an object which was tagged by it's AI in your recording was tagged correctly.

func (*Arlo) UpdateDisplayOrder

func (a *Arlo) UpdateDisplayOrder(d DeviceOrder) error

UpdateDisplayOrder sets the display order according to the order defined in the DeviceOrder given.

func (*Arlo) UpdateFriends

func (a *Arlo) UpdateFriends(f Friend) error

func (*Arlo) UpdatePassword

func (a *Arlo) UpdatePassword(pass string) error

func (*Arlo) UpdateProfile

func (a *Arlo) UpdateProfile(firstName, lastName string) error

UpdateProfile takes a first and last name, and updates the user profile with that information.

type AudioDetectionProperties

type AudioDetectionProperties struct {
	BaseDetectionProperties `json:"audioDetection"`
}

AudioDetectionProperties is the Properties struct for the EventStreamPayload type.

type BaseDetectionProperties

type BaseDetectionProperties struct {
	Armed       bool     `json:"armed"`
	Sensitivity int      `json:"sensitivity"`
	Zones       []string `json:"zones,omitempty"`
}

type BaseEventActionProperties

type BaseEventActionProperties struct {
	ActionType        string `json:"actionType"`
	StopType          string `json:"stopType"`
	Timeout           int    `json:"timeout"`
	EmailNotification `json:"emailNotification"`
}

type BaseLoopbackModeProperties

type BaseLoopbackModeProperties struct {
	LoopbackMode string `json:"loopbackMode"`
}

type BaseNightLightProperties

type BaseNightLightProperties struct {
	Brightness   int                     `json:"brightness,omitempty"`
	Enabled      bool                    `json:"enabled"`
	Mode         string                  `json:"mode,omitempty"`
	RGB          NightLightRGBProperties `json:"rgb,omitempty"`
	SleepTime    int64                   `json:"sleepTime,omitempty"`
	SleepTimeRel int                     `json:"sleepTimeRel,omitempty"`
}

type BaseShuffleProperties

type BaseShuffleProperties struct {
	ShuffleActive bool `json:"shuffleActive"`
}

type BaseSleepTimerProperties

type BaseSleepTimerProperties struct {
	SleepTime    int64 `json:"sleepTime"`
	SleepTimeRel int   `json:"sleepTimeRel"`
}

type BaseStationMetadata

type BaseStationMetadata struct {
	InterfaceVersion         int             `json:"interfaceVersion"`
	ApiVersion               int             `json:"apiVersion"`
	State                    string          `json:"state"`
	SwVersion                string          `json:"swVersion"`
	HwVersion                string          `json:"hwVersion"`
	ModelId                  string          `json:"modelId"`
	Capabilities             []string        `json:"capabilities"`
	McsEnabled               bool            `json:"mcsEnabled"`
	AutoUpdateEnabled        bool            `json:"autoUpdateEnabled"`
	TimeZone                 string          `json:"timeZone"`
	OlsonTimeZone            string          `json:"olsonTimeZone"`
	UploadBandwidthSaturated bool            `json:"uploadBandwidthSaturated"`
	AntiFlicker              map[string]int  `json:"antiFlicker"`
	LowBatteryAlert          map[string]bool `json:"lowBatteryAlert"`
	LowSignalAlert           map[string]bool `json:"lowSignalAlert"`
	Claimed                  bool            `json:"claimed"`
	TimeSyncState            string          `json:"timeSyncState"`
	Connectivity             Connectivity    `json:"connectivity"`
}

type Basestation

type Basestation struct {
	Device
	// contains filtered or unexported fields
}

A Basestation is a Device that's not type "camera" (basestation, arloq, arloqs, etc.). This type is here just for semantics. Some methods explicitly require a device of a certain type.

func (*Basestation) Arm

func (b *Basestation) Arm() (response *EventStreamResponse, err error)

func (*Basestation) DeleteMode

func (b *Basestation) DeleteMode(mode string) (response *EventStreamResponse, err error)

func (*Basestation) Disarm

func (b *Basestation) Disarm() (response *EventStreamResponse, err error)

func (*Basestation) Disconnect

func (b *Basestation) Disconnect() error

func (*Basestation) GetAssociatedCamerasState

func (b *Basestation) GetAssociatedCamerasState() (response *EventStreamResponse, err error)

func (*Basestation) GetCalendarMode

func (b *Basestation) GetCalendarMode() (response *EventStreamResponse, err error)

func (*Basestation) GetModes

func (b *Basestation) GetModes() (response *EventStreamResponse, err error)

func (*Basestation) GetRules

func (b *Basestation) GetRules() (response *EventStreamResponse, err error)

func (*Basestation) GetState

func (b *Basestation) GetState() (response *EventStreamResponse, err error)

func (*Basestation) IsConnected

func (b *Basestation) IsConnected() error

func (*Basestation) NotifyEventStream

func (b *Basestation) NotifyEventStream(payload EventStreamPayload, msg string) error

func (*Basestation) Ping

func (b *Basestation) Ping() error

Ping makes a call to the subscriptions endpoint. The Arlo event stream requires this message to be sent every 30s.

func (*Basestation) SetCalendarMode

func (b *Basestation) SetCalendarMode(active bool) (response *EventStreamResponse, err error)

SetCalendarMode toggles calendar mode. NOTE: The Arlo API seems to disable calendar mode when switching to other modes, if it's enabled. You should probably do the same, although, the UI reflects the switch from calendar mode to say armed mode without explicitly setting calendar mode to inactive.

func (*Basestation) SetCustomMode

func (b *Basestation) SetCustomMode(mode string) (response *EventStreamResponse, err error)

func (*Basestation) SirenOff

func (b *Basestation) SirenOff() (response *EventStreamResponse, err error)

func (*Basestation) SirenOn

func (b *Basestation) SirenOn() (response *EventStreamResponse, err error)

func (*Basestation) Subscribe

func (b *Basestation) Subscribe() error

func (*Basestation) Unsubscribe

func (b *Basestation) Unsubscribe() error

type BasestationModeProperties

type BasestationModeProperties struct {
	Active string `json:"active"`
}

type BasestationScheduleProperties

type BasestationScheduleProperties struct {
	Active bool `json:"active"`
}

type Basestations

type Basestations []Basestation

Basestations is a slice of Basestation objects.

func (*Basestations) Find

func (bs *Basestations) Find(deviceId string) *Basestation

Find returns a basestation with the device id passed in.

type Camera

type Camera Device

A Camera is a Device of type "camera". This type is here just for semantics. Some methods explicitly require a device of a certain type.

func (*Camera) Continuous

func (c *Camera) Continuous() (response *EventStreamResponse, err error)

func (*Camera) DisableAudioAlerts

func (c *Camera) DisableAudioAlerts(sensitivity int) (response *EventStreamResponse, err error)

func (*Camera) DisableMotionAlerts

func (c *Camera) DisableMotionAlerts(sensitivity int, zones []string) (response *EventStreamResponse, err error)

func (*Camera) DisableNightLightTimer

func (c *Camera) DisableNightLightTimer(sleepTimeRel int) (response *EventStreamResponse, err error)

func (*Camera) DisableSleepTimer

func (c *Camera) DisableSleepTimer(sleepTimeRel int) (response *EventStreamResponse, err error)

func (*Camera) EnableAudioAlerts

func (c *Camera) EnableAudioAlerts(sensitivity int) (response *EventStreamResponse, err error)

func (*Camera) EnableMotionAlerts

func (c *Camera) EnableMotionAlerts(sensitivity int, zones []string) (response *EventStreamResponse, err error)

func (*Camera) EnableNightLightTimer

func (c *Camera) EnableNightLightTimer(sleepTime int64, sleepTimeRel int) (response *EventStreamResponse, err error)

func (*Camera) EnableSleepTimer

func (c *Camera) EnableSleepTimer(sleepTime int64, sleepTimeRel int) (response *EventStreamResponse, err error)

func (*Camera) GetAudioPlayback

func (c *Camera) GetAudioPlayback() (response *EventStreamResponse, err error)

func (*Camera) GetCvrPlaylist

func (c *Camera) GetCvrPlaylist(fromDate, toDate time.Time) (playlist *CvrPlaylist, err error)

This function downloads a Cvr Playlist file for the period fromDate to toDate.

func (*Camera) Mute

func (c *Camera) Mute() (response *EventStreamResponse, err error)

Mute mutes the audio playback.

func (*Camera) Next

func (c *Camera) Next() error

Next moves audio playback to the next track.

func (*Camera) NightLight

func (c *Camera) NightLight(on bool) (response *EventStreamResponse, err error)

The follow methods are all related to the nightlight features of Arlo Baby.

NOTE: The current state is in: cameras[0]["properties"][0]["nightLight"] returned from the basestation.GetAssociatedCamerasState() method.

func (*Camera) Off

func (c *Camera) Off() (response *EventStreamResponse, err error)

On turns a camera off; meaning it won't detect and record events.

func (*Camera) On

func (c *Camera) On() (response *EventStreamResponse, err error)

On turns a camera on; meaning it will detect and record events.

func (*Camera) Pause

func (c *Camera) Pause() error

Pause pauses audio playback.

func (*Camera) Play

func (c *Camera) Play(trackId string, position int) error

Play plays an audio track, specified by the track ID, from a given position starting from 0 seconds.

func (*Camera) PushToTalk

func (c *Camera) PushToTalk() error

PushToTalk starts a push-to-talk session. FIXME: This feature requires more API calls to make it actually work, and I haven't figure out how to fully implement it. It appears that the audio stream is Real-Time Transport Protocol (RTP), which requires a player (ffmpeg?) to consume the stream.

func (*Camera) SetAlertNotificationMethods

func (c *Camera) SetAlertNotificationMethods(action string, email, push bool) (response *EventStreamResponse, err error)

action: disabled OR recordSnapshot OR recordVideo

func (*Camera) SetBrightness

func (c *Camera) SetBrightness(brightness int) (response *EventStreamResponse, err error)

SetBrightness sets the camera brightness. NOTE: Brightness is between -2 and 2 in increments of 1 (-2, -1, 0, 1, 2). Setting it to an invalid value has no effect.

func (*Camera) SetLoopBackMode

func (c *Camera) SetLoopBackMode(loopbackMode string) (response *EventStreamResponse, err error)

func (*Camera) SetNightLightBrightness

func (c *Camera) SetNightLightBrightness(level int) (response *EventStreamResponse, err error)

func (*Camera) SetNightLightColor

func (c *Camera) SetNightLightColor(red, blue, green int) (response *EventStreamResponse, err error)

SetNightLightColor sets the night light color to the RGB value specified by the three parameters, which have valid values from 0-255.

func (*Camera) SetNightLightMode

func (c *Camera) SetNightLightMode(mode string) (response *EventStreamResponse, err error)

SetNightLightMode set the night light mode. Valid values are: "rainbow" or "rgb".

func (*Camera) SetVolume

func (c *Camera) SetVolume(volume int) (response *EventStreamResponse, err error)

SetVolume sets the volume of the audio playback to a level from 0-100.

func (*Camera) Shuffle

func (c *Camera) Shuffle(on bool) (response *EventStreamResponse, err error)

Shuffle toggles the audio play back mode to shuffle or not.

func (*Camera) SingleTrack

func (c *Camera) SingleTrack() (response *EventStreamResponse, err error)

func (*Camera) StartRecording

func (c *Camera) StartRecording() (url string, err error)

StartRecording causes the camera to start recording and returns a url that you must start reading from using ffmpeg or something similar.

func (*Camera) StartStream

func (c *Camera) StartStream() (url string, err error)

If you call StartStream(), you have to start reading data from the stream, or streaming will be cancelled and taking a snapshot may fail (since it requires the stream to be active).

func (*Camera) StopRecording

func (c *Camera) StopRecording() error

StopRecording causes the camera to stop recording.

func (*Camera) TakeSnapshot

func (c *Camera) TakeSnapshot() (response *EventStreamResponse, err error)

NOTE: You should not use this function is you just want a snapshot and aren't intending to stream. Use TriggerFullFrameSnapshot() instead.

NOTE: Use DownloadSnapshot() to download the actual image file. TODO: Need to refactor the even stream code to allow handling of events whose transIds don't correlate. :/

func (*Camera) TriggerFullFrameSnapshot

func (c *Camera) TriggerFullFrameSnapshot() (response *EventStreamResponse, err error)

TriggerFullFrameSnapshot causes the camera to record a full-frame snapshot. The presignedFullFrameSnapshotUrl url is returned. Use DownloadSnapshot() to download the actual image file. TODO: Need to refactor the even stream code to allow handling of events whose transIds don't correlate. :/

func (*Camera) UnMute

func (c *Camera) UnMute() (response *EventStreamResponse, err error)

UnMute un-mutes the audio playback.

type CameraProperties

type CameraProperties struct {
	PrivacyActive bool `json:"privacyActive"`
	Brightness    int  `json:"brightness,omitempty"`
}

type Cameras

type Cameras []Camera

Cameras is a slice of Camera objects.

func (*Cameras) Find

func (cs *Cameras) Find(deviceId string) *Camera

Find returns a camera with the device id passed in.

type Connectivity

type Connectivity struct {
	ActiveNetwork  string `json:"activeNetwork,omitempty"`
	APN            string `json:"apn,omitempty"`
	CarrierFw      string `json:"carrierFw,omitempty"`
	Connected      bool   `json:"connected,omitempty"`
	FWVersion      string `json:"fwVersion,omitempty"`
	ICCID          string `json:"iccid,omitempty"`
	IMEI           string `json:"imei,omitempty"`
	MEPStatus      string `json:"mepStatus,omitempty"`
	MSISDN         string `json:"msisdn,omitempty"`
	NetworkMode    string `json:"networkMode,omitempty"`
	NetworkName    string `json:"networkName,omitempty"`
	RFBand         int    `json:"rfBand,omitempty"`
	Roaming        bool   `json:"roaming"`
	RoamingAllowed bool   `json:"roamingAllowed"`
	SignalStrength string `json:"signalStrength,omitempty"`
	Type           string `json:"type,omitempty"`
	WWANIPAddr     string `json:"wwanIpAddr,omitempty"`
}

Connectivity is part of the Device data.

type CvrPlaylist

type CvrPlaylist struct {
	ToDate   string                               `json:"toDate"`
	Playlist map[string]map[string][]PlaylistItem `json:"playlist"`
	UserId   string                               `json:"userId"`
	FromDate string                               `json:"fromDate"`
	DeviceId string                               `json:"deviceId"`
	UniqueId string                               `json:"uniqueId"`
}

type CvrPlaylistResponse

type CvrPlaylistResponse struct {
	Data CvrPlaylist
	Status
}

type Data

type Data struct {
	Message string `json:"message,omitempty"`
	Reason  string `json:"reason,omitempty"`
	Error   string `json:"error,omitempty"`
}

URL is part of the Status message fragment returned by most calls to the Arlo API. URL is only populated when Success is false.

type Device

type Device struct {
	AnalyticsEnabled              bool         `json:"analyticsEnabled"`
	ArloMobilePlan                bool         `json:"arloMobilePlan"`
	ArloMobilePlanId              string       `json:"arloMobilePlanId"`
	ArloMobilePlanName            string       `json:"arloMobilePlanName"`
	ArloMobilePlanThreshold       int          `json:"arloMobilePlanThreshold"`
	Connectivity                  Connectivity `json:"connectivity"`
	CriticalBatteryState          bool         `json:"criticalBatteryState"`
	DateCreated                   int64        `json:"dateCreated"`
	DeviceId                      string       `json:"deviceId"`
	DeviceName                    string       `json:"deviceName"`
	DeviceType                    string       `json:"deviceType"`
	DisplayOrder                  uint8        `json:"displayOrder"`
	FirmwareVersion               string       `json:"firmwareVersion"`
	InterfaceVersion              string       `json:"interfaceVersion"`
	InterfaceSchemaVer            string       `json:"interfaceSchemaVer"`
	LastImageUploaded             string       `json:"lastImageUploaded"`
	LastModified                  int64        `json:"lastModified"`
	MigrateActivityZone           bool         `json:"migrateActivityZone"`
	MobileCarrier                 string       `json:"mobileCarrier"`
	MobileTrialUsed               bool         `json:"mobileTrialUsed"`
	PermissionsFilePath           string       `json:"permissionsFilePath"`
	PermissionsSchemaVer          string       `json:"permissionsSchemaVer"`
	PermissionsVerison            string       `json:"permissionsVerison"` // WTF? Netgear developers think this is OK... *sigh*
	PermissionsVersion            string       `json:"permissionsVersion"`
	PresignedFullFrameSnapshotUrl string       `json:"presignedFullFrameSnapshotUrl"`
	PresignedLastImageUrl         string       `json:"presignedLastImageUrl"`
	PresignedSnapshotUrl          string       `json:"presignedSnapshotUrl"`
	MediaObjectCount              uint8        `json:"mediaObjectCount"`
	ModelId                       string       `json:"modelId"`
	Owner                         Owner        `json:"owner"`
	ParentId                      string       `json:"parentId"`
	Properties                    Properties   `json:"properties"`
	UniqueId                      string       `json:"uniqueId"`
	UserId                        string       `json:"userId"`
	UserRole                      string       `json:"userRole"`
	State                         string       `json:"state"`
	XCloudId                      string       `json:"xCloudId"`
	// contains filtered or unexported fields
}

A Device is the device data, this can be a camera, basestation, arloq, etc.

func (Device) IsArloQ

func (d Device) IsArloQ() bool

func (Device) IsBasestation

func (d Device) IsBasestation() bool

func (Device) IsCamera

func (d Device) IsCamera() bool

func (Device) IsLight

func (d Device) IsLight() bool

func (Device) IsSiren

func (d Device) IsSiren() bool

func (*Device) UpdateDeviceName

func (d *Device) UpdateDeviceName(name string) error

UpdateDeviceName sets the name of the given device to the name argument.

type DeviceOrder

type DeviceOrder struct {
	Devices map[string]int `json:"devices"`
}

A DeviceOrder holds a map of device ids and a numeric index. The numeric index is the device order. Device order is mainly used by the UI to determine which order to show the devices.

{
  "devices":{
    "XXXXXXXXXXXXX":1,
    "XXXXXXXXXXXXX":2,
    "XXXXXXXXXXXXX":3
}

type DeviceResponse

type DeviceResponse struct {
	Data Devices
	Status
}

DeviceResponse is an intermediate struct used when parsing data from the GetDevices() call.

type Devices

type Devices []Device

Devices is a slice of Device objects.

func (*Devices) Find

func (ds *Devices) Find(deviceId string) *Device

Find returns a device with the device id passed in.

func (Devices) FindCameras

func (ds Devices) FindCameras(basestationId string) Cameras

func (Devices) GetBasestations

func (ds Devices) GetBasestations() *Basestations

GetBasestations returns a Basestations object containing all devices that are NOT type "camera". I did this because some device types, like arloq, don't have a basestation. So, when interacting with them you must treat them like a basestation and a camera. Cameras also includes devices of this type, so you can get the same data there or cast.

func (Devices) GetCameras

func (ds Devices) GetCameras() *Cameras

GetCameras returns a Cameras object containing all devices that are of type "camera". I did this because some device types, like arloq, don't have a basestation. So, when interacting with them you must treat them like a basestation and a camera. Basestations also includes devices of this type, so you can get the same data there or cast.

type EmailNotification

type EmailNotification struct {
	Enabled          bool     `json:"enabled"`
	EmailList        []string `json:"emailList"`
	PushNotification bool     `json:"pushNotification"`
}

type EventActionProperties

type EventActionProperties struct {
	BaseEventActionProperties `json:"eventAction"`
}

type EventStreamPayload

type EventStreamPayload struct {
	Action          string      `json:"action,omitempty"`
	Resource        string      `json:"resource,omitempty"`
	PublishResponse bool        `json:"publishResponse"`
	Properties      interface{} `json:"properties,omitempty"`
	TransId         string      `json:"transId"`
	From            string      `json:"from"`
	To              string      `json:"to"`
}

EventStreamPayload is the message that will be sent to the arlo servers via the /notify API.

type EventStreamResponse

type EventStreamResponse struct {
	EventStreamPayload
	Status string `json:"status,omitempty"`
}

type Favorite

type Favorite struct {
	NonFavorite uint8 `json:"nonFavorite"`
	Favorite    uint8 `json:"Favorite"`
}

type Friend

type Friend struct {
	FirstName    string      `json:"firstName"`
	LastName     string      `json:"lastName"`
	Devices      DeviceOrder `json:"devices"`
	LastModified int64       `json:"lastModified"`
	AdminUser    bool        `json:"adminUser"`
	Email        string      `json:"email"`
	Id           string      `json:"id"`
}

Friend is the account data for non-primary account holders designated as friends.

type Library

type Library []Recording

type LibraryMetaData

type LibraryMetaData struct {
	DateTo   string                         `json:"dateTo"`
	DateFrom string                         `json:"dateFrom"`
	Meta     map[string]map[string]Favorite `json:"meta"`
}

LibraryMetaData is the library meta data.

type LibraryMetaDataResponse

type LibraryMetaDataResponse struct {
	Data LibraryMetaData
	Status
}

LibraryMetaDataResponse is an intermediate struct used when parsing data from the GetLibraryMetaData() call.

type LibraryResponse

type LibraryResponse struct {
	Data Library
	Status
}

type LoginResponse

type LoginResponse struct {
	Data Account
	Status
}

LoginResponse is an intermediate struct used when parsing data from the Login() call.

type LoopbackModeProperties

type LoopbackModeProperties struct {
	Config BaseLoopbackModeProperties `json:"config"`
}

type MotionDetectionProperties

type MotionDetectionProperties struct {
	BaseDetectionProperties `json:"motionDetection"`
}

MotionDetectionProperties is the Properties struct for the EventStreamPayload type.

type NightLightProperties

type NightLightProperties struct {
	NightLight BaseNightLightProperties `json:"nightLight"`
}

type NightLightRGBProperties

type NightLightRGBProperties struct {
	Red   int `json:"red"`
	Green int `json:"green"`
	Blue  int `json:"blue"`
}

type Owner

type Owner struct {
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
	OwnerId   string `json:"ownerId"`
}

Owner is the owner of a Device data.

type PlayTrackProperties

type PlayTrackProperties struct {
	TrackId  string `json:"trackId"`
	Position int    `json:"position"`
}

type PlaylistItem

type PlaylistItem struct {
	TZ   string `json:"tz"`
	D    string `json:"d"`
	URL  string `json:"url"`
	SURL string `json:"sUrl"`
	S    string `json:"s"`
	U    int64  `json:"u"`
}

type Properties

type Properties struct {
	ModelId       string `json:"modelId"`
	OlsonTimeZone string `json:"olsonTimeZone"`
	HwVersion     string `json:"hwVersion"`
}

Properties is the Device properties data.

type Recording

type Recording struct {
	MediaDurationSecond   int    `json:"mediaDurationSecond"`
	ContentType           string `json:"contentType"`
	Name                  string `json:"name"`
	PresignedContentUrl   string `json:"presignedContentUrl"`
	LastModified          int64  `json:"lastModified"`
	LocalCreatedDate      int64  `json:"localCreatedDate"`
	PresignedThumbnailUrl string `json:"presignedThumbnailUrl"`
	Reason                string `json:"reason"`
	DeviceId              string `json:"deviceId"`
	CreatedBy             string `json:"createdBy"`
	CreatedDate           string `json:"createdDate"`
	TimeZone              string `json:"timeZone"`
	OwnerId               string `json:"ownerId"`
	UtcCreatedDate        int64  `json:"utcCreatedDate"`
	CurrentState          string `json:"currentState"`
	MediaDuration         string `json:"mediaDuration"`
	UniqueId              string `json:"uniqueId"`
}

presignedContentUrl is a link to the actual video in Amazon AWS. presignedThumbnailUrl is a link to the thumbnail .jpg of the actual video in Amazon AWS.

type RecordingResponse

type RecordingResponse struct {
	Data Stream
	Status
}

type Session

type Session struct {
	AccountStatus string `json:"accountStatus"`

	AppStore `json:"appStore"`
	Account
}

type SessionResponse

type SessionResponse struct {
	Data Session
	Status
}

type ShuffleProperties

type ShuffleProperties struct {
	Config BaseShuffleProperties `json:"config"`
}

type SirenProperties

type SirenProperties struct {
	SirenState string `json:"sirenState"`
	Duration   int    `json:"duration"`
	Volume     int    `json:"volume"`
	Pattern    string `json:"pattern"`
}

type SleepTimerProperties

type SleepTimerProperties struct {
	Config BaseSleepTimerProperties `json:"config"`
}

type SpeakerProperties

type SpeakerProperties struct {
	Speaker VolumeProperties `json:"speaker"`
}

type Status

type Status struct {
	Data    `json:"URL,omitempty"`
	Success bool `json:"success"`
}

Status is the message fragment returned from most http calls to the Arlo API.

type Stream

type Stream struct {
	URL string `json:"url"`
}

type StreamResponse

type StreamResponse struct {
	Data Stream
	Status
}

type UserProfile

type UserProfile struct {
	Type           string `json:"_type"`
	AcceptedPolicy int    `json:"acceptedPolicy"`
	Country        string `json:"country"`
	CurrentPolicy  int    `json:"currentPolicy"`
	FirstName      string `json:"firstName"`
	LastName       string `json:"lastName"`
	ValidEmail     bool   `json:"validEmail"`
}

type UserProfileResponse

type UserProfileResponse struct {
	Data UserProfile
	Status
}

type VolumeProperties

type VolumeProperties struct {
	Mute   bool `json:"mute"`
	Volume int  `json:"volume,omitempty"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL