marzipan

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2018 License: MIT Imports: 12 Imported by: 1

README

Marzipan

Marzipan is a simple Go websocket client for the Securifi Almond routers.

Status

This project is in alpha currently and only supports a small section of the Securifi websocket API.

Documentation

Index

Constants

View Source
const (
	Action              = "Action"
	CommandType         = "CommandType"
	MobileInternalIndex = "MobileInternalIndex"
)
View Source
const DefaultHost = "localhost"
View Source
const DefaultPort = "7681"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides an API for interacting with the Securifi Almond websocket API.

func NewClient

func NewClient(c ClientConfig) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Do

func (c *Client) Do(r Request) (string, <-chan Response, error)

Do performs a request and returns a channel were the response can be retrieved.

func (*Client) Request

func (c *Client) Request(r Request) error

Request sends a request but does not wait for the response.

func (*Client) Subscribe

func (c *Client) Subscribe(ct string) (<-chan Response, error)

Subscribe returns a channel that will receive events for the desired command type. If ct is an empty string then responses to all command types are returned. Send operations on the channel are non-blocking so events may be dropped.

type ClientConfig

type ClientConfig struct {
	// Host is a host:port adderss of the Almond router.
	// The default is localhost:7681.
	Host     string
	User     string
	Password string
	// Logger is used to log any errors that may occur.
	// If nil no logs will be written.
	Logger *log.Logger
}

type ClientSpec

type ClientSpec struct {
	ID            string `json:"ID"`
	Name          string `json:"Name"`
	Connection    string `json:"Connection"`
	MAC           string `json:"MAC"`
	Type          string `json:"Type"`
	LastKnownIP   string `json:"LastKnownIP"`
	Active        bool   `json:"Active"`
	UseAsPresence bool   `json:"UseAsPresence"`
}

type Device

type Device struct {
	Data         map[string]string      `json:"Data"`
	DeviceValues map[string]DeviceValue `json:"DeviceValues"`
}

type DeviceList

type DeviceList struct {
	Meta
	Devices map[string]Device
}

type DeviceValue

type DeviceValue struct {
	Name  string
	Value string
}

type DynamicAlmondModeUpdated

type DynamicAlmondModeUpdated struct {
	Meta
	Mode    string
	EmailId string
}

type DynamicClientAdded

type DynamicClientAdded struct {
	Meta
	Clients map[string]ClientSpec `json:"Clients"`
}

type DynamicClientJoined

type DynamicClientJoined struct {
	Meta
	Clients map[string]ClientSpec `json:"Clients"`
}

type DynamicClientLeft

type DynamicClientLeft struct {
	Meta
	Clients map[string]ClientSpec `json:"Clients"`
}

type DynamicIndexUpdated

type DynamicIndexUpdated struct {
	Meta
	Devices map[string]Device `json:"Devices"`
}

type Meta

type Meta struct {
	MII string `json:"MobileInternalIndex,omitempty"`
	CT  string `json:"CommandType,omitempty"`
	ACT string `json:"Action,omitempty"`
}

func (*Meta) Action

func (m *Meta) Action() string

func (*Meta) CommandType

func (m *Meta) CommandType() string

func (*Meta) MobileInternalIndex

func (m *Meta) MobileInternalIndex() string

func (*Meta) SetAction

func (m *Meta) SetAction(a string)

func (*Meta) SetCommandType

func (m *Meta) SetCommandType(ct string)

func (*Meta) SetMobileInternalIndex

func (m *Meta) SetMobileInternalIndex(mii string)

type Request

type Request interface {
	SetMobileInternalIndex(string)
}

func NewDeviceListRequest

func NewDeviceListRequest() Request

func NewUpdateDeviceIndexRequest

func NewUpdateDeviceIndexRequest(id, index, value string) Request

type Response

type Response interface {
	MobileInternalIndex() string
	CommandType() string
	Action() string
}

type UpdateDeviceIndex

type UpdateDeviceIndex struct {
	Meta
	Success string `json:"Success"`
}

type UpdateDeviceIndexRequest

type UpdateDeviceIndexRequest struct {
	Meta
	ID    string `json:"ID"`
	Index string `json:"Index"`
	Value string `json:"Value"`
}

Jump to

Keyboard shortcuts

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