Documentation
¶
Overview ¶
Package samil provides an API for quering networked Samil Power inverters. Supported inverters are those that work with SolarPower Browser V3 software. These are: SolarRiver TD, SolarRiver TL-D and SolarLake TL inverters. It is only tested and confirmed for SolarRiver 4500TL-D.
Index ¶
Constants ¶
const ( Wait = 0 Normal = 1 Fault = 2 PermanentFault = 3 Check = 4 PVPowerOff = 5 )
Possible operating modes returned by the inverter.
const ( SinglePhaseInverter = 1 ThreePhaseInverter = 2 SolarEnviMonitor = 3 RPhaseInverter = 4 SPhaseInverter = 5 TPhaseInverter = 6 )
Device type values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct {
// Internal temperature in decicelcius (375 = 37.5 degrees Celsius)
InternalTemperature int
// PV1 voltage in decivolts (2975 = 297.5 V)
PV1Voltage int
// PV2 voltage in decivolts
PV2Voltage int
// PV1 current in deciampere
PV1Current int
// PV2 current in deciampere
PV2Current int
// Total operation time in hours
OperationTime int
// Operating mode, see constants for possible values
OperatingMode int
// Energy produced today in decawatt hour (474 = 4.74 kWh)
EnergyToday int
// PV1 input power in watt
PV1Power int
// PV2 input power in watt
PV2Power int
// Single phase grid current in deciampere
GridCurrent int
// Grid voltage in decivolts
GridVoltage int
// Grid frequency in centihertz (4998 = 49.98 Hz)
GridFrequency int
// Output power in watt
OutputPower int
// Total energy produced in hectowatt hour (114649 = 11464.9 kWh)
EnergyTotal int
}
Data stores generation and operational data from the inverter.
type HistoryDay ¶
type HistoryDay struct {
// Year number in 2 digits (e.g. 99 for 2099)
Year int
// Month number
Month int
// Day numer
Day int
// Value is a csv-encoded string of generation per hour values.
// Please check the format yourself as it could be different.
Value string
}
HistoryDay stores the history data for a single day.
type Model ¶
type Model struct {
// Device type, see constants for possible values
DeviceType int
// Volt-ampere rating, e.g. "4500"
VARating string
// Firmware version, e.g. "V1.30"
FirmwareVersion string
// Model name, e.g. "River 4500TL-D"
ModelName string
// Manufacturer, e.g. "SamilPower"
Manufacturer string
// Serial number, e.g. "DW413B8080"
SerialNumber string
// Communication version, e.g. "V1.30"
CommunicationVersion string
// Other version, I don't know what it means, for me it is "V1.30"
OtherVersion string
// General, I don't know what it means (maybe a version code), for me it is
// 2. When your inverter returns something different than 2, there is a
// chance that generation data is not correctly interpreted, notably the PV2
// voltage and current.
General int
}
Model stores model and version information.
type Samil ¶
type Samil struct {
// contains filtered or unexported fields
}
Samil maintains a connection to an inverter.
Connections are usually closed by the inverter after 20 seconds of inactivity. When a connection is closed, subsequent API calls will return the error EOF.
func NewConnection ¶
NewConnection searches for an inverter in the network and returns the connection if one is found.
Inverters that are already connected to a client will not initiate a new connection. Therefore calling this function multiple times while leaving the connections open will connect to different inverters.
The search will return with an i/o timeout error when no inverter is found after a minute.
func NewConnectionWithInterface ¶
NewConnectionWithInterface behaves almost the same as the NewConnection function. The difference is that this function lets you specify the interface IP address that is used to listen on.
This can be helpful if the program by default binds to the wrong IP address. In that case, no inverter can be found. It can then help to set the interface IP address to your local network IPv4 address (e.g. 192.168.1.15).
func (*Samil) Data ¶
Data requests current data values from the inverter and returns them in the Data struct.
func (*Samil) History ¶
func (s *Samil) History(start, end int, c chan HistoryDay) error
History requests and returns history data in the time period provided. The time period is provided as two integers for the last digits of the start and end year. E.g. start=7 and end=10 are for 2007 and 2010.
The history data is asynchronously returned via the channel parameter. This channel must be provided by the caller. The method will block while the data is being returned on the channel, and will only unblock after all data is received or an error occurred. In the case of an error, the error is returned, else the return value is nil. The provided channel will be closed after the data is received or an error occurred. The caller should ensure that the channel is not full for too long periods, otherwise incoming messages may get discarded.
func (*Samil) LocalAddr ¶
LocalAddr returns the local network address. The Addr returned is shared by all invocations of LocalAddr, so do not modify it.
func (*Samil) Model ¶
Model requests and returns model and version information.
Source Files
¶
- connect.go
- data.go
- history.go
- model.go
- packet.go
- read.go
- samil.go