arlo

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

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

Go to latest
Published: Feb 6, 2017 License: MIT Imports: 13 Imported by: 0

README

Arlo-go

An SDK for arming and disarming Netgear's Arlo camera system.

This library offers a basic method to quickly arm and disarm the system via CLI. This was created due to how slow it is to arm / disarm the system via the Arlo Android app.

The CLI app and code example can be found in the cmd directory.

Disclaimer

This project was made for convenience, and practise of the Go language. It does not come with unit tests or guarantees that it will work for non-default set ups. Use at your own discretion.

Getting started with the CLI app

Build
cd cmd && build -o arlo main.go
Config set up
cp config.toml.sample config.toml

// Enter your Arlo details in the config file
Args
Mode: -m <arm|disarm>
Arm / Disarm
// Arm
./arlo -m arm

// Disarm
./arlo -m disarm

Documentation

Index

Constants

View Source
const (
	ModeDeviceArm    = "mode1"
	ModeDeviceDisarm = "mode0"
)

Device modes - assumes default mode listing order.

View Source
const (
	DeviceTypeBasestation = "basestation"
	DeviceTypeCamera      = "camera"
)

Variables

View Source
var (
	ErrRequestFailedStatusNotOK = errors.New("request failed")
	ErrRequestUnsuccessful      = errors.New("request unsuccessful")
	ErrNotLoggedIn              = errors.New("not logged in yet")
	ErrNoBasestationFound       = errors.New("no basestation found")
	ErrNoCamerasFound           = errors.New("no cameras found")
	ErrRequestUnauthorized      = errors.New("401 unauthorized")
)

Errors

Functions

This section is empty.

Types

type Client

type Client struct {
	// For initial login
	Username string
	Password string
	UserID   string

	// For request authorization
	Token string

	HTTPClient   *http.Client
	Devices      []Device
	EventStreams map[string]*EventStream

	Verbose bool
}

Client represents a client to the Arlo API.

func NewClient

func NewClient() *Client

NewClient returns a new Arlo client.

func (*Client) Arm

func (a *Client) Arm(deviceID, xCloudID string) error

Arm arms the basestation.

func (*Client) Disarm

func (a *Client) Disarm(deviceID, xCloudID string) error

Disarm disarms the basestation.

func (*Client) GetBasestation

func (a *Client) GetBasestation() (*Device, error)

GetBasestation attempts to retrieve the basestation device from memory. GetDevices() should be called beforehand.

func (*Client) GetCameras

func (a *Client) GetCameras() ([]Device, error)

GetCameras attempts to retrieve a list of camera devices from memory. GetDevices() should be called beforehand.

func (*Client) GetDevices

func (a *Client) GetDevices() ([]Device, error)

GetDevices returns a list of available devices.

func (*Client) Login

func (a *Client) Login() error

Login logs in and retrieves an access token. The login response has been stripped down to values used by the library.

func (*Client) Logout

func (a *Client) Logout() error

Logout logs the client out.

func (*Client) Notify

func (a *Client) Notify(deviceID, xCloudID string, payload NotifyPayload) (string, error)

Notify sends a message to the Arlo notify API. A response will be returned via the device's SSE stream.

func (*Client) Register

func (a *Client) Register(deviceID, xCloudID string) error

Register registers a device to receive event stream messages.

func (*Client) Subscribe

func (a *Client) Subscribe(deviceID, xCloudID string) error

Subscribe connects to the event stream for the given device ID.

type Device

type Device struct {
	UserID     string `json:"userId"`
	DeviceID   string `json:"deviceId"`
	UniqueID   string `json:"uniqueId"`
	DeviceType string `json:"deviceType"`
	DeviceName string `json:"deviceName"`
	XCloudID   string `json:"xCloudId"`
}

Device represents a basestation or camera.

func (Device) IsBasestation

func (d Device) IsBasestation() bool

func (Device) IsCamera

func (d Device) IsCamera() bool

type EventStream

type EventStream struct {
	Registered bool
	Connected  bool
	SSEClient  *sse.Client
	Events     chan *sse.Event

	Verbose bool
}

func NewEventStream

func NewEventStream() *EventStream

func (*EventStream) Listen

func (e *EventStream) Listen() error

type NotifyPayload

type NotifyPayload struct {
	Action          string      `json:"action,omitempty"`
	Resource        string      `json:"resource,omitempty"`
	PublishResponse bool        `json:"publishResponse,omitempty"`
	Properties      interface{} `json:"properties,omitempty"`

	TransID string `json:"transId"`
	From    string `json:"from"`
	To      string `json:"to"`
}

NotifyPayload represents the message that will be sent to the Arlo servers via the Notify API.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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