model

package
v0.0.0-...-cff5da0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Type     string
	Elements map[uint16]*Element
}

Device holds the name addr and type of device

func MakeDevice

func MakeDevice(deviceType string, addr uint16) Device

MakeDevice makes a new device with the given addr

func (*Device) AddElem

func (d *Device) AddElem(name, stateType string, devAddr uint16) uint16

AddElem adds a element to the device

func (*Device) GetState

func (d *Device) GetState(addr uint16) ([]byte, error)

GetState returns the state of a element

func (*Device) UpdateState

func (d *Device) UpdateState(addr uint16, state []byte) error

UpdateState updates the state of the element with the given address

type Element

type Element struct {
	Name      string
	State     []byte
	StateType string
}

Element holds an elements name, addr and its state

type Group

type Group struct {
	Name     string
	KeyIndex uint16
	Devices  map[uint16]*Device
	Scenes   map[uint16]*Scene
}

Group holds a collection of devices and its app key

func MakeGroup

func MakeGroup(name string, addr, keyIndex uint16) Group

MakeGroup makes a new group with the given addr

func (*Group) AddDevice

func (g *Group) AddDevice(addr uint16, device Device)

AddDevice adds a device to the group

func (*Group) AddScene

func (g *Group) AddScene(name string, number uint16)

AddScene adds a scene to a the group

func (*Group) GetDevice

func (g *Group) GetDevice(addr uint16) (*Device, error)

GetDevice gets the ref to device with given addr

func (*Group) GetScene

func (g *Group) GetScene(number uint16) (*Scene, error)

GetScene gets the ref to scene with given number

func (*Group) RemoveDevice

func (g *Group) RemoveDevice(addr uint16)

RemoveDevice removes the device from the group

func (*Group) RemoveScene

func (g *Group) RemoveScene(number uint16)

RemoveScene removes a scene from the group

type Scene

type Scene struct {
	Name string
}

Scene holds the scenes name and number

type Store

type Store struct {
	Groups          map[uint16]*Group
	NextGroupAddr   uint16
	NextSceneNumber uint16
	WebKeys         [][]byte
	Configured      bool
}

Store is a capture of all data in use by the home hub

func MakeStore

func MakeStore() Store

MakeStore makes a new store with the given webKey

func (*Store) AddGroup

func (s *Store) AddGroup(addr uint16, group Group)

AddGroup adds a group to the store

func (*Store) AddWebKey

func (s *Store) AddWebKey(webKey []byte)

AddWebKey checks the validity of the given webKey

func (*Store) CheckWebKey

func (s *Store) CheckWebKey(webKey []byte) bool

CheckWebKey checks the validity of the given webKey

func (*Store) GetConfigured

func (s *Store) GetConfigured() bool

GetConfigured returns a bool indicating if the network is configured

func (*Store) GetGroup

func (s *Store) GetGroup(groupAddr uint16) (*Group, error)

GetGroup gets the ref to group with given addr

func (*Store) GetNextGroupAddr

func (s *Store) GetNextGroupAddr() uint16

GetNextGroupAddr returns the next group address

func (*Store) GetNextSceneNumber

func (s *Store) GetNextSceneNumber() uint16

GetNextSceneNumber returns the next scene number

func (*Store) IncrementNextGroupAddr

func (s *Store) IncrementNextGroupAddr()

IncrementNextGroupAddr increments the next group address

func (*Store) IncrementNextSceneNumber

func (s *Store) IncrementNextSceneNumber()

IncrementNextSceneNumber increments the next app key index

func (*Store) MarkConfigured

func (s *Store) MarkConfigured()

MarkConfigured marks the network as configured

func (*Store) RemoveGroup

func (s *Store) RemoveGroup(addr uint16)

RemoveGroup removes the group from the store

Jump to

Keyboard shortcuts

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