types

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(input, output interface{}, hooks ...mapstructure.DecodeHookFunc) error

func IntToJsIntArr

func IntToJsIntArr(sourceType, targetType reflect.Type, sourceData interface{}) (interface{}, error)

func StringInterfaceToJsonRawMessage

func StringInterfaceToJsonRawMessage(sourceType, targetType reflect.Type, sourceData interface{}) (interface{}, error)

func StringToJsonTime

func StringToJsonTime(sourceType, targetType reflect.Type, sourceData interface{}) (interface{}, error)

Types

type Action

type Action uint16

Action is an enum of all the possible commands

const (
	SET     Action = iota // Turn on/activate something
	RESET                 // Turn off/deactivate something
	TOGGLE                // Toggle something from on/activated to off/deactivated
	PUSH                  // Used to define actions shuch as the one of pushing a button
	GET                   // Retrieve a value
	SUNSET                // Sunset related command
	SUNRISE               // Sunrise Related command
)

Available command types

type Command

type Command struct {
	Type CommandType
	Data json.RawMessage
}

Command is the root object in every message

func NewCommand

func NewCommand(t CommandType, data interface{}) *Command

NewCommand creates a command given a type and his content

func (*Command) String

func (c *Command) String() string

type CommandType

type CommandType uint8

CommandType represent the type of the current message

const (
	HeartbeatType CommandType = iota
	DigitalCommandType
	TimerCommandType
	StatusSubscriptionCommandType
	StatusNotificationCommandType
	StatusUpdateCommandType
	VersionRequestCommandType
	VersionReplyCommandType
	SunsetCommandType
)

Message types used in various plugins

func (CommandType) String

func (i CommandType) String() string

type DigitalCommand

type DigitalCommand struct {
	Command  JSIntArr `json:",JSIntArr"`
	DeviceID string
}

DigitalCommand used to instruct the appliance to execute a Command on a gpio pin

type EnabledDays

type EnabledDays uint16

EnabledDays days on which a TimedCommand is enabled used as binary flag

const (
	Noday     EnabledDays = 0x00
	Sunday    EnabledDays = 0x01
	Monday    EnabledDays = 0x02
	Tuesday   EnabledDays = 0x04
	Wednesday EnabledDays = 0x08
	Thursday  EnabledDays = 0x10
	Friday    EnabledDays = 0x20
	Saturday  EnabledDays = 0x40
)

Days of the week

type JSIntArr

type JSIntArr []Action

JSIntArr an int array that can be rapresented in javascript like an integer or like an array of integers

func (JSIntArr) MarshalJSON

func (t JSIntArr) MarshalJSON() ([]byte, error)

func (*JSIntArr) UnmarshalJSON

func (t *JSIntArr) UnmarshalJSON(data []byte) error

type JSONTime

type JSONTime struct {
	time.Time
}

JSONTime a time specialization that allows a compact string rapresentation: hh:mm

func (JSONTime) MarshalJSON

func (j JSONTime) MarshalJSON() ([]byte, error)

MarshalJSON returns the js string that represent the current hours and minutes

func (*JSONTime) UnmarshalJSON

func (j *JSONTime) UnmarshalJSON(data []byte) error

UnmarshalJSON returns the time corresponding to the string "15:04"

type SimpleCommand

type SimpleCommand struct {
	Command JSIntArr `json:",JSIntArr"`
}

SimpleCommand is used to send a basic request regarding the whole system

type Status

type Status map[string]interface{}

Status is the response to a status request Command the key is the handler name value can be anything

type TimedCommand

type TimedCommand struct {
	Action  JSIntArr    `json:",JSIntArr"`
	TimerID uint16      `json:",int,omitempty"`
	Time    JSONTime    `json:",string,omitempty"`
	Repeat  EnabledDays `json:",int,omitempty"`
	Command *Command
}

TimedCommand represent a command with an associated delay in minutes if TimerID is zero it means it is a new timer. otherwise it should edit the timer with the corresponding id

type VersionIndication

type VersionIndication struct {
	CurrentVersion   string
	AvailableVersion string
}

VersionIndication returns info about the current version and the optional update available

Jump to

Keyboard shortcuts

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