owl

package module
v0.0.0-...-4dd4442 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: MIT Imports: 6 Imported by: 0

README

go-owl

A local listener for the Owl Intuition energy monitor

Go Report Card travis-ci

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.

Full documentation: godoc.org/github.com/billglover/go-owl

Examples

  • basic – logs electricity readings to the console
  • multicast – similar to basic but listens to the multicast address
  • prometheus – exposes electricty readings as metrics for Prometheus

To run the basic example:

examples/multicast ▸ go build
examples/multicast ▸ ./multicast

2017-11-07 21:50:44 +0000 GMT : electricity reading : power=434.00w
2017-11-07 21:50:56 +0000 GMT : electricity reading : power=418.00w
2017-11-07 21:51:32 +0000 GMT : electricity reading : power=402.00w

Benchmarks

goos: darwin
goarch: amd64
pkg: github.com/billglover/go-owl
BenchmarkRead-8   	   50000	     24739 ns/op
PASS
ok  	github.com/billglover/go-owl	1.496s

Note: remember, benchmarks allow for relative comparisons as actual performance is system dependence.

Contributing

Contributions are welcome. Please leave a comment on an issue if you are going to work on it.

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

View Source
const (
	// MulticastAddress is the default address for the Owl Intuition.
	MulticastAddress string = "224.192.32.19:22600"
)

Variables

View Source
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

type ElecChan struct {
	Energy      float64
	EnergyUnits string
	Power       float64
	PowerUnits  string
}

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

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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