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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Timestamp is the timestamp format used in the dutch smartmeters. Do note this function assumes the CET/CEST timezone.