sml

package module
v0.0.0-...-e7f52fa Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MPL-2.0 Imports: 12 Imported by: 1

README

3e8.eu/go/sml

This is a Go library for the Smart Message Language (SML) protocol, which is used by electricity meters in Germany. An optical interface on the meter repeatedly transmits SML messages containing current meter readings.

The main purpose of this library is to extract the meter readings from these messages.

If you consider using this library for another purpose, keep in mind that it only supports reading, and that many SML types are not implemented. However, it should still be able to parse any well-formed SML data. For unimplemented types, only the raw TLV (tag-length-value) items are reported.

For reference, a small example application is included. It supports reading SML data from a file or from a Tibber Pulse Bridge.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeMessages

func DecodeMessages(values []tlv.Value) ([]types.SML_Message, error)

DecodeMessages decodes TLV values to actual SML message types. It returns a list of messages, or an error.

func ExtractMeterData

func ExtractMeterData(messages []types.SML_Message) (meter.Data, error)

ExtractMeterData extracts meter readings from SML messages. If no readings are found, for example because there is no SML_GetList.Res message, it returns empty data. An error is only returned for severe inconsistencies in the message content, such as unexpected value types or units.

func ParseValues

func ParseValues(data []byte) ([]tlv.Value, error)

ParseValues parses the content of an SML file into its raw TLV values. It returns a list of TLV values (which should each correspond to an SML message) or an error.

func ReadFile

func ReadFile(reader io.Reader) ([]byte, error)

ReadFile finds an SML file from the given io.Reader, and returns its content, without escape sequences. It only returns when it has found a complete message, or on error (including EOF). Leading data, such as a partial message, or non-SML data, is silently ignored.

Types

This section is empty.

Directories

Path Synopsis