Documentation
¶
Overview ¶
Package owl reads a slice of bytes as broadcast by the Owl Intuition electricity monitor and decodes them into an ElecReading containing three channels of Power and Energy measurements. It also reports battery level, signal strength and timestamp. Although the Owl Intuition broadcasts weather readings these are ignored as they are of limited use. Errors are returned if the byte slice is not decoded successfully.
Further information on the Owl Intuition multicast and UDP messages formats can be found on the OWL Intuition support pages.
https://theowl.zendesk.com/hc/en-gb/articles/201284603-Multicast-UDP-API-Information
Index ¶
Examples ¶
Constants ¶
const ( // MulticastAddress is the default address for the Owl Intuition. MulticastAddress string = "224.192.32.19:22600" )
Variables ¶
var ( // ErrWeatherPacket indicates we have received a weather packet. ErrWeatherPacket = errors.New("weather packets are not decoded") // ErrInvalidPacket indicates we were unable to decode a valid packet. ErrInvalidPacket = errors.New("unable to decode packet") )
Functions ¶
This section is empty.
Types ¶
type ElecChan ¶
ElecChan represents a single channel electricity reading containing both instantaneous Power and Energy used throughout the day.
type ElecReading ¶
type ElecReading struct { ID string Timestamp time.Time RSSI float64 LQI float64 Battery float64 Chan [3]ElecChan }
ElecReading represents a single electricity reading from the Owl Intuition.
func Read ¶
func Read(b []byte) (ElecReading, error)
Read takes a byte slice and returns an ElecReading containing three channels of data. It returns an empty reading and an error if decoding the byte slice was unsuccessful.
Example ¶
var elec = []byte(`<electricity id='443719005443'> <timestamp>1509950911</timestamp> <signal rssi='-68' lqi='48'/> <battery level='100%'/> <chan id='0'> <curr units='w'>305.00</curr> <day units='wh'>1863.39</day> </chan> <chan id='1'/> <chan id='2'/> </electricity>`) r, err := owl.Read(elec) if err != nil { fmt.Println(err) return } fmt.Printf("%s power=%.2f energy=%.2f battery=%.2f\n", r.Timestamp.UTC(), r.Chan[0].Power, r.Chan[0].Energy, r.Battery)
Output: 2017-11-06 06:48:31 +0000 UTC power=305.00 energy=1863.39 battery=100.00