rest

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package rest provides functions to query and update the SunSynk REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Battery added in v0.6.0

type Battery struct{ *SynkObject }

Battery is a model of a battery connected to an inverter.

func (*Battery) SOC added in v0.13.0

func (battery *Battery) SOC() int

SOC returns the percentage state of charge of a battery. This is a convenience method that calls

battery.Get("bmsSoc")

since "bmsSoc" is the attribute used by the SunSynk REST API.

type Grid added in v0.6.0

type Grid struct{ *SynkObject }

Grid is the SunSynk model of the electricity grid connected to an inverter. Attributes of the Grid include the frequency (e.g. 50 Hz), voltage and, most importantly, whether the grid is up.

func (*Grid) IsUp added in v0.9.0

func (grid *Grid) IsUp() bool

IsUp returns true if the electricity grid can supply power. This is a convenience method that calls

grid.Get("acRealyStatus")

to get the state of the grid (Note: "Realy" should probably be "Relay")

type Input added in v0.9.0

type Input struct{ *SynkObject }

Input is the SunSynk model of the inputs (e.g. solar panels) to an inverter. Attributes of the Grid include the number of inputs (e.g. two if there are two MPPTs) and the power being supplied by the input.

func (*Input) Power added in v0.13.0

func (input *Input) Power() int

Power returns the most recent reading of the power (in watts, W) being generated.

type Inverter added in v0.6.0

type Inverter struct {
	AbsorptionVolt               string `json:"absorptionVolt,omitempty"`
	AcCoupleFreqUpper            string `json:"acCoupleFreqUpper,omitempty"`
	AcCoupleOnGridSideEnable     string `json:"acCoupleOnGridSideEnable,omitempty"`
	AcCoupleOnLoadSideEnable     string `json:"acCoupleOnLoadSideEnable,omitempty"`
	AcCurrentUp                  string `json:"acCurrentUp,omitempty"`
	AcFreqLow                    string `json:"acFreqLow,omitempty"`
	AcFreqUp                     string `json:"acFreqUp,omitempty"`
	ActivePowerControl           string `json:"activePowerControl,omitempty"`
	AcType                       string `json:"acType,omitempty"`
	AcVoltLow                    string `json:"acVoltLow,omitempty"`
	AcVoltUp                     string `json:"acVoltUp,omitempty"`
	AllowRemoteControl           string `json:"allowRemoteControl,omitempty"`
	Ampm                         string `json:"ampm,omitempty"`
	ArcFactB                     string `json:"arcFactB,omitempty"`
	ArcFactC                     string `json:"arcFactC,omitempty"`
	ArcFactD                     string `json:"arcFactD,omitempty"`
	ArcFactFrz                   string `json:"arcFactFrz,omitempty"`
	ArcFactF                     string `json:"arcFactF,omitempty"`
	ArcFactI                     string `json:"arcFactI,omitempty"`
	ArcFactT                     string `json:"arcFactT,omitempty"`
	ArcFaultType                 string `json:"arcFaultType,omitempty"`
	AtsEnable                    string `json:"atsEnable,omitempty"`
	AtsSwitch                    string `json:"atsSwitch,omitempty"`
	AutoDim                      string `json:"autoDim,omitempty"`
	BackupDelay                  string `json:"backupDelay,omitempty"`
	BatErr                       string `json:"batErr,omitempty"`
	BatteryCap                   string `json:"batteryCap,omitempty"`
	BatteryChargeType            string `json:"batteryChargeType,omitempty"`
	BatteryEfficiency            string `json:"batteryEfficiency,omitempty"`
	BatteryEmptyVolt             string `json:"batteryEmptyVolt,omitempty"`
	BatteryEmptyV                string `json:"batteryEmptyV,omitempty"`
	BatteryImpedance             string `json:"batteryImpedance,omitempty"`
	BatteryLowCap                string `json:"batteryLowCap,omitempty"`
	BatteryLowVolt               string `json:"batteryLowVolt,omitempty"`
	BatteryMaxCurrentCharge      string `json:"batteryMaxCurrentCharge,omitempty"`
	BatteryMaxCurrentDischarge   string `json:"batteryMaxCurrentDischarge,omitempty"`
	BatteryOn                    string `json:"batteryOn,omitempty"`
	BatteryRestartCap            string `json:"batteryRestartCap,omitempty"`
	BatteryRestartVolt           string `json:"batteryRestartVolt,omitempty"`
	BatteryShutdownCap           string `json:"batteryShutdownCap,omitempty"`
	BatteryShutdownVolt          string `json:"batteryShutdownVolt,omitempty"`
	BatteryWorkStatus            string `json:"batteryWorkStatus,omitempty"`
	BattMode                     string `json:"battMode,omitempty"`
	BattType                     string `json:"battType,omitempty"`
	BatWarn                      string `json:"batWarn,omitempty"`
	Beep                         string `json:"beep,omitempty"`
	BmsErrStop                   string `json:"bmsErrStop,omitempty"`
	CaFStart                     string `json:"caFStart,omitempty"`
	CaFStop                      string `json:"caFStop,omitempty"`
	CaFwEnable                   string `json:"caFwEnable,omitempty"`
	CaliforniaFreqPressureEnable string `json:"californiaFreqPressureEnable,omitempty"`
	CaliforniaVoltPressureEnable string `json:"californiaVoltPressureEnable,omitempty"`
	CaLv3                        string `json:"caLv3,omitempty"`
	Cap1                         string `json:"cap1,omitempty"`
	Cap2                         string `json:"cap2,omitempty"`
	Cap3                         string `json:"cap3,omitempty"`
	Cap4                         string `json:"cap4,omitempty"`
	Cap5                         string `json:"cap5,omitempty"`
	Cap6                         string `json:"cap6,omitempty"`
	CaVoltPressureEnable         string `json:"caVoltPressureEnable,omitempty"`
	CaVStart                     string `json:"caVStart,omitempty"`
	CaVStop                      string `json:"caVStop,omitempty"`
	CaVwEnable                   string `json:"caVwEnable,omitempty"`
	ChargeCurrentLimit           string `json:"chargeCurrentLimit,omitempty"`
	ChargeCurrent                string `json:"chargeCurrent,omitempty"`
	ChargeLimit                  string `json:"chargeLimit,omitempty"`
	ChargeVolt                   string `json:"chargeVolt,omitempty"`
	CheckSelfTime                string `json:"checkSelfTime,omitempty"`
	CheckTime                    string `json:"checkTime,omitempty"`
	CommAddr                     string `json:"commAddr,omitempty"`
	CommBaudRate                 string `json:"commBaudRate,omitempty"`
	ComSet                       string `json:"comSet,omitempty"`
	Current10                    string `json:"current10,omitempty"`
	Current11                    string `json:"current11,omitempty"`
	Current12                    string `json:"current12,omitempty"`
	Current1                     string `json:"current1,omitempty"`
	Current2                     string `json:"current2,omitempty"`
	Current3                     string `json:"current3,omitempty"`
	Current4                     string `json:"current4,omitempty"`
	Current5                     string `json:"current5,omitempty"`
	Current6                     string `json:"current6,omitempty"`
	Current7                     string `json:"current7,omitempty"`
	Current8                     string `json:"current8,omitempty"`
	Current9                     string `json:"current9,omitempty"`
	DcVoltUp                     string `json:"dcVoltUp,omitempty"`
	DisableFloatCharge           string `json:"disableFloatCharge,omitempty"`
	DischargeCurrentLimit        string `json:"dischargeCurrentLimit,omitempty"`
	DischargeCurrent             string `json:"dischargeCurrent,omitempty"`
	DischargeLimit               string `json:"dischargeLimit,omitempty"`
	DischargeVolt                string `json:"dischargeVolt,omitempty"`
	DrmEnable                    string `json:"drmEnable,omitempty"`
	Eeprom                       string `json:"eeprom,omitempty"`
	EnergyMode                   string `json:"energyMode,omitempty"`
	EquChargeCycle               string `json:"equChargeCycle,omitempty"`
	EquChargeTime                string `json:"equChargeTime,omitempty"`
	EquipMode                    string `json:"equipMode,omitempty"`
	EquVoltCharge                string `json:"equVoltCharge,omitempty"`
	ExMeterCt                    string `json:"exMeterCt,omitempty"`
	ExMeterCtSwitch              string `json:"exMeterCtSwitch,omitempty"`
	ExternalCtRatio              string `json:"externalCtRatio,omitempty"`
	ExternalCurrent              string `json:"externalCurrent,omitempty"`
	FacHighProtect               string `json:"facHighProtect,omitempty"`
	FacLowProtect                string `json:"facLowProtect,omitempty"`
	Fac                          string `json:"fac,omitempty"`
	Flag2                        string `json:"flag2,omitempty"`
	FloatVolt                    string `json:"floatVolt,omitempty"`
	Four19                       string `json:"four19,omitempty"`
	FridayOn                     any    `json:"fridayOn,omitempty"`
	GenAndGridSignal             string `json:"genAndGridSignal,omitempty"`
	GenChargeOn                  string `json:"genChargeOn,omitempty"`
	GenConnectGrid               string `json:"genConnectGrid,omitempty"`
	GenCoolingTime               string `json:"genCoolingTime,omitempty"`
	GeneratorBatteryCurrent      string `json:"generatorBatteryCurrent,omitempty"`
	GeneratorForcedStart         string `json:"generatorForcedStart,omitempty"`
	GeneratorStartCap            string `json:"generatorStartCap,omitempty"`
	GeneratorStartVolt           string `json:"generatorStartVolt,omitempty"`
	GenMinSolar                  string `json:"genMinSolar,omitempty"`
	GenOffCap                    string `json:"genOffCap,omitempty"`
	GenOffVolt                   string `json:"genOffVolt,omitempty"`
	GenOnCap                     string `json:"genOnCap,omitempty"`
	GenOnVolt                    string `json:"genOnVolt,omitempty"`
	GenPeakPower                 string `json:"genPeakPower,omitempty"`
	GenPeakShaving               string `json:"genPeakShaving,omitempty"`
	GenSignal                    string `json:"genSignal,omitempty"`
	GenTime1on                   any    `json:"genTime1on,omitempty"`
	GenTime2on                   any    `json:"genTime2on,omitempty"`
	GenTime3on                   any    `json:"genTime3on,omitempty"`
	GenTime4on                   any    `json:"genTime4on,omitempty"`
	GenTime5on                   any    `json:"genTime5on,omitempty"`
	GenTime6on                   any    `json:"genTime6on,omitempty"`
	GenToLoadOn                  string `json:"genToLoadOn,omitempty"`
	GenToLoad                    string `json:"genToLoad,omitempty"`
	Gfdi                         string `json:"gfdi,omitempty"`
	GridAlwaysOn                 string `json:"gridAlwaysOn,omitempty"`
	GridMode                     string `json:"gridMode,omitempty"`
	GridPeakPower                string `json:"gridPeakPower,omitempty"`
	GridPeakShaving              string `json:"gridPeakShaving,omitempty"`
	GridSideINVMeter2            string `json:"gridSideINVMeter2,omitempty"`
	GridSignal                   string `json:"gridSignal,omitempty"`
	HighThrough                  string `json:"highThrough,omitempty"`
	ImpedanceLow                 string `json:"impedanceLow,omitempty"`
	ImportPower                  string `json:"importPower,omitempty"`
	InverterOutputVoltage        string `json:"inverterOutputVoltage,omitempty"`
	InverterType                 string `json:"inverterType,omitempty"`
	IsletProtect                 string `json:"isletProtect,omitempty"`
	Limit                        string `json:"limit,omitempty"`
	Limter                       string `json:"limter,omitempty"`
	LithiumMode                  string `json:"lithiumMode,omitempty"`
	LoadMode                     string `json:"loadMode,omitempty"`
	LockInVoltVar                string `json:"lockInVoltVar,omitempty"`
	LockInWattPF                 string `json:"lockInWattPF,omitempty"`
	LockOutChange                string `json:"lockOutChange,omitempty"`
	LockOutVoltVar               string `json:"lockOutVoltVar,omitempty"`
	LockOutWattPF                string `json:"lockOutWattPF,omitempty"`
	LowNoiseMode                 string `json:"lowNoiseMode,omitempty"`
	LowPowerMode                 string `json:"lowPowerMode,omitempty"`
	LowThrough                   string `json:"lowThrough,omitempty"`
	MaxOperatingTimeOfGen        string `json:"maxOperatingTimeOfGen,omitempty"`
	MeterA                       string `json:"meterA,omitempty"`
	MeterB                       string `json:"meterB,omitempty"`
	MeterC                       string `json:"meterC,omitempty"`
	MeterSelect                  string `json:"meterSelect,omitempty"`
	MicExportAll                 string `json:"micExportAll,omitempty"`
	MicExportGridOff             string `json:"micExportGridOff,omitempty"`
	ModbusSn                     string `json:"modbusSn,omitempty"`
	MondayOn                     any    `json:"mondayOn,omitempty"`
	MpptMulti                    string `json:"mpptMulti,omitempty"`
	MpptNum                      string `json:"mpptNum,omitempty"`
	MpptVoltLow                  string `json:"mpptVoltLow,omitempty"`
	NormalUpwardSlope            string `json:"normalUpwardSlope,omitempty"`
	OffGridImmediatelyOff        string `json:"offGridImmediatelyOff,omitempty"`
	Offset                       string `json:"offset,omitempty"`
	Open                         string `json:"open,omitempty"`
	OverFreq1Delay               string `json:"overFreq1Delay,omitempty"`
	OverFreq1                    string `json:"overFreq1,omitempty"`
	OverFreq2Delay               string `json:"overFreq2Delay,omitempty"`
	OverFreq2                    string `json:"overFreq2,omitempty"`
	OverLongVolt                 string `json:"overLongVolt,omitempty"`
	OverVolt1Delay               string `json:"overVolt1Delay,omitempty"`
	OverVolt1                    string `json:"overVolt1,omitempty"`
	OverVolt2Delay               string `json:"overVolt2Delay,omitempty"`
	OverVolt2                    string `json:"overVolt2,omitempty"`
	ParallelRegister1            string `json:"parallelRegister1,omitempty"`
	ParallelRegister2            string `json:"parallelRegister2,omitempty"`
	Parallel                     string `json:"parallel,omitempty"`
	PeakAndVallery               string `json:"peakAndVallery,omitempty"`
	Pf                           string `json:"pf,omitempty"`
	Phase                        string `json:"phase,omitempty"`
	PvLine                       string `json:"pvLine,omitempty"`
	PvMaxLimit                   string `json:"pvMaxLimit,omitempty"`
	Pwm                          string `json:"pwm,omitempty"`
	QvResponseTime               string `json:"qvResponseTime,omitempty"`
	Rcd                          string `json:"rcd,omitempty"`
	ReconnMaxFreq                string `json:"reconnMaxFreq,omitempty"`
	ReconnMaxVolt                string `json:"reconnMaxVolt,omitempty"`
	ReconnMinFreq                string `json:"reconnMinFreq,omitempty"`
	ReconnMinVolt                string `json:"reconnMinVolt,omitempty"`
	RecoveryTime                 string `json:"recoveryTime,omitempty"`
	RemoteLock                   string `json:"remoteLock,omitempty"`
	Reset                        string `json:"reset,omitempty"`
	Riso                         string `json:"riso,omitempty"`
	Rsd                          string `json:"rsd,omitempty"`
	SafetyType                   string `json:"safetyType,omitempty"`
	SaturdayOn                   any    `json:"saturdayOn,omitempty"`
	SdBatteryCurrent             string `json:"sdBatteryCurrent,omitempty"`
	SdChargeOn                   string `json:"sdChargeOn,omitempty"`
	SdStartCap                   string `json:"sdStartCap,omitempty"`
	SdStartVolt                  string `json:"sdStartVolt,omitempty"`
	SellTime1Pac                 string `json:"sellTime1Pac,omitempty"`
	SellTime1                    string `json:"sellTime1,omitempty"`
	SellTime1Volt                string `json:"sellTime1Volt,omitempty"`
	SellTime2Pac                 string `json:"sellTime2Pac,omitempty"`
	SellTime2                    string `json:"sellTime2,omitempty"`
	SellTime2Volt                string `json:"sellTime2Volt,omitempty"`
	SellTime3Pac                 string `json:"sellTime3Pac,omitempty"`
	SellTime3                    string `json:"sellTime3,omitempty"`
	SellTime3Volt                string `json:"sellTime3Volt,omitempty"`
	SellTime4Pac                 string `json:"sellTime4Pac,omitempty"`
	SellTime4                    string `json:"sellTime4,omitempty"`
	SellTime4Volt                string `json:"sellTime4Volt,omitempty"`
	SellTime5Pac                 string `json:"sellTime5Pac,omitempty"`
	SellTime5                    string `json:"sellTime5,omitempty"`
	SellTime5Volt                string `json:"sellTime5Volt,omitempty"`
	SellTime6Pac                 string `json:"sellTime6Pac,omitempty"`
	SellTime6                    string `json:"sellTime6,omitempty"`
	SellTime6Volt                string `json:"sellTime6Volt,omitempty"`
	SensorsCheck                 string `json:"sensorsCheck,omitempty"`
	SignalIslandModeEnable       string `json:"signalIslandModeEnable,omitempty"`
	SmartLoadOpenDelay           string `json:"smartLoadOpenDelay,omitempty"`
	Sn                           string `json:"sn,omitempty"`
	SoftStart                    string `json:"softStart,omitempty"`
	Solar1WindInputEnable        string `json:"solar1WindInputEnable,omitempty"`
	Solar2WindInputEnable        string `json:"solar2WindInputEnable,omitempty"`
	SolarMaxSellPower            string `json:"solarMaxSellPower,omitempty"`
	SolarPSU                     string `json:"solarPSU,omitempty"`
	SolarSell                    string `json:"solarSell,omitempty"`
	SpecialFunction              string `json:"specialFunction,omitempty"`
	Standard                     string `json:"standard,omitempty"`
	StartVoltLow                 string `json:"startVoltLow,omitempty"`
	StartVoltUp                  string `json:"startVoltUp,omitempty"`
	SundayOn                     any    `json:"sundayOn,omitempty"`
	SysWorkMode                  string `json:"sysWorkMode,omitempty"`
	Tempco                       string `json:"tempco,omitempty"`
	TestCommand                  string `json:"testCommand,omitempty"`
	Three41                      string `json:"three41,omitempty"`
	ThursdayOn                   any    `json:"thursdayOn,omitempty"`
	Time1on                      any    `json:"time1on,omitempty"`
	Time1On                      string `json:"time1On,omitempty"`
	Time2on                      any    `json:"time2on,omitempty"`
	Time2On                      string `json:"time2On,omitempty"`
	Time3on                      any    `json:"time3on,omitempty"`
	Time3On                      string `json:"time3On,omitempty"`
	Time4on                      any    `json:"time4on,omitempty"`
	Time4On                      string `json:"time4On,omitempty"`
	Time5on                      any    `json:"time5on,omitempty"`
	Time5On                      string `json:"time5On,omitempty"`
	Time6on                      any    `json:"time6on,omitempty"`
	Time6On                      string `json:"time6On,omitempty"`
	TimeSync                     string `json:"timeSync,omitempty"`
	TuesdayOn                    any    `json:"tuesdayOn,omitempty"`
	UnderFreq1Delay              string `json:"underFreq1Delay,omitempty"`
	UnderFreq1                   string `json:"underFreq1,omitempty"`
	UnderFreq2Delay              string `json:"underFreq2Delay,omitempty"`
	UnderFreq2                   string `json:"underFreq2,omitempty"`
	UnderVolt1Delay              string `json:"underVolt1Delay,omitempty"`
	UnderVolt1                   string `json:"underVolt1,omitempty"`
	UnderVolt2Delay              string `json:"underVolt2Delay,omitempty"`
	UnderVolt2                   string `json:"underVolt2,omitempty"`
	UpsStandard                  string `json:"upsStandard,omitempty"`
	VacHighProtect               string `json:"vacHighProtect,omitempty"`
	VacLowProtect                string `json:"vacLowProtect,omitempty"`
	VarQac1                      string `json:"varQac1,omitempty"`
	VarQac2                      string `json:"varQac2,omitempty"`
	VarQac3                      string `json:"varQac3,omitempty"`
	VarQac4                      string `json:"varQac4,omitempty"`
	VarVolt1                     string `json:"varVolt1,omitempty"`
	VarVolt2                     string `json:"varVolt2,omitempty"`
	VarVolt3                     string `json:"varVolt3,omitempty"`
	VarVolt4                     string `json:"varVolt4,omitempty"`
	VarVoltEnable                string `json:"varVoltEnable,omitempty"`
	VnResponseTime               string `json:"vnResponseTime,omitempty"`
	Volt10                       string `json:"volt10,omitempty"`
	Volt11                       string `json:"volt11,omitempty"`
	Volt12                       string `json:"volt12,omitempty"`
	Volt1                        string `json:"volt1,omitempty"`
	Volt2                        string `json:"volt2,omitempty"`
	Volt3                        string `json:"volt3,omitempty"`
	Volt4                        string `json:"volt4,omitempty"`
	Volt5                        string `json:"volt5,omitempty"`
	Volt6                        string `json:"volt6,omitempty"`
	Volt7                        string `json:"volt7,omitempty"`
	Volt8                        string `json:"volt8,omitempty"`
	Volt9                        string `json:"volt9,omitempty"`
	WattActivePf1                string `json:"wattActivePf1,omitempty"`
	WattActivePf2                string `json:"wattActivePf2,omitempty"`
	WattActivePf3                string `json:"wattActivePf3,omitempty"`
	WattActivePf4                string `json:"wattActivePf4,omitempty"`
	WattFreqEnable               string `json:"wattFreqEnable,omitempty"`
	WattOverExitFreqStopDelay    string `json:"wattOverExitFreqStopDelay,omitempty"`
	WattOverExitFreq             string `json:"wattOverExitFreq,omitempty"`
	WattOverFreq1StartDelay      string `json:"wattOverFreq1StartDelay,omitempty"`
	WattOverFreq1                string `json:"wattOverFreq1,omitempty"`
	WattOverWgralFreq            string `json:"wattOverWgralFreq,omitempty"`
	WattPf1                      string `json:"wattPf1,omitempty"`
	WattPf2                      string `json:"wattPf2,omitempty"`
	WattPf3                      string `json:"wattPf3,omitempty"`
	WattPf4                      string `json:"wattPf4,omitempty"`
	WattPfEnable                 string `json:"wattPfEnable,omitempty"`
	WattUnderExitFreqStopDelay   string `json:"wattUnderExitFreqStopDelay,omitempty"`
	WattUnderExitFreq            string `json:"wattUnderExitFreq,omitempty"`
	WattUnderFreq1StartDelay     string `json:"wattUnderFreq1StartDelay,omitempty"`
	WattUnderFreq1               string `json:"wattUnderFreq1,omitempty"`
	WattUnderWgalFreq            string `json:"wattUnderWgalFreq,omitempty"`
	WattV1                       string `json:"wattV1,omitempty"`
	WattV2                       string `json:"wattV2,omitempty"`
	WattV3                       string `json:"wattV3,omitempty"`
	WattV4                       string `json:"wattV4,omitempty"`
	WattVarActive1               string `json:"wattVarActive1,omitempty"`
	WattVarActive2               string `json:"wattVarActive2,omitempty"`
	WattVarActive3               string `json:"wattVarActive3,omitempty"`
	WattVarActive4               string `json:"wattVarActive4,omitempty"`
	WattVarEnable                string `json:"wattVarEnable,omitempty"`
	WattVarReactive1             string `json:"wattVarReactive1,omitempty"`
	WattVarReactive2             string `json:"wattVarReactive2,omitempty"`
	WattVarReactive3             string `json:"wattVarReactive3,omitempty"`
	WattVarReactive4             string `json:"wattVarReactive4,omitempty"`
	WattVoltEnable               string `json:"wattVoltEnable,omitempty"`
	WattW1                       string `json:"wattW1,omitempty"`
	WattW2                       string `json:"wattW2,omitempty"`
	WattW3                       string `json:"wattW3,omitempty"`
	WattW4                       string `json:"wattW4,omitempty"`
	WednesdayOn                  any    `json:"wednesdayOn,omitempty"`
	WorkState                    string `json:"workState,omitempty"`
	ZeroExportPower              string `json:"zeroExportPower,omitempty"`
}

Inverter is the complete SunSynk model of the inverter including fields that cannot be updated. For example, the batteryShutdownCap field is included in the response which can be useful but this REST API does not allow the field to be updated.

func (*Inverter) BatteryCapacity added in v0.16.0

func (settings *Inverter) BatteryCapacity() int

BatteryCapacity gets the battery state of charge at which point the inverter will use the grid rather than batteries to power circuits.

func (*Inverter) GridChargeOn added in v1.1.0

func (settings *Inverter) GridChargeOn() bool

GridChargeOn returns true if the grid is used at any time to charge the battery.

func (*Inverter) LimitedToLoad added in v0.13.0

func (settings *Inverter) LimitedToLoad() bool

LimitedToLoad returns true if the inverter powers only essential loads. If the inverter can power circuits connected to the CT, this method returns false.

func (*Inverter) SetBatteryCapacity added in v0.6.0

func (settings *Inverter) SetBatteryCapacity(batteryCap int) error

SetBatteryCapacity sets the battery state of charge at which point the inverter will use the grid rather than batteries to power circuits. It is an error to set the capacity at a value higher than the maximum allowed SoC for the battery (typically, 100%) or below the shutdown capacity of the battery (e.g. 10%).

func (*Inverter) SetGridChargeOn added in v1.1.0

func (settings *Inverter) SetGridChargeOn(on bool)

SetGridChargeOn sets whether to enable (true) or disable (false) grid charging of the battery.

func (*Inverter) SetLimitedToLoad added in v0.8.0

func (settings *Inverter) SetLimitedToLoad(limitToLoad bool) error

SetLimitedToLoad is a method that can disable (enable) power to non-essential loads. Passing the value 'true' will disable power from the inverter flowing to non-essential circuits (i.e. those powered by the CT coil).

func (*Inverter) String added in v0.8.0

func (inverter *Inverter) String() string

String() returns a pretty-printed JSON representation of an Inverter.

func (*Inverter) ToShortForm added in v0.13.0

func (inverter *Inverter) ToShortForm() (*InverterShortForm, error)

ToShortForm returns the short form of an Inverter.

func (*Inverter) ToSynkObject added in v0.17.0

func (inverter *Inverter) ToSynkObject() (*SynkObject, error)

ToSynkObject is an adapter that returns a SynkObject adaptation of an Inverter type.

type InverterShortForm added in v0.11.0

type InverterShortForm struct {
	BattMode          string `json:"battMode,omitempty"`
	Cap1              string `json:"cap1,omitempty"`
	Cap2              string `json:"cap2,omitempty"`
	Cap3              string `json:"cap3,omitempty"`
	Cap4              string `json:"cap4,omitempty"`
	Cap5              string `json:"cap5,omitempty"`
	Cap6              string `json:"cap6,omitempty"`
	EnergyMode        string `json:"energyMode,omitempty"`
	FridayOn          any    `json:"fridayOn,omitempty"`
	GenTime1on        any    `json:"genTime1on,omitempty"`
	GenTime2on        any    `json:"genTime2on,omitempty"`
	GenTime3on        any    `json:"genTime3on,omitempty"`
	GenTime4on        any    `json:"genTime4on,omitempty"`
	GenTime5on        any    `json:"genTime5on,omitempty"`
	GenTime6on        any    `json:"genTime6on,omitempty"`
	MondayOn          any    `json:"mondayOn,omitempty"`
	PeakAndVallery    string `json:"peakAndVallery,omitempty"`
	PvMaxLimit        string `json:"pvMaxLimit,omitempty"`
	SafetyType        string `json:"safetyType,omitempty"`
	SaturdayOn        any    `json:"saturdayOn,omitempty"`
	SellTime1Pac      string `json:"sellTime1Pac,omitempty"`
	SellTime1         string `json:"sellTime1,omitempty"`
	SellTime1Volt     string `json:"sellTime1Volt,omitempty"`
	SellTime2Pac      string `json:"sellTime2Pac,omitempty"`
	SellTime2         string `json:"sellTime2,omitempty"`
	SellTime2Volt     string `json:"sellTime2Volt,omitempty"`
	SellTime3Pac      string `json:"sellTime3Pac,omitempty"`
	SellTime3         string `json:"sellTime3,omitempty"`
	SellTime3Volt     string `json:"sellTime3Volt,omitempty"`
	SellTime4Pac      string `json:"sellTime4Pac,omitempty"`
	SellTime4         string `json:"sellTime4,omitempty"`
	SellTime4Volt     string `json:"sellTime4Volt,omitempty"`
	SellTime5Pac      string `json:"sellTime5Pac,omitempty"`
	SellTime5         string `json:"sellTime5,omitempty"`
	SellTime5Volt     string `json:"sellTime5Volt,omitempty"`
	SellTime6Pac      string `json:"sellTime6Pac,omitempty"`
	SellTime6         string `json:"sellTime6,omitempty"`
	SellTime6Volt     string `json:"sellTime6Volt,omitempty"`
	SN                string `json:"sn,omitempty"`
	SolarMaxSellPower string `json:"solarMaxSellPower,omitempty"`
	SolarSell         string `json:"solarSell,omitempty"`
	SundayOn          any    `json:"sundayOn,omitempty"`
	SysWorkMode       string `json:"sysWorkMode,omitempty"`
	ThursdayOn        any    `json:"thursdayOn,omitempty"`
	Time1on           any    `json:"time1on,omitempty"`
	Time2on           any    `json:"time2on,omitempty"`
	Time3on           any    `json:"time3on,omitempty"`
	Time4on           any    `json:"time4on,omitempty"`
	Time5on           any    `json:"time5on,omitempty"`
	Time6on           any    `json:"time6on,omitempty"`
	TuesdayOn         any    `json:"tuesdayOn,omitempty"`
	WednesdayOn       any    `json:"wednesdayOn,omitempty"`
	ZeroExportPower   string `json:"zeroExportPower,omitempty"`
}

InverterShortForm is a struct that includes only Inverter fields that can be updated.

func (*InverterShortForm) String added in v0.11.0

func (inverter *InverterShortForm) String() string

String() returns a pretty-printed JSON representation of an InverterShortForm.

func (*InverterShortForm) ToLongForm added in v0.13.0

func (inverter *InverterShortForm) ToLongForm() (*Inverter, error)

ToLongForm returns a struct with all Inverter fields. Fields that are not defined in the short form will be unpopulated.

type Load added in v0.6.0

type Load struct{ *SynkObject }

Load is the SunSynk model of the load connected to an inverter. The most important attribute of the load is the power being consumed.

func (*Load) Power added in v0.13.0

func (load *Load) Power() int

Power returns the current power (in watts, W) being consumed by the load. This is a convenience method that reads the totalPower attribute of a Load instance.

type SynkClient

type SynkClient struct {
	SerialNumber string
	// contains filtered or unexported fields
}

SynkClient is a type that is needed for accessing the SunSynk API; it includes the API endpoint and OAuth tokens. It also includes the serial number for an inverter since most requests use the serial number to identify which object is being requested (e.g. the details of a battery connected to the inverter.)

func Authenticate

func Authenticate(ctx context.Context, config *configuration.Configuration) (*SynkClient, error)

Authenticate uses a specify configuration to authenticate a user. If successful, a SynkClient is returned that can be used to make requests against the API.

func (*SynkClient) Battery added in v0.13.0

func (synkClient *SynkClient) Battery(ctx context.Context) (*Battery, error)

Battery calls the SunSynk REST API to get the state of a battery connected to the inverter.

func (*SynkClient) Grid added in v0.13.0

func (synkClient *SynkClient) Grid(ctx context.Context) (*Grid, error)

Grid calls the SunSynk REST API to get the state of the power grid.

func (*SynkClient) Input added in v0.13.0

func (synkClient *SynkClient) Input(ctx context.Context) (*Input, error)

Input calls the SunSynk REST API to get the state of the input.

func (*SynkClient) Inverter added in v0.13.0

func (synkClient *SynkClient) Inverter(ctx context.Context) (*Inverter, error)

Inverter gets the settings of an inverter from the API.

func (*SynkClient) ListInverters

func (synkClient *SynkClient) ListInverters(ctx context.Context) ([]string, error)

ListInverters returns the serial numbers of all inverters that the user can view.

func (*SynkClient) Load added in v0.13.0

func (synkClient *SynkClient) Load(ctx context.Context) (*Load, error)

Load calls the SunSynk REST API to get the state of the load.

func (*SynkClient) UpdateInverter added in v0.13.0

func (synkClient *SynkClient) UpdateInverter(ctx context.Context, settings *Inverter) error

UpdateInverter issues a POST request to the SunSynk API to reconfigure the inverter. For example, the battery capacity can be changed or powering non-essential circuits can be disabled.

type SynkObject

type SynkObject map[string]any

SynkObject is an abstraction of JSON objects returned by the SunSynk REST API. Concrete objects like Grid, Load or Battery encapsulate an instance of SynkObject that maps attributes of the object to values. The SynkObject type is "read only" and types derived from it should not be updated.

Note: The Inverter abstraction does not encapsulate an instance of this type. The Inverter type is special since it can be updated (e.g. to set the battery discharge threshold.)

func (*SynkObject) ExtractKeys added in v0.17.0

func (s *SynkObject) ExtractKeys(keys []string) (*SynkObject, error)

ExtractKeys returns a subset of the fields of a SynkObject

func (*SynkObject) Get added in v0.7.0

func (s *SynkObject) Get(key string) (any, bool)

Get returns the value of an attribute for an object returned by the SunSynk REST API.

func (SynkObject) String added in v0.4.0

func (s SynkObject) String() string

String returns a JSON representation of a SynkObject (grid, battery, load, etc.)

type SynkResponse

type SynkResponse struct {
	Code    int            `json:"code"`
	Message string         `json:"msg"`
	Data    map[string]any `json:"data"`
	Success bool           `json:"success"`
}

SynkResponse is the response returned by the SunSynk API to any HTTP GET. The "data" field encapsulates the object that was requested (e.g. OAuth tokens or details about an inverter, battery, etc.)

Jump to

Keyboard shortcuts

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