Documentation
¶
Overview ¶
Package data is used for manipulating energy management system data model.
The data model can be synchronized with multiple data writers:
CSV file
InfluxDB database
Index ¶
- Constants
- type CsvWriter
- type DataModel
- type DataSynchronizer
- func (s *DataSynchronizer) DisableOverloadProtectionActive()
- func (e *DataSynchronizer) GetDiagnosis() (diagnosis DiagnosisData)
- func (s *DataSynchronizer) GetDiagnosisState() *model.DeviceDiagnosisStateDataType
- func (s *DataSynchronizer) GetMeter() (meter linkymeter.MeterData)
- func (s *DataSynchronizer) GetMeterMinAvailableCurrent() (minAvailableCurrent float64)
- func (s *DataSynchronizer) GetModel() (model DataModel)
- func (s *DataSynchronizer) GetOverloadProtection() (overloadProtection OverloadProtectionData)
- func (s *DataSynchronizer) GetOverloadProtectionLockDuration() (lockDuration time.Duration)
- func (s *DataSynchronizer) GetOverloadProtectionValue() (limitValue float64)
- func (s *DataSynchronizer) GetVehicle() (vehicle map[string]interface{})
- func (s *DataSynchronizer) GetWallbox() (wallbox map[string]interface{})
- func (s *DataSynchronizer) HasMeterData() (hasMeterData bool)
- func (s *DataSynchronizer) IsConnected() (isConnected bool)
- func (s *DataSynchronizer) IsOpevSupported() (isOpevSupported bool)
- func (s *DataSynchronizer) Print()
- func (s *DataSynchronizer) SetDiagnosis(operatingState model.DeviceDiagnosisOperatingStateType, ...) (hasChanged bool)
- func (s *DataSynchronizer) SetHasMeterData(hasMeterData bool) (hasChanged bool)
- func (s *DataSynchronizer) SetIsConnected(isConnected bool) (hasChanged bool)
- func (s *DataSynchronizer) SetIsOpevSupported(isOpevSupported bool) (hasChanged bool)
- func (s *DataSynchronizer) SetMeter(meter linkymeter.MeterData) (hasChanged bool)
- func (s *DataSynchronizer) SetOverloadProtectionLockActive(lockActive bool) (hasChanged bool)
- func (s *DataSynchronizer) SetOverloadProtectionLockStart(lockStart time.Time) (hasChanged bool)
- func (s *DataSynchronizer) SetOverloadProtectionResult(result model.ResultDataType) (hasChanged bool)
- func (s *DataSynchronizer) SetOverloadProtectionValue(limitValue float64)
- func (s *DataSynchronizer) SetVehicle(vehicle map[string]interface{}) (hasChanged bool)
- func (s *DataSynchronizer) SetWallbox(wallbox map[string]interface{}) (hasChanged bool)
- type DataWriter
- type DiagnosisData
- type InfluxDbWriter
- type OverloadProtectionData
Constants ¶
const (
// Diagnosis last error code when there is no error
DIAGNOSIS_NO_ERROR = "No error"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CsvWriter ¶
type CsvWriter struct {
// contains filtered or unexported fields
}
CsvWriter is a writer that saves the data model to a CSV file with rotation
func NewCsvWriter ¶
NewCsvWriter creates a new CsvWriter with the given configuration
type DataModel ¶
type DataModel struct {
IsConnected bool `json:"IsConnected"` // Whether the energy management system is connected (EEBUS) to the wallbox
HasMeterData bool `json:"HasMeterData"` // Whether the energy management system is receiving linky meter data
IsOpevSupported bool `json:"IsOpevSupported"` // Whether the wallbox supports the EEBUS OPEV use case
Vehicle map[string]interface{} `json:"Vehicle"` // The vehicle data (if available, otherwise empty)
Wallbox map[string]interface{} `json:"Wallbox"` // The wallbox data (if available, otherwise empty)
Meter linkymeter.MeterData `json:"Meter"` // The linky meter data
OverloadProtection OverloadProtectionData `json:"OverloadProtection"` // The overload protection data
Diagnosis DiagnosisData `json:"Diagnosis"` // The diagnosis data
}
type DataSynchronizer ¶
type DataSynchronizer struct {
// contains filtered or unexported fields
}
DataSynchronizer is used to synchronize the data model and save it with multiple data writers
func NewDataSynchronizer ¶
func NewDataSynchronizer(dataModelConfig config.DataModelConfig) *DataSynchronizer
NewDataSynchronizer creates an instance of DataSynchronizer from data model configuration
func (*DataSynchronizer) DisableOverloadProtectionActive ¶
func (s *DataSynchronizer) DisableOverloadProtectionActive()
DisableOverloadProtectionActive disables the overload protection active state
If the state has changed, it saves the data model with the data writers
func (*DataSynchronizer) GetDiagnosis ¶
func (e *DataSynchronizer) GetDiagnosis() (diagnosis DiagnosisData)
GetDiagnosis returns a copy of the diagnosis data
func (*DataSynchronizer) GetDiagnosisState ¶
func (s *DataSynchronizer) GetDiagnosisState() *model.DeviceDiagnosisStateDataType
GetDiagnosisState returns a pointer to the device diagnosis state data
func (*DataSynchronizer) GetMeter ¶
func (s *DataSynchronizer) GetMeter() (meter linkymeter.MeterData)
GetMeter returns a copy of the Linky meter data
func (*DataSynchronizer) GetMeterMinAvailableCurrent ¶
func (s *DataSynchronizer) GetMeterMinAvailableCurrent() (minAvailableCurrent float64)
GetMeterMinAvailableCurrent returns the minimum available current from the Linky meter data
func (*DataSynchronizer) GetModel ¶
func (s *DataSynchronizer) GetModel() (model DataModel)
GetModel returns a copy of the data model
func (*DataSynchronizer) GetOverloadProtection ¶
func (s *DataSynchronizer) GetOverloadProtection() (overloadProtection OverloadProtectionData)
GetOverloadProtection returns a copy of the overload protection data
func (*DataSynchronizer) GetOverloadProtectionLockDuration ¶
func (s *DataSynchronizer) GetOverloadProtectionLockDuration() (lockDuration time.Duration)
GetOverloadProtectionLockDuration returns the overload protection lock duration
func (*DataSynchronizer) GetOverloadProtectionValue ¶
func (s *DataSynchronizer) GetOverloadProtectionValue() (limitValue float64)
GetOverloadProtectionValue returns the overload protection value
func (*DataSynchronizer) GetVehicle ¶
func (s *DataSynchronizer) GetVehicle() (vehicle map[string]interface{})
GetVehicle returns a copy of the vehicle data map
func (*DataSynchronizer) GetWallbox ¶
func (s *DataSynchronizer) GetWallbox() (wallbox map[string]interface{})
GetWallbox returns a copy of the wallbox data map
func (*DataSynchronizer) HasMeterData ¶
func (s *DataSynchronizer) HasMeterData() (hasMeterData bool)
HasMeterData returns true if the Linky meter sends data to the EMS
func (*DataSynchronizer) IsConnected ¶
func (s *DataSynchronizer) IsConnected() (isConnected bool)
IsConnected returns true if the EMS is connected to a wallbox
func (*DataSynchronizer) IsOpevSupported ¶
func (s *DataSynchronizer) IsOpevSupported() (isOpevSupported bool)
IsOpevSupported returns true if the EEBUS OPEV use case is supported by the wallbox
func (*DataSynchronizer) Print ¶
func (s *DataSynchronizer) Print()
Print prints the data model as a formatted JSON string
func (*DataSynchronizer) SetDiagnosis ¶
func (s *DataSynchronizer) SetDiagnosis(operatingState model.DeviceDiagnosisOperatingStateType, lastErrorCode model.LastErrorCodeType) (hasChanged bool)
SetDiagnosis updates the diagnosis data with the provided data
If the data has changed, it saves the data model with the data writers and returns true
func (*DataSynchronizer) SetHasMeterData ¶
func (s *DataSynchronizer) SetHasMeterData(hasMeterData bool) (hasChanged bool)
SetHasMeterData sets the state if the Linky meter sends data to the EMS
If the state has changed, it saves the data model with the data writers and returns true
func (*DataSynchronizer) SetIsConnected ¶
func (s *DataSynchronizer) SetIsConnected(isConnected bool) (hasChanged bool)
SetIsConnected sets the connection state of the EMS to a wallbox
If the state has changed, it saves the data model with the data writers and returns true
func (*DataSynchronizer) SetIsOpevSupported ¶
func (s *DataSynchronizer) SetIsOpevSupported(isOpevSupported bool) (hasChanged bool)
SetIsOpevSupported sets the state if the EEBUS OPEV use case is supported by the wallbox
If the state has changed, it saves the data model with the data writers and returns true
func (*DataSynchronizer) SetMeter ¶
func (s *DataSynchronizer) SetMeter(meter linkymeter.MeterData) (hasChanged bool)
SetMeter updates the Linky meter data with the provided data
If the data has changed, it saves the data model with the data writers and returns true
func (*DataSynchronizer) SetOverloadProtectionLockActive ¶
func (s *DataSynchronizer) SetOverloadProtectionLockActive(lockActive bool) (hasChanged bool)
SetOverloadProtectionLockActive sets the overload protection lock active state
If the state has changed, it saves the data model with the data writers and returns true
func (*DataSynchronizer) SetOverloadProtectionLockStart ¶
func (s *DataSynchronizer) SetOverloadProtectionLockStart(lockStart time.Time) (hasChanged bool)
SetOverloadProtectionLockStart sets the overload protection lock start time and activates the lock
If the lock start time has changed, it saves the data model with the data writers and returns true
func (*DataSynchronizer) SetOverloadProtectionResult ¶
func (s *DataSynchronizer) SetOverloadProtectionResult(result model.ResultDataType) (hasChanged bool)
GetOverloadProtectionResult returns the overload protection result code and description
func (*DataSynchronizer) SetOverloadProtectionValue ¶
func (s *DataSynchronizer) SetOverloadProtectionValue(limitValue float64)
SetOverloadProtectionValue sets the overload protection value and activates the overload protection
It saves the data model with the data writers
func (*DataSynchronizer) SetVehicle ¶
func (s *DataSynchronizer) SetVehicle(vehicle map[string]interface{}) (hasChanged bool)
SetVehicle updates the vehicle data map with the provided data
If the data has changed, it saves the data model with the data writers and returns true
func (*DataSynchronizer) SetWallbox ¶
func (s *DataSynchronizer) SetWallbox(wallbox map[string]interface{}) (hasChanged bool)
SetWallbox updates the wallbox data map with the provided data
If the data has changed, it saves the data model with the data writers and returns true
type DiagnosisData ¶
type DiagnosisData struct {
OperatingState model.DeviceDiagnosisOperatingStateType `json:"OperatingState"` // The current operating state of the energy management system
LastErrorCode model.LastErrorCodeType `json:"LastErrorCode"` // The last error code of the energy management system
}
DiagnosisData represents the diagnosis data send to the wallbox
type InfluxDbWriter ¶
type InfluxDbWriter struct {
// contains filtered or unexported fields
}
InfluxDbWriter is the handler to write data to InfluxDB
func NewInfluxDbWriter ¶
func NewInfluxDbWriter(config *config.InfluxDbConfig) *InfluxDbWriter
NewInfluxDbWriter creates a new InfluxDbWriter with the given configuration
func (*InfluxDbWriter) Save ¶
func (h *InfluxDbWriter) Save(model DataModel)
Save saves the given data model to InfluxDB
type OverloadProtectionData ¶
type OverloadProtectionData struct {
Active bool `json:"Active"` // Whether overload protection algortihm is active
Value float64 `json:"Value"` // The electrical vehicle charge limitation value in Amps
Start time.Time `json:"Start"` // The last time when the overload protection was activated
ResultCode model.ErrorNumberType `json:"ResultCode"` // The last electrical vehicle charge limitation update result code
ResultDescription model.DescriptionType `json:"ResultDescription"` // The last electrical vehicle charge limitation update result description
LockActive bool `json:"LockActive"` // Whether the overload protection is currently locking the electrical vehicle charge limitation
LockStart time.Time `json:"LockStart"` // The last time when the overload protection lock started
}
OverloadProtectionData represents the overload protection data