Package dsmr4p1 is a library for reading (and parsing) data from the P1 port of dutch smart meters.
- func ParseTimestamp(timestamp string) (time.Time, error)
- func ParseValueWithUnit(input string) (value float64, unit string, err error)
- func Poll(input io.Reader) chan Telegram
- func RateLimit(input io.Reader, delay time.Duration) io.Reader
- type Telegram
var ( // ErrorParseTimestamp indicates that there was an error parsing a timestamp. ErrorParseTimestamp = errors.New("error 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("error parsing string that should contain both a value and a unit") )
func ParseTimestamp ¶
ParseTimestamp parses the timestamp format used in the dutch smartmeters. Do note this function assumes the CET/CEST timezone.
func ParseValueWithUnit ¶
ParseValueWithUnit parses the provided string into a float and a unit. If the unit starts with "k" the value is multiplied by 1000 and the "k" is removed from the unit.
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.
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).
type Telegram byte
Telegram holds the a P1 telegram. It is essentially a slice of bytes.
func (Telegram) Identifier ¶
Identifier returns the identifier in the telegram.