goraven

package module
v0.0.0-...-719beb1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: GPL-2.0 Imports: 9 Imported by: 0

README

go-raven

A simple Go (golang) library for interfacing with the rainforest RAVEn

The Long Story

go-raven is a Go (golang) library for interacting with the RAVEn ZigBee device made by Rainforest Automation. If you own a smart meter, and you want to write custom software to analyze your usage data, this is a solution.

Documentation

Overview

A simple library for interacting with the Rainforest Automation RAVEn

Index

Constants

View Source
const (
	TIME      = "time"
	PRICE     = "price"
	DEMAND    = "demand"
	SUMMATION = "summation"
	MESSAGE   = "message"
)

Types of events

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionStatus

type ConnectionStatus struct {
	XMLName      xml.Name `xml:"ConnectionStatus"`
	DeviceMacId  string   `xml:"DeviceMacId"`
	MeterMacId   string   `xml:"MeterMacId"`
	Status       string   `xml:"Status"`
	Description  string   `xml:"Description,omitempty"`
	StatusCode   string   `xml:"StatusCode,omitempty"`
	ExtPanId     string   `xml:"ExtPanId,omitempty"`
	Channel      int      `xml:"Channel,omitempty"`
	ShortAddr    string   `xml:"ShortAddr,omitempty"`
	LinkStrength string   `xml:"LinkStrength"`
}

Notify: ConnectionStatus

type CurrentPeriodUsage

type CurrentPeriodUsage struct {
	XMLName             xml.Name `xml:"CurrentPeriodUsage"`
	DeviceMacId         string   `xml:"DeviceMacId"`
	MeterMacId          string   `xml:"MeterMacId"`
	TimeStamp           string   `xml:"TimeStamp"`
	CurrentUsage        string   `xml:"CurrentUsage"`
	Multiplier          string   `xml:"Multiplier"`
	Divisor             string   `xml:"Divisor"`
	DigitsRight         string   `xml:"DigitsRight"`
	DigitsLeft          string   `xml:"DigitsLeft"`
	SuppressLeadingZero string   `xml:"SuppressLeadingZero"`
	StartDate           string   `xml:"StartDate"`
}

Notify: CurrentPeriodUsage

type CurrentSummationDelivered

type CurrentSummationDelivered struct {
	XMLName             xml.Name `xml:"CurrentSummationDelivered"`
	DeviceMacId         string   `xml:"DeviceMacId"`
	MeterMacId          string   `xml:"MeterMacId"`
	TimeStamp           string   `xml:"TimeStamp"`
	SummationDelivered  string   `xml:"SummationDelivered"`
	SummationReceived   string   `xml:"SummationReceived"`
	Multiplier          string   `xml:"Multiplier"`
	Divisor             string   `xml:"Divisor"`
	DigitsRight         string   `xml:"DigitsRight"`
	DigitsLeft          string   `xml:"DigitsLeft"`
	SuppressLeadingZero string   `xml:"SuppressLeadingZero"`
}

Notify: CurrentSummationDelivered

func (*CurrentSummationDelivered) GetSummationDelivered

func (c *CurrentSummationDelivered) GetSummationDelivered() (float64, error)

GetSummationDelivered() is a convenience function that returns a correctly formatted floating point number for the Current Summation Delivered field

func (*CurrentSummationDelivered) GetSummationReceived

func (c *CurrentSummationDelivered) GetSummationReceived() (float64, error)

GetSummationReceived() is a convenience function that returns a correctly formatted floating point number for the Current Summation Received field

type DeviceInfo

type DeviceInfo struct {
	XMLName      xml.Name `xml:"DeviceInfo"`
	DeviceMacId  string   `xml:"DeviceMacId"`
	InstallCode  string   `xml:"InstallCode"`
	LinkKey      string   `xml:"LinkKey"`
	FWVersion    string   `xml:"FWVersion"`
	HWVersion    string   `xml:"HWVersion"`
	ImageType    string   `xml:"ImageType"`
	Manufacturer string   `xml:"Manufacturer"`
	ModelId      string   `xml:"ModelId"`
	DateCode     string   `xml:"DateCode"`
}

Notify: DeviceInfo

type InstantaneousDemand

type InstantaneousDemand struct {
	XMLName             xml.Name `xml:"InstantaneousDemand"`
	DeviceMacId         string   `xml:"DeviceMacId"`
	MeterMacId          string   `xml:"MeterMacId"`
	TimeStamp           string   `xml:"TimeStamp"`
	Demand              string   `xml:"Demand"`
	Multiplier          string   `xml:"Multiplier"`
	Divisor             string   `xml:"Divisor"`
	DigitsRight         string   `xml:"DigitsRight"`
	DigitsLeft          string   `xml:"DigitsLeft"`
	SuppressLeadingZero string   `xml:"SuppressLeadingZero"`
}

Notify: InstantaneousDemand

func (*InstantaneousDemand) GetDemand

func (i *InstantaneousDemand) GetDemand() (float64, error)

GetDemand() is a convenience function that returns a correctly formatted floating point number for the Demand field

type LastPeriodUsage

type LastPeriodUsage struct {
	XMLName             xml.Name `xml:"LastPeriodUsage"`
	DeviceMacId         string   `xml:"DeviceMacId"`
	MeterMacId          string   `xml:"MeterMacId"`
	TimeStamp           string   `xml:"TimeStamp"`
	LastUsage           string   `xml:"LastUsage"`
	Multiplier          string   `xml:"Multiplier"`
	Divisor             string   `xml:"Divisor"`
	DigitsRight         string   `xml:"DigitsRight"`
	DigitsLeft          string   `xml:"DigitsLeft"`
	SuppressLeadingZero string   `xml:"SuppressLeadingZero"`
	StartDate           string   `xml:"StartDate"`
	EndDate             string   `xml:"EndDate"`
}

Notify: LastPeriodUsage

type MessageCluster

type MessageCluster struct {
	XMLName              xml.Name `xml:"MessageCluster"`
	DeviceMacId          string   `xml:"DeviceMacId"`
	MeterMacId           string   `xml:"MeterMacId"`
	TimeStamp            string   `xml:"TimeStamp"`
	Id                   string   `xml:"Id"`
	Text                 string   `xml:"Text"`
	ConfirmationRequired string   `xml:"ConfirmationRequired"`
	Queued               string   `xml:"Queued"`
}

Notify: MessageCluster

type MeterInfo

type MeterInfo struct {
	XMLName     xml.Name `xml:"MeterInfo"`
	DeviceMacId string   `xml:"DeviceMacId"`
	MeterMacId  string   `xml:"MeterMacId"`
	NickName    string   `xml:"NickName"`
	Account     string   `xml:"Account,omitempty"`
	Auth        string   `xml:"Auth,omitempty"`
	Host        string   `xml:"Host,omitempty"`
	Enabled     string   `xml:"Enabled,omitempty"`
}

Notify: MeterInfo

type MeterList

type MeterList struct {
	XMLName     xml.Name `xml:"MeterList"`
	DeviceMacId string   `xml:"DeviceMacId"`
	MeterMacId  []string `xml:"MeterMacId,omitempty"`
}

Notify: MeterList

type NetworkInfo

type NetworkInfo struct {
	XMLName      xml.Name `xml:"NetworkInfo"`
	DeviceMacId  string   `xml:"DeviceMacId"`
	CoordMacId   string   `xml:"CoordMacId"`
	Status       string   `xml:"Status"`
	Description  string   `xml:"Description"`
	StatusCode   string   `xml:"StatusCode"`
	ExtPanId     string   `xml:"ExtPanId"`
	Channel      string   `xml:"Channel"`
	ShortAddr    string   `xml:"ShortAddr"`
	LinkStrength string   `xml:"LinkStrength"`
}

Notify: NetworkInfo

type PriceCluster

type PriceCluster struct {
	XMLName        xml.Name `xml:"PriceCluster"`
	DeviceMacId    string   `xml:"DeviceMacId"`
	MeterMacId     string   `xml:"MeterMacId"`
	TimeStamp      string   `xml:"TimeStamp"`
	Price          string   `xml:"Price"`
	Currency       string   `xml:"Currency"`
	TrailingDigits string   `xml:"TrailingDigits"`
	Tier           string   `xml:"Tier"`
	TierLabel      string   `xml:"TierLabel,omitempty"`
	RateLabel      string   `xml:"RateLabel,omitempty"`
}

Notify: PriceCluster

func (*PriceCluster) GetPrice

func (p *PriceCluster) GetPrice() (float64, error)

GetPrice() is a convenience function to get a correctly formatted floating point number of the Price contained in the PriceCluster

type Raven

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

func Connect

func Connect(dev string) (*Raven, error)

Connect opens a connection to a RAVEn, given the port name (/dev/ttyUSB0)

func (*Raven) Close

func (r *Raven) Close() error

Close closes the RAVEn's port safely

func (*Raven) CloseCurrentPeriod

func (r *Raven) CloseCurrentPeriod() error

Force the RAVEn to roll over the current period to the last period and initialize the current period.

func (*Raven) FactoryReset

func (r *Raven) FactoryReset() error

FactoryReset resets the RAVEn. This command will erase the commissioning data and force a restart. On restart, the RAVEn will begin the commissioning cycle.

func (*Raven) GetConnectionStatus

func (r *Raven) GetConnectionStatus() error

GetConnectionStatus gets the RAVEn connection information. The RAVEn will send a ConnectionStatus notification in response. The RAVEn continuously sends ConnectionStatus during the start-up sequence and during the join/re-join sequence for diagnostic purposes.

func (*Raven) GetCurrentPeriodUsage

func (r *Raven) GetCurrentPeriodUsage() error

Get the accumulated usage information from the RAVEn. The RAVEn will send a CurrentPeriodUsage notification in response. Note that this command will not cause the current period consumption total to be updated. To do this, send a GetCurrentSummationDelivered command with Refresh set to Y.

func (*Raven) GetCurrentPrice

func (r *Raven) GetCurrentPrice() error

Send the GET_CURRENT_PRICE command to get the price information. Set the refresh element to Y to force the RAVEn to get the information from the meter, not the cache. The RAVEn will send a PriceCluster notification in response.

func (*Raven) GetCurrentSummationDelivered

func (r *Raven) GetCurrentSummationDelivered(refresh bool) error

Get the summation information from the RAVEn. If refresh is true, the device gets the information from the meter instead of from its cache.

func (*Raven) GetDeviceInfo

func (r *Raven) GetDeviceInfo() error

GetDeviceInfo gets RAVEn configuration information. The RAVEn will send a DeviceInfo notification in response.

func (*Raven) GetInstantaneousDemand

func (r *Raven) GetInstantaneousDemand(refresh bool) error

Get the demand information from the RAVEn. If refresh is true, the device gets the information from the meter instead of from its cache.

func (*Raven) GetLastPeriodUsage

func (r *Raven) GetLastPeriodUsage() error

Get the previous period accumulation data from the RAVEn. The RAVEn will send a LastPeriodUsage notification in response.

func (*Raven) GetMessage

func (r *Raven) GetMessage(refresh bool) error

GetMessage gets the current message. The RAVEn will send a MessageCluster notification in response.

func (*Raven) GetMeterInfo

func (r *Raven) GetMeterInfo() error

GetMeterInfo gets the meter information. The RAVEn will send a MeterInfo notification in response.

func (*Raven) GetMeterList

func (r *Raven) GetMeterList() error

GetMeterList gets the list of meters the RAVEn is connected to. The RAVEn will send a MeterList notification in response.

func (*Raven) GetNetworkInfo

func (r *Raven) GetNetworkInfo() error

Get the status of the device on the network. The RAVEn will send a NetworkInfo notification in response.

func (*Raven) GetProfileData

func (r *Raven) GetProfileData()

Not Implemented

func (*Raven) GetSchedule

func (r *Raven) GetSchedule() error

GetSchedule gets the RAVEn scheduler information. The RAVEn will send the ScheduleInfo notification in response; or, RAVEn will send a series of ScheduleInfo notifications if the Event field is omitted.

func (*Raven) GetTime

func (r *Raven) GetTime() error

Send the GET_TIME command to get the current time. The RAVEn will send a TimeCluster notification in response

func (*Raven) Initialize

func (r *Raven) Initialize() error

Intitialize reinitializes the XML parser on the device. Use this command when first connecting to the RAVEn prior to sending any other commands. Initialization is not required, but will speed up the initial connection.

func (*Raven) Receive

func (r *Raven) Receive() (notify interface{}, err error)

Receive grabs the next "Notify" message in the stream

func (*Raven) Restart

func (r *Raven) Restart() error

Restart forces the RAVEn to go through the start-up sequence. This command is useful for capturing any diagnostic information sent during the start-up sequence.

func (*Raven) SetCurrentPrice

func (r *Raven) SetCurrentPrice()

Not Implemented

func (*Raven) SetFastPoll

func (r *Raven) SetFastPoll()

Not Implemented

func (*Raven) SetMeterInfo

func (r *Raven) SetMeterInfo() error

SetMeterInfo sets the meter information.

func (*Raven) SetSchedule

func (r *Raven) SetSchedule(event string, enabled bool) error

SetSchedule updates the RAVEn scheduler. The command options include setting the frequency of the command in seconds, and disabling the event. If the event is disabled the frequency is set to 0xFFFFFFFF

func (*Raven) SetScheduleDefault

func (r *Raven) SetScheduleDefault(event string) error

SetScheduleDefault resets the RAVEn scheduler to default settings. If the Event field is set, only that schedule item is reset to default values; otherwise all schedule items are reset to their default values.

type ScheduleInfo

type ScheduleInfo struct {
	XMLName     xml.Name `xml:"ScheduleInfo"`
	DeviceMacId string   `xml:"DeviceMacId"`
	MeterMacId  string   `xml:"MeterMacId,omitempty"`
	Event       string   `xml:"Event"`
	Frequency   string   `xml:"Frequency"`
	Enabled     string   `xml:"Enabled"`
}

Notify: ScheduleInfo

type TimeCluster

type TimeCluster struct {
	XMLName     xml.Name `xml:"TimeCluster"`
	DeviceMacId string   `xml:"DeviceMacId"`
	MeterMacId  string   `xml:"MeterMacId"`
	UTCTime     string   `xml:"UTCTime"`
	LocalTime   string   `xml:"LocalTime"`
}

func (*TimeCluster) GetLocalTime

func (t *TimeCluster) GetLocalTime() (time.Time, error)

GetLocalTime() is a convenience function to get the Local time contained in a TimeCluster notify

func (*TimeCluster) GetUTCTime

func (t *TimeCluster) GetUTCTime() (time.Time, error)

GetUTCTime() is a convenience function to get the UTC time contained in a TimeCluster notify

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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