ad-ha/mg-saic-ha

[ISSUE] battery capacity value incorrect

Closed this issue · 2 comments

Home Assistant Version

2024.11.3

MG/SAIC Integration Version

0.6.0

Installation Method

HACS

Did you check for existing issues?

  • Yes, I have checked for existing issues
  • No, I have not checked for existing issues

Did you enable debug logging before and are ready to post logs?

  • Yes, I have enabled debug logging
  • No, I have not enabled debug logging

Describe the Issue

Hello! I was just testing out the newly-added "total battery capacity". I have an MG ZS EV (Australia) with a 51kwh battery, which seems to be incorrectly reporting as 72.5 under sensor.mg_zs_ev_total_battery_capacity when it should be ~51.

There is a warning in the logs about this sensor which may be relevant:

Entity sensor.mg_zs_ev_total_battery_capacity (<class 'custom_components.mg_saic.sensor.SAICMGChargingSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total_increasing', 'total'

Logs

2024-11-25 17:44:32.726 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.mg_zs_ev_total_battery_capacity (<class 'custom_components.mg_saic.sensor.SAICMGChargingSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total_increasing', 'total'; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/ad-ha/mg-saic-ha/issues
2024-11-25 17:57:22.066 DEBUG (MainThread) [custom_components.mg_saic] Vehicle Type: BEV
2024-11-25 17:57:22.066 DEBUG (MainThread) [custom_components.mg_saic] Vehicle Info: [VinInfo(bindTime=1729312267000, brandName='MG', colorName='St.Moritz Blue', isActivate=False, isCurrentVehicle=True, isSubaccount=False, modelName='ZS EV', modelYear='2021', name='MGZS', series='ZS EV L', vin='<redacted>', subAccountList=[], vehicleModelConfiguration=[VehicleModelConfiguration(itemCode='J17', itemName='Tire pressure monitoring system', itemValue='1'), VehicleModelConfiguration(itemCode='Q00', itemName='Regular airbags', itemValue='1'), VehicleModelConfiguration(itemCode='Q01', itemName='Front-seat airbags', itemValue='0'), VehicleModelConfiguration(itemCode='Q09', itemName='Airbag switch', itemValue='0'), VehicleModelConfiguration(itemCode='S35', itemName='Sun Roof', itemValue='0'), VehicleModelConfiguration(itemCode='S61', itemName='Remote control', itemValue='1'), VehicleModelConfiguration(itemCode='T11', itemName='Air conditioning', itemValue='1'), VehicleModelConfiguration(itemCode='EPS', itemName='Electric Power Steering', itemValue='1'), VehicleModelConfiguration(itemCode='SA64', itemName='Security alert', itemValue='0111110000000000000010000100100100000010100000000000000000000110'), VehicleModelConfiguration(itemCode='BONNUT', itemName='Bonnut Status', itemValue='1'), VehicleModelConfiguration(itemCode='DOOR', itemName='Door Status', itemValue='1111'), VehicleModelConfiguration(itemCode='BOOT', itemName='Boot Status', itemValue='1'), VehicleModelConfiguration(itemCode='ENGINE', itemName='Engine Status', itemValue='1'), VehicleModelConfiguration(itemCode='EV', itemName='Electric Vehicle', itemValue='0'), VehicleModelConfiguration(itemCode='HeatedSeat', itemName='HeatedSeat', itemValue='0'), VehicleModelConfiguration(itemCode='KEYPOS', itemName='Key Position', itemValue='1'), VehicleModelConfiguration(itemCode='ENERGY', itemName='Energy state', itemValue='1'), VehicleModelConfiguration(itemCode='BATTERY', itemName='Battery Voltage', itemValue='1'), VehicleModelConfiguration(itemCode='INTEMP', itemName='Interior Temperature', itemValue='1'), VehicleModelConfiguration(itemCode='EXTEMP', itemName='Exterior Temperature', itemValue='1'), VehicleModelConfiguration(itemCode='WINDOW', itemName='Window Status', itemValue='0000'), VehicleModelConfiguration(itemCode='LRD', itemName='Left-Right Driving', itemValue='1'), VehicleModelConfiguration(itemCode='BTKEY', itemName='BLE CarKey', itemValue='0'), VehicleModelConfiguration(itemCode='BTYPE', itemName='Battery Type', itemValue='2'), VehicleModelConfiguration(itemCode='ROV', itemName='ROV', itemValue='25857')])]
2024-11-25 17:57:22.067 DEBUG (MainThread) [custom_components.mg_saic] Vehicle Status: VehicleStatusResp(basicVehicleStatus=BasicVehicleStatus(batteryVoltage=148, bonnetStatus=0, bootStatus=0, canBusActive=1, clstrDspdFuelLvlSgmt=0, currentJourneyId=743, currentJourneyDistance=110, dippedBeamStatus=0, driverDoor=0, driverWindow=0, engineStatus=0, extendedData1=72, extendedData2=0, exteriorTemperature=18, frontLeftSeatHeatLevel=0, frontLeftTyrePressure=74, frontRightSeatHeatLevel=0, frontRightTyrePressure=73, fuelLevelPrc=0, fuelRange=2150, fuelRangeElec=2150, handBrake=0, interiorTemperature=24, lastKeySeen=32355, lockStatus=1, mainBeamStatus=0, mileage=25810, passengerDoor=0, passengerWindow=0, powerMode=0, rearLeftDoor=0, rearLeftTyrePressure=72, rearLeftWindow=0, rearRightDoor=0, rearRightTyrePressure=73, rearRightWindow=0, remoteClimateStatus=2, rmtHtdRrWndSt=0, sideLightStatus=0, steeringHeatLevel=0, steeringWheelHeatFailureReason=0, sunroofStatus=0, timeOfLastCANBUSActivity=None, vehElecRngDsp=0, vehicleAlarmStatus=2, wheelTyreMonitorStatus=0), extendedVehicleStatus=ExtendedVehicleStatus(alertDataSum=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), gpsPosition=GpsPosition(gpsStatus=2, timeStamp=1732517836, wayPoint=GpsPosition.WayPoint(hdop=5, heading=10, position=GpsPosition.WayPoint.Position(altitude=52, latitude=<redacted>, longitude=<redacted>), satellites=8, speed=0)), statusTime=1732517837)
2024-11-25 17:57:22.073 DEBUG (MainThread) [custom_components.mg_saic] Vehicle Charging Data: ChrgMgmtDataResp(chrgMgmtData=ChrgMgmtData(bmsAdpPubChrgSttnDspCmd=1, bmsAltngChrgCrntDspCmd=0, bmsChrgCtrlDspCmd=2, bmsChrgOtptCrntReq=0, bmsChrgOtptCrntReqV=None, bmsChrgSpRsn=0, bmsChrgSts=0, bmsDsChrgSpRsn=None, bmsEstdElecRng=304, bmsOnBdChrgTrgtSOCDspCmd=7, bmsPackCrnt=20046, bmsPackCrntV=None, bmsPackSOCDsp=715, bmsPackVol=1594, bmsPTCHeatReqDspCmd=0, bmsPTCHeatResp=None, bmsPTCHeatSpRsn=0, bmsReserCtrlDspCmd=2, bmsReserSpHourDspCmd=5, bmsReserSpMintueDspCmd=0, bmsReserStHourDspCmd=21, bmsReserStMintueDspCmd=5, ccuEleccLckCtrlDspCmd=None, ccuOffBdChrgrPlugOn=None, ccuOnbdChrgrPlugOn=None, chrgngAddedElecRng=None, chrgngAddedElecRngV=None, chrgngDoorOpenCnd=None, chrgngDoorPosSts=None, chrgngRmnngTime=1023, chrgngRmnngTimeV=1, chrgngSpdngTime=None, chrgngSpdngTimeV=None, clstrElecRngToEPT=215, disChrgngRmnngTime=None, disChrgngRmnngTimeV=None, imcuChrgngEstdElecRng=None, imcuChrgngEstdElecRngV=None, imcuDschrgngEstdElecRng=None, imcuDschrgngEstdElecRngV=None, imcuVehElecRng=None, imcuVehElecRngV=None, onBdChrgrAltrCrntInptCrnt=None, onBdChrgrAltrCrntInptVol=None), rvsChargeStatus=RvsChargeStatus(chargingDuration=0, chargingElectricityPhase=None, chargingGunState=0, chargingPileID=None, chargingPileSupplier=None, chargingType=3, endTime=1732504857, extendedData1=None, extendedData2=None, extendedData3=None, extendedData4=None, fotaLowestVoltage=None, fuelRangeElec=2150, lastChargeEndingPower=558, mileage=25810, mileageOfDay=160, mileageSinceLastCharge=160, powerUsageOfDay=863, powerUsageSinceLastCharge=40, realtimePower=518, startTime=1732504614, staticEnergyConsumption=None, totalBatteryCapacity=725, workingCurrent=20046, workingVoltage=1594))
2024-11-25 17:57:22.076 DEBUG (MainThread) [custom_components.mg_saic] Finished fetching MG SAIC data update coordinator data in 6.802 seconds (success: True)

Additional Context

No response

Hi @brettmc

Thanks for the feedback.

On the battery capacity, that's directly the information that the API is returning. From your log: totalBatteryCapacity=725

MG sends some values that cannot be really understandable. Example, your log also has: itemName='Electric Vehicle', itemValue='0' which would mean that it is not Electric.

If we are able to create a user based info for battery capacity and correlation to models, I could create a dictionary to get those values, but seems quite a hard job to get the info for all vehicles and models.

On the state class warning, I will have a look and get it fixed for next release.

The warning message has been fixed on 0.6.1

The total battery capacity cannot be addressed since it is dependent on the API reply data.