Bug: oldIndex hardcoded to "1" for all modes in Mode.payload()
Description
The Mode.payload() method hardcodes oldIndex to "1" for every mode, but the correct value differs per mode as shown in the comments of Client.set_mode():
# Time of use: oldIndex=3
# Emergency Backup: oldIndex=1
# Self consumption: oldIndex=2
Impact
Sending the wrong oldIndex causes the FranklinWH app to no longer correctly display the current operating mode, even though the battery itself behaves correctly.
Suggested Fix
Each static factory method (time_of_use, emergency_backup, self_consumption) should set the correct oldIndex on the Mode instance, and payload() should use it:
def time_of_use(soc=20):
mode = Mode(soc)
mode.currendId = 9322
mode.workMode = 1
mode.oldIndex = 3
return mode
def emergency_backup(soc=100):
mode = Mode(soc)
mode.currendId = 9324
mode.workMode = 3
mode.oldIndex = 1
return mode
def self_consumption(soc=20):
mode = Mode(soc)
mode.currendId = 9323
mode.workMode = 2
mode.oldIndex = 2
return mode
Bug:
oldIndexhardcoded to"1"for all modes inMode.payload()Description
The
Mode.payload()method hardcodesoldIndexto"1"for every mode, but the correct value differs per mode as shown in the comments ofClient.set_mode():Impact
Sending the wrong
oldIndexcauses the FranklinWH app to no longer correctly display the current operating mode, even though the battery itself behaves correctly.Suggested Fix
Each static factory method (
time_of_use,emergency_backup,self_consumption) should set the correctoldIndexon theModeinstance, andpayload()should use it: