dsmr4p1

package module
v0.0.0-...-9cdd68c Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2017 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

dsmr4p1

A basic Go library for reading (and parsing) data from the P1 port of dutch smart meters. Do note that this library has only been tested with a limited number of smartmeters (i.e., one), so it might not work with yours.

GoDoc

Documentation

Overview

Package dsmr4p1 is a library for reading (and parsing) data from the P1 port of dutch smart meters.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorParseTimestamp indicates that there was an error parsing a timestamp.
	ErrorParseTimestamp = errors.New("parsing timestamp: missing DST indicator")
	// ErrorParseValueWithUnit indicates that there was an error parsing a value string
	// (i.e., a string containing both a value and a unit)
	ErrorParseValueWithUnit = errors.New("parsing string that should contain both a value and a unit")
)

Functions

func Poll

func Poll(input io.Reader) chan Telegram

Poll starts polling the P1 port represented by input (an io.Reader). It will start a goroutine and received telegrams are put into returned channel. Only telegrams whose CRC value are correct are put into the channel.

func RateLimit

func RateLimit(input io.Reader, delay time.Duration) io.Reader

RateLimit takes a io.Reader (typically the output of a os.Open) and delay the output of each Telegram (delimited by a '/') at a certain rate (delay). The main purpose is for testing/simulation. Simply save the output of an actual smartmeter to a file. Then in your test program open the file and use the resulting io.Reader with this function. The resulting io.Reader will mimick a real smart-meter that outputs a telegram every n seconds (typically 10).

Types

type GasMeterValue

type GasMeterValue struct {
	Timestamp Timestamp
	Value     float64
	Unit      string
}

func (*GasMeterValue) UnmarshalJSON

func (v *GasMeterValue) UnmarshalJSON(b []byte) error

type Table

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

Table is a 256-word table representing the polynomial for efficient processing.

type Telegram

type Telegram struct {
	Identifier string

	// Data stored in database for every reading.
	Timestamp                     Timestamp `json:"0-0:1.0.0,omitempty"`
	ElectricityEquipmentID        string    `json:"0-0:96.1.1,omitempty"`
	ElectricityDelivered1         Value     `json:"1-0:1.8.1,omitempty"`
	ElectricityReturned1          Value     `json:"1-0:2.8.1,omitempty"`
	ElectricityDelivered2         Value     `json:"1-0:1.8.2,omitempty"`
	ElectricityReturned2          Value     `json:"1-0:2.8.2,omitempty"`
	ElectricityCurrentlyDelivered Value     `json:"1-0:1.7.0,omitempty"`
	ElectricityCurrentlyReturned  Value     `json:"1-0:2.7.0,omitempty"`

	PhaseCurrentlyDeliveredL1 Value `json:"1-0:21.7.0,omitempty"`
	PhaseCurrentlyDeliveredL2 Value `json:"1-0:41.7.0,omitempty"`
	PhaseCurrentlyDeliveredL3 Value `json:"1-0:61.7.0,omitempty"`

	// Static data, stored in database but only record of the last reading is preserved.
	DsmrVersion                Value `json:"1-3:0.2.8,omitempty"`
	ElectricityTariff          Value `json:"0-0:96.14.0,omitempty"`
	PowerFailureCount          Value `json:"0-0:96.7.21,omitempty"`
	LongPowerFailureCount      Value `json:"0-0:96.7.9,omitempty"`
	InstantaneousCurrentL1     Value `json:"1-0:31.7.0,omitempty"`
	InstantaneousCurrentL2     Value `json:"1-0:51.7.0,omitempty"`
	InstantaneousCurrentL3     Value `json:"1-0:71.7.0,omitempty"`
	InstantaneousActivePowerL1 Value `json:"1-0:22.7.0,omitempty"`
	InstantaneousActivePowerL2 Value `json:"1-0:42.7.0,omitempty"`
	InstantaneousActivePowerL3 Value `json:"1-0:62.7.0,omitempty"`
	VoltageSagCountL1          Value `json:"1-0:32.32.0,omitempty"`
	VoltageSagCountL2          Value `json:"1-0:52.32.0,omitempty"`
	VoltageSagCountL3          Value `json:"1-0:72.32.0,omitempty"`
	VoltageSwellCountL1        Value `json:"1-0:32.36.0,omitempty"`
	VoltageSwellCountL2        Value `json:"1-0:52.36.0,omitempty"`
	VoltageSwellCountL3        Value `json:"1-0:72.36.0,omitempty"`

	// Gas meter information
	GasEquipmentID string        `json:"0-1:96.1.0,omitempty"`
	GasTimeValue   GasMeterValue `json:"0-1:24.2.1,omitempty"`
}

Telegram holds the a P1 telegram. It is essentially a slice of bytes.

type Timestamp

type Timestamp time.Time

Timestamp is the timestamp format used in the dutch smartmeters. Do note this function assumes the CET/CEST timezone.

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

type Value

type Value struct {
	Val  float64
	Unit string
}

Value holds a P1 value

func (*Value) UnmarshalJSON

func (v *Value) UnmarshalJSON(b []byte) error

Directories

Path Synopsis
Simple example program that illustrates how to use the dsmr4p1 library.
Simple example program that illustrates how to use the dsmr4p1 library.

Jump to

Keyboard shortcuts

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