Documentation
¶
Index ¶
- Constants
- Variables
- type Marstek
- func (m *Marstek) BluetoothLock(enable bool) error
- func (m *Marstek) ClearManualSchedule() error
- func (m *Marstek) GetBatStatus() (map[string]interface{}, error)
- func (m *Marstek) GetBluetoothStatus() (map[string]interface{}, error)
- func (m *Marstek) GetDevice(bleMac string) (map[string]interface{}, error)
- func (m *Marstek) GetEnergyMeterStatus() (map[string]interface{}, error)
- func (m *Marstek) GetEnergySystemStatus() (map[string]interface{}, error)
- func (m *Marstek) GetMode() (map[string]interface{}, error)
- func (m *Marstek) GetPVStatus() (map[string]interface{}, error)
- func (m *Marstek) GetWifiStatus() (map[string]interface{}, error)
- func (m *Marstek) LEDControl(enable bool) error
- func (m *Marstek) PassivePowerConsumption(power, cdTime int) error
- func (m *Marstek) SetAIMode(enable bool) error
- func (m *Marstek) SetAutoMode(enable bool) error
- func (m *Marstek) SetDOD(value int) error
- func (m *Marstek) SetManualSchedule(schedule *Schedule) error
- func (m *Marstek) SetUPSMode(enable bool) error
- func (m *Marstek) Summary() (map[string]interface{}, error)
- type Schedule
Constants ¶
const MaxManualSchedules = 10
MaxManualSchedules defines the maximum number of manual schedules that can be set for the device. This is based on the device's capabilities and ensures that we do not exceed the allowed number of schedules when clearing them.
Variables ¶
var MaxRetries = 4
MaxRetries defines the maximum number of retry attempts when a read timeout occurs while waiting for a response from the device. This allows for multiple attempts to get a response in case of temporary issues with the device or network.
var ReadTimeout = 15
ReadTimeout defines the duration in seconds to wait for a response from the device before considering it a timeout. This is used to set the read deadline when waiting for a response, allowing for a reasonable amount of time for the device to respond before retrying or giving up.
var RetryDelay = 1
RetryDelay defines the delay in seconds between retry attempts when a read timeout occurs while waiting for a response from the device. This allows for a brief pause before retrying the request, which can help in cases where the device may be temporarily unresponsive or experiencing network issues.
Functions ¶
This section is empty.
Types ¶
type Marstek ¶
func New ¶
New creates a new instance of the Marstek struct with the provided service address. It initializes the Services field with the given address and returns a pointer to the Marstek instance. This function is used to create a new Marstek object that can be used to interact with the device.
func (*Marstek) BluetoothLock ¶
BluetoothLock sets the Bluetooth lock status of the device by sending a request to the device. It constructs a JSON request using a template and sends it to the device to update the Bluetooth lock settings. The method takes in a boolean parameter to enable or disable the Bluetooth lock and returns any error encountered during the process. The enable parameter determines whether to enable (true) or disable (false) the Bluetooth lock, and the method sends the appropriate request to the device based on the value of this parameter.
func (*Marstek) ClearManualSchedule ¶
ClearManualSchedule clears all manual schedules by sending a request to set each schedule to disabled with default values. It iterates through the maximum number of allowed manual schedules and sends a request for each one to ensure they are all cleared.
func (*Marstek) GetBatStatus ¶
GetBatStatus retrieves the battery status of the device by sending a request to the device. It constructs a JSON request and sends it to the device to obtain the battery status information. The method returns the battery status as a map and any error encountered during the process.
func (*Marstek) GetBluetoothStatus ¶
GetBluetoothStatus retrieves the Bluetooth status of the device by sending a request to the device. It constructs a JSON request and sends it to the device to obtain the Bluetooth status information. The method returns the Bluetooth status as a map and any error encountered during the process.
func (*Marstek) GetDevice ¶
GetDevice retrieves the device information by sending a request to the device using its BLE MAC address. It constructs a JSON request with the provided BLE MAC address and sends it to the device to obtain the device information. The method returns the device information as a map and any error encountered during the process.
func (*Marstek) GetEnergyMeterStatus ¶
GetEnergyMeterStatus retrieves the energy meter status of the device by sending a request to the device. It constructs a JSON request and sends it to the device to obtain the energy meter status information. The method returns the energy meter status as a map and any error encountered during the process.
func (*Marstek) GetEnergySystemStatus ¶
GetEnergySystemStatus retrieves the energy system status of the device by sending a request to the device. It constructs a JSON request and sends it to the device to obtain the energy system status information. The method returns the energy system status as a map and any error encountered during the process.
func (*Marstek) GetMode ¶
GetMode retrieves the current mode of the device by sending a request to the device. It constructs a JSON request using a template and sends it to the device to obtain the mode information. The method returns the mode information as a map and any error encountered during the process.
func (*Marstek) GetPVStatus ¶
GetPVStatus retrieves the photovoltaic (PV) status of the device by sending a request to the device. It constructs a JSON request and sends it to the device to obtain the PV status information. The method returns the PV status as a map and any error encountered during the process.
func (*Marstek) GetWifiStatus ¶
GetWifiStatus retrieves the Wi-Fi status of the device by sending a request to the device. It constructs a JSON request and sends it to the device to obtain the Wi-Fi status information. The method returns the Wi-Fi status as a map and any error encountered during the process.
func (*Marstek) LEDControl ¶
LEDControl sets the LED control status of the device by sending a request to the device. It constructs a JSON request using a template and sends it to the device to update the LED control settings. The method takes in a boolean parameter to enable or disable the LED control and returns any error encountered during the process. The enable parameter determines whether to enable (true) or disable (false) the LED control, and the method sends the appropriate request to the device based on the value of this parameter.
func (*Marstek) PassivePowerConsumption ¶
PassivePowerConsumption sets the environment power consumption by sending a request to the device. It constructs a JSON request using a template and sends it to the device to update the power consumption settings. The method takes in the desired power level and cooldown time as parameters and returns any error encountered during the process. The negative power value indicates the power consumption level into the battery, positive power value indicates the power output level from the battery, and zero means no power consumption or output.
func (*Marstek) SetAIMode ¶
SetAIMode sets the device to AI mode by sending a request to the device. It constructs a JSON request using a template and sends it to the device to update the mode settings. The method takes in a boolean parameter to enable or disable AI mode and returns any error encountered during the process.
func (*Marstek) SetAutoMode ¶
SetAutoMode sets the device to auto mode by sending a request to the device. It constructs a JSON request using a template and sends it to the device to update the mode settings. The method returns any error encountered during the process.
func (*Marstek) SetDOD ¶
SetDOD sets the depth of discharge (DOD) value for the device by sending a request to the device. It constructs a JSON request using a template and sends it to the device to update the DOD settings. The method takes in the desired DOD value as a parameter and returns any error encountered during the process. The DOD value must be between 33 and 88, and the method will return an error if the value is out of range.
func (*Marstek) SetManualSchedule ¶
SetManualSchedule sets a manual schedule for the device by sending a request to the device. It constructs a JSON request using a template and sends it to the device to update the manual schedule settings. The method takes in a Schedule struct as a parameter, which contains the schedule details, and returns any error encountered during the process.
func (*Marstek) SetUPSMode ¶
SetUPSMode sets the device to UPS mode by sending a request to the device. It constructs a JSON request using a template and sends it to the device to update the mode settings. The method takes in a boolean parameter to enable or disable UPS mode and returns any error encountered during the process.