feat: Enhance MK2 driver with device state management and improved command handling
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -102,3 +102,57 @@ type SettingsWriter interface {
|
||||
// When enabled, the inverter is prevented from sleeping while switched off.
|
||||
SetStandby(enabled bool) error
|
||||
}
|
||||
|
||||
type DeviceState byte
|
||||
|
||||
const (
|
||||
// DeviceStateChargerOnly enables charging only.
|
||||
DeviceStateChargerOnly DeviceState = 0x02
|
||||
// DeviceStateInverterOnly enables inverter output and disables charging.
|
||||
DeviceStateInverterOnly DeviceState = 0x03
|
||||
// DeviceStateOn enables both inverter and charger.
|
||||
DeviceStateOn DeviceState = 0x04
|
||||
// DeviceStateOff disables inverter and charger.
|
||||
DeviceStateOff DeviceState = 0x05
|
||||
)
|
||||
|
||||
var DeviceStateNames = map[DeviceState]string{
|
||||
DeviceStateChargerOnly: "charger_only",
|
||||
DeviceStateInverterOnly: "inverter_only",
|
||||
DeviceStateOn: "on",
|
||||
DeviceStateOff: "off",
|
||||
}
|
||||
|
||||
type RAMVarInfo struct {
|
||||
ID uint16
|
||||
Scale int16
|
||||
Offset int16
|
||||
Factor float64
|
||||
Signed bool
|
||||
Supported bool
|
||||
}
|
||||
|
||||
// ProtocolControl exposes protocol 3.14 command paths for direct MK2 control.
|
||||
type ProtocolControl interface {
|
||||
SettingsWriter
|
||||
// GetDeviceState returns the current VE.Bus state using command 0x0E.
|
||||
GetDeviceState() (DeviceState, error)
|
||||
// SetDeviceState sets the VE.Bus state using command 0x0E.
|
||||
SetDeviceState(state DeviceState) error
|
||||
// ReadRAMVarByID reads a RAM variable via command 0x30.
|
||||
ReadRAMVarByID(id uint16) (int16, error)
|
||||
// ReadSettingByID reads a setting via command 0x31.
|
||||
ReadSettingByID(id uint16) (int16, error)
|
||||
// SelectRAMVar selects a RAM variable for follow-up read-selected/write-selected paths.
|
||||
SelectRAMVar(id uint16) error
|
||||
// SelectSetting selects a setting for follow-up read-selected/write-selected paths.
|
||||
SelectSetting(id uint16) error
|
||||
// ReadSelected reads the currently selected value via command 0x35.
|
||||
ReadSelected() (int16, error)
|
||||
// ReadRAMVarInfo reads RAM variable metadata via command 0x36.
|
||||
ReadRAMVarInfo(id uint16) (RAMVarInfo, error)
|
||||
// WriteSettingByID writes a setting via command 0x37.
|
||||
WriteSettingByID(id uint16, value int16) error
|
||||
// WriteRAMVarByID writes a RAM variable via command 0x38.
|
||||
WriteRAMVarByID(id uint16, value int16) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user