Skip to content

Commit 336aeea

Browse files
FLEXmax detection should no longer throw errors
1 parent f8602a9 commit 336aeea

File tree

3 files changed

+89
-6
lines changed

3 files changed

+89
-6
lines changed

core/src/main/java/me/retrodaredevil/solarthing/solar/outback/mx/AuxMode.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
* make sure that the value code you compare with this
99
* <p>
1010
* Also, it's possible there are undocumented modes such as 27: https://forum.outbackpower.com/viewtopic.php?f=14&t=8268&sid=710ecc3edc75cf26584532c3b93d5aef
11+
* <p>
12+
* For modes such as 27 or 63, it is assumed that an Outback FLEXmax is being used and a Mate with outdated firmware is reporting the aux mode.
13+
* For these situations, you must be careful in parsing the aux mode.
1114
*/
1215
@SuppressWarnings("unused")
1316
public enum AuxMode implements CodeMode {

core/src/main/java/me/retrodaredevil/solarthing/solar/outback/mx/MXStatusPacket.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ default boolean isNewDay(DailyData previousDailyData){
143143
default int getAuxModeValue() {
144144
return AuxMode.getActualValueCode(getRawAuxModeValue());
145145
}
146-
@GraphQLInclude("auxMode")
146+
@Deprecated
147147
default @NotNull AuxMode getAuxMode(){ return Modes.getActiveMode(AuxMode.class, getAuxModeValue());}
148+
@GraphQLInclude("auxMode")
149+
default @Nullable AuxMode getAuxModeOrNull(){ return Modes.getActiveModeOrNull(AuxMode.class, getAuxModeValue());}
148150
@GraphQLInclude("auxBitActive")
149151
default boolean isAuxBitActive(){ return AuxMode.isAuxModeActive(getRawAuxModeValue()); }
150152

@@ -162,7 +164,7 @@ default int getAuxModeValue() {
162164

163165
/**
164166
* Should be serialized as "chargerMode"
165-
*
167+
* <p>
166168
* Right now, the range should only be [0..4] as there are no documented charger modes other than those 5
167169
* @return [0..99] representing the MX's {@link ChargerMode}
168170
*/
@@ -206,9 +208,14 @@ default int getAuxModeValue() {
206208
// endregion
207209

208210
// region Convenience Strings
211+
@Deprecated
212+
default @NotNull String getAuxModeName(){ return getAuxMode().getModeName(); }
209213
@ConvenienceField
210214
@JsonProperty("auxModeName")
211-
default @NotNull String getAuxModeName(){ return getAuxMode().getModeName(); }
215+
default @Nullable String getAuxModeNameOrNull(){
216+
AuxMode auxMode = getAuxModeOrNull();
217+
return auxMode == null ? null : auxMode.getModeName();
218+
}
212219
@ConvenienceField
213220
@JsonProperty("errors")
214221
default @NotNull String getErrorsString(){ return Modes.toString(MXErrorMode.class, getErrorModeValue()); }
@@ -218,7 +225,6 @@ default int getAuxModeValue() {
218225
// endregion
219226

220227
/**
221-
* Note: It is unknown if this means old MX firmware or old mate firmware
222228
* @return true if the Mate's firmware is pre 4.01, false otherwise
223229
*/
224230
default boolean isOldMateFirmware(){
@@ -234,12 +240,25 @@ default boolean isOldMateFirmware(){
234240
* @return true if this is a FlexMAX charge controller, false if it's an MX, null if the Mate has old firmware and is unable to tell
235241
*/
236242
default @Nullable Boolean isFlexMax(){
237-
if (isAuxBitActive() || getAuxMode().isFlexMaxOnly() || getAmpChargerCurrent() != 0) {
243+
if (isAuxBitActive() || getAmpChargerCurrent() != 0) {
244+
return true;
245+
}
246+
AuxMode auxMode = getAuxModeOrNull();
247+
boolean oldMateFirmware = isOldMateFirmware();
248+
if (auxMode == null) {
249+
// If we cannot parse the aux mode, then we assume we have an old MATE firmware and it is a FLEXmax.
250+
// If it's a new MATE firmware and we cannot parse the aux mode, we don't know what the heck is going on
251+
return oldMateFirmware ? true : null;
252+
}
253+
if (auxMode.isFlexMaxOnly()) {
238254
return true;
239255
}
240256
if (isOldMateFirmware()) {
257+
// In this case we parsed an auxiliary mode that could be for an MX or for a FLEXmax.
258+
// It is most likely that this is an MX since we were able to parse the aux mode at all, but there's still a chance it is a FLEXmax.
241259
return null;
242260
}
261+
// In this case, we have updated MATE firmware, so it is only an MX device if the daily AH reading is 9999
243262
return getDailyAH() != 9999;
244263
}
245264

web/src/generated/graphql.ts

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export type Scalars = {
3333
Long: any;
3434
/** Built-in scalar for dynamic values */
3535
ObjectScalar: any;
36+
/** Built-in Short as Int */
37+
Short: any;
3638
/** Use SPQR's SchemaPrinter to remove this from SDL */
3739
UNREPRESENTABLE: any;
3840
};
@@ -123,6 +125,11 @@ export enum BatteryManagementMode {
123125
VOLTAGE_COMPENSATION = 'VOLTAGE_COMPENSATION'
124126
}
125127

128+
export enum BatteryType {
129+
LEAD_ACID = 'LEAD_ACID',
130+
LITHIUM = 'LITHIUM'
131+
}
132+
126133
export type BatteryVoltage = {
127134
__typename?: 'BatteryVoltage';
128135
/** The battery voltage */
@@ -161,6 +168,16 @@ export enum ChargingEquipmentError {
161168
PV_INPUT_SHORT = 'PV_INPUT_SHORT'
162169
}
163170

171+
export enum ChargingMethod_E02D {
172+
DIRECT = 'DIRECT',
173+
PWM = 'PWM'
174+
}
175+
176+
export enum ChargingMethod_E021 {
177+
DIRECT = 'DIRECT',
178+
PWM = 'PWM'
179+
}
180+
164181
export enum ChargingState {
165182
ACTIVATED = 'ACTIVATED',
166183
BOOST = 'BOOST',
@@ -368,6 +385,7 @@ export type ExecutionReason = {
368385
};
369386

370387
export enum ExecutionReasonType {
388+
PACKET_COLLECTION = 'PACKET_COLLECTION',
371389
SOURCE = 'SOURCE'
372390
}
373391

@@ -672,7 +690,7 @@ export type MXStatusPacket = {
672690
/** @deprecated Field no longer supported */
673691
ampChargerCurrent: Scalars['Float'];
674692
auxBitActive: Scalars['Boolean'];
675-
auxMode: AuxMode;
693+
auxMode?: Maybe<AuxMode>;
676694
auxModeValue: Scalars['Int'];
677695
auxModeValueRaw: Scalars['Int'];
678696
/** The battery voltage */
@@ -1418,7 +1436,9 @@ export type RoverStatusPacket = {
14181436
solarModeName: Scalars['String'];
14191437
solarModeType: SolarModeType;
14201438
solarModeTypeDisplayName: Scalars['String'];
1439+
specialPowerControlE02D?: Maybe<SpecialPowerControl_E02D>;
14211440
specialPowerControlE02DRaw?: Maybe<Scalars['Int']>;
1441+
specialPowerControlE021?: Maybe<SpecialPowerControl_E021>;
14221442
specialPowerControlE021Raw: Scalars['Int'];
14231443
streetLightValue: Scalars['Int'];
14241444
systemVoltageSetting: Scalars['Int'];
@@ -1689,6 +1709,42 @@ export type SolarThingStatusQuery = {
16891709
tracerStatus: Array<PacketNode_TracerStatusPacket>;
16901710
};
16911711

1712+
export type SpecialPowerControl_E02D = {
1713+
__typename?: 'SpecialPowerControl_E02D';
1714+
batteryType?: Maybe<BatteryType>;
1715+
batteryTypeValueCode: Scalars['Int'];
1716+
chargingMethod?: Maybe<ChargingMethod_E02D>;
1717+
chargingMethodValueCode: Scalars['Int'];
1718+
combined: Scalars['Int'];
1719+
combinedShort: Scalars['Short'];
1720+
formattedInfo?: Maybe<Scalars['String']>;
1721+
is24VSystem: Scalars['Boolean'];
1722+
isEachNightOnEnabled: Scalars['Boolean'];
1723+
isIntelligentPowerEnabled: Scalars['Boolean'];
1724+
isLithiumBattery: Scalars['Boolean'];
1725+
isNoChargingBelow0CEnabled: Scalars['Boolean'];
1726+
lower: Scalars['Int'];
1727+
rawChargingMethodValueCode: Scalars['Int'];
1728+
systemVoltage?: Maybe<SystemVoltage>;
1729+
systemVoltageValueCode: Scalars['Int'];
1730+
upper: Scalars['Int'];
1731+
};
1732+
1733+
export type SpecialPowerControl_E021 = {
1734+
__typename?: 'SpecialPowerControl_E021';
1735+
chargingMethod?: Maybe<ChargingMethod_E021>;
1736+
chargingMethodValueCode: Scalars['Int'];
1737+
combined: Scalars['Int'];
1738+
combinedShort: Scalars['Short'];
1739+
formattedInfo?: Maybe<Scalars['String']>;
1740+
isChargingModeControlledByVoltage: Scalars['Boolean'];
1741+
isEachNightOnEnabled: Scalars['Boolean'];
1742+
isNoChargingBelow0CEnabled: Scalars['Boolean'];
1743+
isSpecialPowerControlEnabled: Scalars['Boolean'];
1744+
lower: Scalars['Int'];
1745+
upper: Scalars['Int'];
1746+
};
1747+
16921748
export type SuccessMateCommandPacket = {
16931749
__typename?: 'SuccessMateCommandPacket';
16941750
command: MateCommand;
@@ -1705,6 +1761,11 @@ export enum Support {
17051761
UNKNOWN = 'UNKNOWN'
17061762
}
17071763

1764+
export enum SystemVoltage {
1765+
V12 = 'V12',
1766+
V24 = 'V24'
1767+
}
1768+
17081769
export enum TargetedMetaPacketType {
17091770
DATA_INFO = 'DATA_INFO',
17101771
DEVICE_INFO = 'DEVICE_INFO',

0 commit comments

Comments
 (0)