Documentation ¶
Index ¶
Constants ¶
View Source
const ( CommandPoll = "000" CommandStatusReport = "001" CommandLogin = "005" CommandSetTimeAndDate = "010" CommandPartitionArmControlAway = "030" CommandPartitionArmControlStay = "031" CommandPartitionArmControlZeroEntry = "032" CommandPartitionDisarmControl = "040" CommandCode = "200" CommandAck = "500" CommandCommandError = "501" CommandSystemError = "502" CommandLoginStatus = "505" CommandKeypadLed = "510" CommandZoneAlarm = "601" CommandZoneTamper = "603" CommandZoneFault = "605" CommandZoneOpen = "609" CommandZoneRestored = "610" CommandPartitionReady = "650" CommandPartitionNotReady = "651" CommandPartitionArmed = "652" CommandPartitionDisarmed = "655" CommandPartitionAlarm = "654" CommandPartitionExitDelay = "656" CommandPartitionEntryDelay = "657" CommandPartitionBusy = "673" CommandPartitionSpecialClosing = "701" CommandTroubleOn = "840" CommandTroubleOff = "841" CommandCodeRequired = "900" )
View Source
const ( ArmAway = iota + 1 ArmStay ArmNoEntryDelay )
View Source
const ( ZoneStatusAlarm = iota + 1 ZoneStatusTamper ZoneStatusFault ZoneStatusOpen ZoneStatusRestored )
View Source
const ( PartitionStatusReady = iota + 1 PartitionStatusNotReady PartitionStatusArmedAway PartitionStatusArmedStay PartitionStatusArmedZeroEntryAway PartitionStatusArmedZeroEntryStay PartitionStatusAlarm PartitionStatusDisarmed PartitionStatusExitDelay PartitionStatusEntryDelay PartitionStatusFailedToArm PartitionStatusBusy )
View Source
const UnknownStatus = 0
Variables ¶
View Source
var ErrAPICommandInvalidLength = errors.New("invalid length")
View Source
var ErrAPICommandNotSupported = errors.New("command not supported")
View Source
var ErrAPICommandPartitionError = errors.New("requested partition is out of bounds")
View Source
var ErrAPICommandSyntaxError = errors.New("syntax error")
View Source
var ErrAPIInvalidCharacters = errors.New("invalid characters")
View Source
var ErrAPISystemNotArmed = errors.New("system not armed")
View Source
var ErrAPISystemNotReadytoArm = errors.New("system not ready, either not secure, in exit-delay, or already armed")
View Source
var ErrAPIUserCodenotRequired = errors.New("user code not required")
View Source
var ErrCommandError = errors.New("command error, bad checksum")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Connect(string, string, string) error Disconnect() Send(Command) error Status() error HandleZoneState(func(int, ZoneStatus)) HandlePartitionState(func(int, PartitionStatus)) HandleKeypadState(func(KeypadStatus)) }
type Command ¶
func NewCommandFromBytes ¶
type KeypadStatus ¶
type Panel ¶
type Panel interface { // Connect opens the connection to the Envisalink panel, logs in using // the supplied password, and upon a successful connection will set the // correct date/time of the alarm system. Connect(host string, pwd string, code string) error // Disconnect closes the connection to the Envisalink panel. Disconnect() // Arm attempts to arm a partition according to the supplied mode // (e.g., Stay, Away). Arm(partition int, mode ArmMode) error // Disarm attempts to disarm a partition. Disarm(partition int) error // SetTime sets the time for the alarm panel. SetTime(time.Time) error // OnPartitionEvent sets a calledback for whenever a partition event // occurs. OnPartitionEvent(func(int, PartitionStatus)) // OnZoneEvent sets a calledback for whenever a zone event occurs. OnZoneEvent(func(int, ZoneStatus)) // OnKeypadEvent sets a callback for whenever a keypad event occurs. OnKeypadEvent(func(KeypadStatus)) // Status returns the current partition, zone, and keypad status. Status() *PanelStatus // Poll queries the Envisalink module to send its latest update. Poll() error }
Panel is the primary interface for connecting to an alarm panel with the Envisalink TPI module.
Usage:
import "github.com/lazyeights/etpi" etpiAddr := "192.168.1.24:4025" pwd := "user" code := "12345" panel := etpi.NewPanel() panel.OnZoneEvent(handleZone) panel.OnPartitionEvent(handlePartition) panel.OnKeypadEvent(handleKeypad) if err := panel.Connect(etpiAddr, pwd, code); err != nil { panic("could not connect to Envisalink") } defer panel.Disconnect() status := panel.Status() fmt.Printf("%+v\n", status)
type PanelStatus ¶
type PanelStatus struct { Zone []ZoneStatus Partition []PartitionStatus Keypad KeypadStatus }
type PartitionStatus ¶
type PartitionStatus int
func (PartitionStatus) String ¶
func (p PartitionStatus) String() string
type ZoneStatus ¶
type ZoneStatus int
func (ZoneStatus) String ¶
func (z ZoneStatus) String() string
Click to show internal directories.
Click to hide internal directories.