gohome

package module
v0.0.0-...-54be368 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MIT Imports: 15 Imported by: 0

README

gohome

MyHome OpenWebNet message sender command

Documentation

Index

Constants

View Source
const COMMAND = "COMMAND"
View Source
const DIMENSIONGET = "DIMENSIONGET"
View Source
const DIMENSIONSET = "DIMENSIONSET"
View Source
const INVALID = "INVALID"
View Source
const PROJECT = "gohome-dev"
View Source
const REQUEST = "REQUEST"
View Source
const SPECIAL = "SPECIAL"
View Source
const SUBSCRIPTION = "home_listening"
View Source
const TOPIC = "calling_home"

Variables

View Source
var ErrAmbientNotFound = errors.New("ambient not found")

ErrAmbientNotFound is returned when the desired where is not found in the conf file

View Source
var ErrConnectionFailed = errors.New("CONNECTION FAILED")
View Source
var ErrLightNotFound = errors.New("light not found")

ErrLightNotFound is returned when the desired loight is not found in the conf file

View Source
var ErrNAK = errors.New("NAK")
View Source
var ErrNoConnection = errors.New("NO CONNECTION")
View Source
var ErrNoData = errors.New("NO DATA")
View Source
var ErrServerNotFound = errors.New("SERVER NOT FOUND")
View Source
var ErrWhatNotFound = errors.New("WHAT not found")
View Source
var ErrWhereNotInPlant = errors.New("WHERE not found in the current plant configuration")

ErrWhereNotInPlant is returned whene a where numeric code is not found in the current plant configuration

View Source
var ErrWhoNotFound = errors.New("WHO not found")
View Source
var SystemMessages = map[string]Message{
	"ACK":                   Message{Kind: SPECIAL, /* contains filtered or unexported fields */},
	"NACK":                  Message{Kind: SPECIAL, /* contains filtered or unexported fields */},
	"QUERY_ALL":             Message{Kind: SPECIAL, /* contains filtered or unexported fields */},
	"OPEN_COMMAND_SESSION":  Message{Kind: SPECIAL, /* contains filtered or unexported fields */},
	"OPEN_EVENT_SESSION":    Message{Kind: SPECIAL, /* contains filtered or unexported fields */},
	"OPEN_SCENARIO_SESSION": Message{Kind: SPECIAL, /* contains filtered or unexported fields */},
}

SystemMessages contains the OpenWebNet codes for various system messages

Functions

func IsValid

func IsValid(msg string) (bool, string)

Types

type Ambient

type Ambient struct {
	Num    int            `json:"num"`
	Lights map[string]int `json:"lights"`
}

type Cable

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

type Dimension

type Dimension string

type Home

type Home struct {
	Cable *Cable
	Plant *Plant
}

Home is a Btcino MyHome plant that can be controlled with a OpenWebNet enabled device (F452 ecc)

func NewHome

func NewHome(plant *Plant) *Home

NewHome creates a new Home connected through the given Cable

func (*Home) Ask

func (h *Home) Ask(request Message) ([]Message, error)

Ask the system

func (*Home) Do

func (h *Home) Do(command Message) error

Do some action with your home

func (*Home) Listen

func (h *Home) Listen() (<-chan string, chan<- struct{}, <-chan error)

type HomeError

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

HomeError wraps OWN errors

type Message

type Message struct {
	Who   *Who   `json:"who"`
	What  What   `json:"what"`
	Where Where  `json:"where"`
	Kind  string `json:"kind"`
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(who *Who, what What, where Where) Message

NewCommand build a new Command to send to the home plant

func NewRequest

func NewRequest(who *Who, what What, where Where) Message

NewRequest build a new Request to send to the home plant

func (Message) Frame

func (m Message) Frame() string

func (Message) IsSpecial

func (m Message) IsSpecial() bool

func (Message) IsValid

func (m Message) IsValid() bool

func (Message) MarshalJSON

func (m Message) MarshalJSON() ([]byte, error)

type Plant

type Plant struct {
	Name     string             `json:"name"`
	Num      int                `json:"num"`
	Address  string             `json:"address"`
	Ambients map[string]Ambient `json:"ambients"`
}

func NewPlant

func NewPlant(config io.Reader) (*Plant, error)

NewPlant load a plant configuration from a json file. Return a pointer to the Plant that will be used.

func (*Plant) ExportPlant

func (p *Plant) ExportPlant(f io.Writer) error

ExportPlant the current plant configuration to the given file

func (*Plant) FormatToJSON

func (p *Plant) FormatToJSON(msg Message) string

FormatToJSON returns the who, what, where of a message in a JSON formatted string

func (*Plant) ParseFrame

func (p *Plant) ParseFrame(frame string) Message

ParseFrame parse a OWN frame and returns a structured message.

func (*Plant) ParseFromJSON

func (p *Plant) ParseFromJSON(jsonMessage string) Message

func (*Plant) ServerAddress

func (p *Plant) ServerAddress() string

ServerAddress returns the server address for the loaded configuration

func (*Plant) WhereFromCode

func (p *Plant) WhereFromCode(code string) (Where, error)

Decode returns where defined by the ambient and light names in the plant config file: <ambient>[.<light>]

func (*Plant) WhereFromDesc

func (p *Plant) WhereFromDesc(text string) (Where, error)

NewWhere returns a

type PubSub

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

func NewPubSub

func NewPubSub() (*PubSub, error)

func (*PubSub) Listen

func (p *PubSub) Listen(home *Home) (<-chan Message, <-chan error)

type Value

type Value string

type What

type What struct {
	Code string
	Desc string
}

type Where

type Where struct {
	Code string
	Desc string
}
var GENERAL Where = Where{Code: "0", Desc: "GENERAL"}

GENERAL is the Where that refers to the entire plant

type Who

type Who struct {
	Code    string
	Desc    string
	Actions map[string]string
}

func NewWho

func NewWho(who string) *Who

func (*Who) WhatFromCode

func (w *Who) WhatFromCode(code string) (What, error)

func (*Who) WhatFromDesc

func (w *Who) WhatFromDesc(text string) (What, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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