linkymeter

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package linkymeter implements utility routines for receiving and computing Linky meter data needed by the energy management system.

The reception of Linky meter data is done through a TIC2WebSocket client. This client receives data periodically (from 1 to 3 seconds) and a routine used by the energy management system computes data to be stored in the data model. Those data are then used by the energy management system to decide the electrical vehicle charge power to be sent to the wallbox.

See MeterData for the data provided by the Linky meter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmptyIdentifier

func IsEmptyIdentifier(identifier TicIdentifier) bool

IsEmptyIdentifier returns true if the TIC identifier is empty, false otherwise

func IsEqual

func IsEqual(meter MeterData, other MeterData) bool

IsEqual checks if two MeterData instances are equal

Types

type MeterData

type MeterData struct {
	// The Linky meter serial number
	SerialNumber string `json:"SerialNumber"`
	// The Linky meter date time in format "yy/MM/dd HH:mm:ss"
	DateTime string `json:"DateTime,omitempty"`
	// Whether the Linky meter breaker is opened (true) or closed (false)
	BreakerOpened bool `json:"BreakerOpened"`
	// The Linky meter phase count (1 or 3)
	PhaseCount int `json:"PhaseCount"`
	// The Linky meter overload power limit in VA
	OverLoadPowerLimit int `json:"OverLoadPowerLimit"`
	// The Linky meter overload current limit per phase in A
	OverLoadCurrentLimitPerPhase []float64 `json:"OverLoadCurrentLimitPerPhase"`
	// The Linky meter RMS voltage per phase in V
	RmsVoltagePerPhase []int `json:"RmsVoltagePerPhase"`
	// The Linky meter RMS current per phase in A
	RmsCurrentPerPhase []float64 `json:"RmsCurrentPerPhase"`
	// The Linky meter total apparent import power in VA
	ApparentImportPower int `json:"ApparentImportPower"`
	// The Linky meter apparent import power per phase in VA
	ApparentImportPowerPerPhase []int `json:"ApparentImportPowerPerPhase,omitempty"`
	// The Linky meter available current per phase in A
	AvailableCurrentPerPhase []float64 `json:"AvailableCurrentPerPhase"`
}

MeterData represents the Linky meter data

func ComputeMeterData

func ComputeMeterData(ticContent map[string]string) MeterData

ComputeMeterData computes the Linky meter data from the TIC content

It works for STANDARD and HISTORIC TIC formats (see https://www.enedis.fr/media/2027/download). It returns an empty MeterData if the TIC content is nil

type ModemInfo

type ModemInfo struct {
	// TIC serial port name
	PortName string `json:"portName"`
	// TIC modem type (e.g. "MICHAUD", "TELEINFO" for USB modems)
	ModemType string `json:"modemType,omitempty"`
	// TIC modem USB product ID
	ProductId int `json:"productId,omitempty"`
	// TIC modem USB vendor ID
	VendorId int `json:"vendorId,omitempty"`
	// TIC modem USB product name
	ProductName string `json:"productName,omitempty"`
	// TIC modem USB manufacturer name
	ManufacturerName string `json:"manufacturerName,omitempty"`
	// TIC modem USB serial number
	SerialNumber string `json:"serialNumber,omitempty"`
	// TIC modem USB port ID
	PortId string `json:"portId,omitempty"`
}

ModemInfo represents the TIC modem information

type OnTicAbnormalClosure

type OnTicAbnormalClosure func()

Callback function used to notify an abnormal closure of the TIC2WebSocket client

type OnTicData

type OnTicData func(ticData TicData)

Callback function used to notify new data received from the TIC2WebSocket client

type OnTicError

type OnTicError func(ticError TicError)

Callback function used to notify an error received from the TIC2WebSocket client

type Tic2WebsocketClient

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

Tic2WebsocketClient handle the connection to the TIC2WebSocket server

func NewTic2WebsocketClient

func NewTic2WebsocketClient() *Tic2WebsocketClient

NewTic2WebsocketClient creates a new TIC2WebSocket client

func (*Tic2WebsocketClient) CheckSubscriber

func (t *Tic2WebsocketClient) CheckSubscriber(subscriptionId string, ticIdentifier TicIdentifier) bool

CheckSubscriber checks if the given subscription ID is subscribed to the given TIC identifier

func (*Tic2WebsocketClient) Close

func (t *Tic2WebsocketClient) Close() error

Close closes the connection to the TIC2WebSocket server

func (*Tic2WebsocketClient) Connect

func (t *Tic2WebsocketClient) Connect(host string) error

Connect connects to the TIC2WebSocket server at the given host

func (*Tic2WebsocketClient) GetAvailableTics

func (t *Tic2WebsocketClient) GetAvailableTics() ([]TicIdentifier, error)

GetAvailableTics returns the list of available TICs stream from the TIC2WebSocket server

func (*Tic2WebsocketClient) GetModemsInfo

func (t *Tic2WebsocketClient) GetModemsInfo() ([]ModemInfo, error)

GetModemsInfo returns the list of TIC modems information from the TIC2WebSocket server

func (*Tic2WebsocketClient) GetSubscribers

func (t *Tic2WebsocketClient) GetSubscribers(ticIdentifier TicIdentifier) map[string]TicIdentifier

GetSubscribers returns the map of subscription IDs and their TIC identifiers for the given TIC identifier

func (*Tic2WebsocketClient) IsConnected

func (t *Tic2WebsocketClient) IsConnected() bool

IsConnected returns true if the connection with the TIC2WebSocket server is established, false otherwise

func (*Tic2WebsocketClient) ReadTic

func (t *Tic2WebsocketClient) ReadTic(identifier TicIdentifier) (TicData, error)

ReadTic reads the TIC data identified by the given TIC identifier from the TIC2WebSocket server

func (*Tic2WebsocketClient) SubscribeTic

func (t *Tic2WebsocketClient) SubscribeTic(onData OnTicData, onError OnTicError, onAbnormalClosure OnTicAbnormalClosure, ticIdentifier TicIdentifier) (string, error)

SubscribeTic subscribes to the TIC data identified by the given TIC identifier from the TIC2WebSocket server and returns a subscription ID

func (*Tic2WebsocketClient) UnsubscribeTic

func (t *Tic2WebsocketClient) UnsubscribeTic(subscriptionId string) error

UnsubscribeTic unsubscribes from the TIC data updates using the subscription ID

type TicData

type TicData struct {
	// TIC format (e.g. "STANDARD", "HISTORIC")
	Mode string `json:"mode"`
	// TIC capture date time (format "2006-01-02T15:04:05.000Z07:00")
	CaptureDateTime string `json:"captureDateTime"`
	// TIC identifier associated to the data
	Identifier TicIdentifier `json:"identifier"`
	// TIC raw content (map of TIC data name and value)
	Content map[string]string `json:"content"`
}

TicData represents the TIC data read or received from the TIC2WebSocket server

type TicError

type TicError struct {
	// Error code (0 if no error)
	ErrorCode int `json:"errorCode"`
	// Error message (empty if no error)
	ErrorMessage string `json:"errorMessage"`
	// TIC identifier associated to the error
	Identifier TicIdentifier `json:"identifier"`
}

TicError represents an error received from the TIC2WebSocket server

type TicIdentifier

type TicIdentifier struct {
	// TIC serial number (if empty, the first available TIC is used)
	SerialNumber string `json:"serialNumber,omitempty"`
	// TIC port name (if empty, the first available TIC is used)
	PortName string `json:"portName,omitempty"`
	// TIC port ID (if empty, the first available TIC is used)
	PortId string `json:"portId,omitempty"`
}

TicIdentifier identifies a TIC to be read or subscribed

Jump to

Keyboard shortcuts

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