ad-ha/mg-saic-ha

Refresh Service

Closed this issue ยท 7 comments

Hey, just wondering if there is a way to implmenet a refresh, i appreicate there is a default refresh time of 7200 minutes but i have an automation which triggers when my pod point charger is connected to the car.

At this point it would be great to have the MG integration poll for the latest information, that way i can ensure the car is also showing connected and ready for charging etc...

Hi @eximo84

Sure, I already had that in mind as well (very similar use case). It shall be pretty straight forward to get working, so let me find sometime this week to get it done and I will release a new update with that change.

I may also include a button to directly call the update service.

Cheers

Hi @eximo84

So I had a moment to get this done and implemented. You have the new service and button on release 0.4.5 (https://github.com/ad-ha/mg-saic-ha/releases/tag/0.4.5)

Let me know if it all works fine.

Cheers

Wow amazing. Updated, I haven't pressed the button yet but will test it later. Thank you ๐Ÿ™๐Ÿผ

Sorry to reopen, finally got around the testing. I think its working although the battery is reporting at 102.3% after a button refresh. Under a controlled test just now.

Car was plugged in - i forced a reload of the integration to get me to a baseline

image

image

The car is now unplugged as ive just driven it and got back home - the integration hasnt refreshed yet because its not designed to.

Pressing the refresh button at 9:48

image

After refresh

image

image

See log:

2024-11-15 09:48:48.927 DEBUG (MainThread) [custom_components.mg_saic] Generic Charging Data response.
2024-11-15 09:48:48.927 ERROR (MainThread) [custom_components.mg_saic] Error: Generic charging response received.
2024-11-15 09:48:52.594 DEBUG (MainThread) [custom_components.mg_saic] Vehicle Type: BEV
2024-11-15 09:48:52.594 DEBUG (MainThread) [custom_components.mg_saic] Vehicle Info: [VinInfo(bindTime=1718292462000, brandName='MG', colorName='Andes Grey', isActivate=False, isCurrentVehicle=True, isSubaccount=False, modelName='EH32 X8', modelYear='2023', name=None, series='EH32 L', vin='', subAccountList=[], vehicleModelConfiguration=[VehicleModelConfiguration(itemCode='J17', itemName='Tire', itemValue='1'), VehicleModelConfiguration(itemCode='Q00', itemName='Airbag', itemValue='1'), VehicleModelConfiguration(itemCode='Q01', itemName='FAirbag', itemValue='1'), VehicleModelConfiguration(itemCode='Q09', itemName='AirbagS', itemValue='1'), VehicleModelConfiguration(itemCode='S35', itemName='Sunroof', itemValue='0'), VehicleModelConfiguration(itemCode='S61', itemName='Remote control', itemValue='1'), VehicleModelConfiguration(itemCode='T11', itemName='AC', itemValue='1'), VehicleModelConfiguration(itemCode='EPS', itemName='EPS', itemValue='1'), VehicleModelConfiguration(itemCode='SA64', itemName='SA64', itemValue='0111110000000000001000000100101000000010100000000000000000000110'), VehicleModelConfiguration(itemCode='BONNUT', itemName='BONNUT', itemValue='1'), VehicleModelConfiguration(itemCode='DOOR', itemName='DOOR', itemValue='1111'), VehicleModelConfiguration(itemCode='BOOT', itemName='BOOT', itemValue='1'), VehicleModelConfiguration(itemCode='ENGINE', itemName='ENGINE', itemValue='1'), VehicleModelConfiguration(itemCode='EV', itemName='EV', itemValue='0'), VehicleModelConfiguration(itemCode='HeatedSeat', itemName='HeatedSeat', itemValue='0'), VehicleModelConfiguration(itemCode='KEYPOS', itemName='KEYPOS', itemValue='0'), VehicleModelConfiguration(itemCode='ENERGY', itemName='ENERGY', itemValue='1'), VehicleModelConfiguration(itemCode='BATTERY', itemName='BATTERY', itemValue='1'), VehicleModelConfiguration(itemCode='INTEMP', itemName='INTEMP', itemValue='1'), VehicleModelConfiguration(itemCode='EXTEMP', itemName='EXTEMP', itemValue='1'), VehicleModelConfiguration(itemCode='WINDOW', itemName='WINDOW', itemValue='0000'), VehicleModelConfiguration(itemCode='LRD', itemName='LRD', itemValue='1'), VehicleModelConfiguration(itemCode='BTKEY', itemName='BTKEY', itemValue='1'), VehicleModelConfiguration(itemCode='BType', itemName='Battery', itemValue='2'), VehicleModelConfiguration(itemCode='SBH', itemName='SBH', itemValue='1'), VehicleModelConfiguration(itemCode='BHI', itemName='BHI', itemValue='1'), VehicleModelConfiguration(itemCode='ROV', itemName='ROV', itemValue='25857')])]
2024-11-15 09:48:52.594 DEBUG (MainThread) [custom_components.mg_saic] Vehicle Status: VehicleStatusResp(basicVehicleStatus=BasicVehicleStatus(batteryVoltage=127, bonnetStatus=0, bootStatus=0, canBusActive=1, clstrDspdFuelLvlSgmt=0, currentJourneyId=836, currentJourneyDistance=20, dippedBeamStatus=0, driverDoor=0, driverWindow=0, engineStatus=0, extendedData1=102, extendedData2=0, exteriorTemperature=4, frontLeftSeatHeatLevel=0, frontLeftTyrePressure=56, frontRightSeatHeatLevel=0, frontRightTyrePressure=56, fuelLevelPrc=0, fuelRange=20460, fuelRangeElec=20460, handBrake=0, interiorTemperature=8, lastKeySeen=0, lockStatus=1, mainBeamStatus=0, mileage=47300, passengerDoor=0, passengerWindow=1, powerMode=0, rearLeftDoor=0, rearLeftTyrePressure=56, rearLeftWindow=1, rearRightDoor=0, rearRightTyrePressure=56, rearRightWindow=1, remoteClimateStatus=0, rmtHtdRrWndSt=0, sideLightStatus=0, steeringHeatLevel=None, steeringWheelHeatFailureReason=None, 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=1731664129, wayPoint=GpsPosition.WayPoint(hdop=13, heading=0, position=GpsPosition.WayPoint.Position(altitude=55, latitude=51488795, longitude=-3361226), satellites=8, speed=0)), statusTime=1731664129)
2024-11-15 09:48:52.594 DEBUG (MainThread) [custom_components.mg_saic] Vehicle Charging Data: ChrgMgmtDataResp(chrgMgmtData=ChrgMgmtData(bmsAdpPubChrgSttnDspCmd=0, bmsAltngChrgCrntDspCmd=0, bmsChrgCtrlDspCmd=0, bmsChrgOtptCrntReq=511, bmsChrgOtptCrntReqV=1, bmsChrgSpRsn=0, bmsChrgSts=0, bmsDsChrgSpRsn=0, bmsEstdElecRng=2046, bmsOnBdChrgTrgtSOCDspCmd=0, bmsPackCrnt=65535, bmsPackCrntV=1, bmsPackSOCDsp=1023, bmsPackVol=4095, bmsPTCHeatReqDspCmd=0, bmsPTCHeatResp=0, bmsPTCHeatSpRsn=None, bmsReserCtrlDspCmd=0, bmsReserSpHourDspCmd=30, bmsReserSpMintueDspCmd=62, bmsReserStHourDspCmd=30, bmsReserStMintueDspCmd=62, ccuEleccLckCtrlDspCmd=0, ccuOffBdChrgrPlugOn=0, ccuOnbdChrgrPlugOn=0, chrgngAddedElecRng=0, chrgngAddedElecRngV=0, chrgngDoorOpenCnd=0, chrgngDoorPosSts=0, chrgngRmnngTime=1023, chrgngRmnngTimeV=1, chrgngSpdngTime=0, chrgngSpdngTimeV=0, clstrElecRngToEPT=2046, disChrgngRmnngTime=1023, disChrgngRmnngTimeV=1, imcuChrgngEstdElecRng=2046, imcuChrgngEstdElecRngV=1, imcuDschrgngEstdElecRng=4095, imcuDschrgngEstdElecRngV=1, imcuVehElecRng=2046, imcuVehElecRngV=1, onBdChrgrAltrCrntInptCrnt=0, onBdChrgrAltrCrntInptVol=0), rvsChargeStatus=RvsChargeStatus(chargingDuration=0, chargingElectricityPhase=None, chargingGunState=0, chargingPileID=None, chargingPileSupplier=None, chargingType=0, endTime=1731649131, extendedData1=None, extendedData2=None, extendedData3=None, extendedData4=None, fotaLowestVoltage=None, fuelRangeElec=20460, lastChargeEndingPower=669, mileage=47300, mileageOfDay=20, mileageSinceLastCharge=20, powerUsageOfDay=15, powerUsageSinceLastCharge=0, realtimePower=742, startTime=1731631137, staticEnergyConsumption=None, totalBatteryCapacity=725, workingCurrent=65535, workingVoltage=4095))
2024-11-15 09:48:52.594 DEBUG (MainThread) [custom_components.mg_saic] Finished fetching MG SAIC data update coordinator data in 14.072 seconds (success: True)
2024-11-15 09:48:52.598 INFO (MainThread) [custom_components.mg_saic] Data update triggered for VIN: 

Hi @eximo84

Which version of the integration are you using? The 102,3% battery state should not be happening anymore, with the latest releases.

On the update intervals, there is no way in MG to know if the charging as started or stopped, so there's no way to setup a trigger to update the data in case the charging has been done and you drove away. I hear from MG that they are working on notifications to be sent on the APP, but so far they did not get that going.

The problem is that you will be dependent on the time updates and you may (or not) get the updated data in time, depending on the generic responses.

I'm sorry, but on that end I cannot do much. You may change the update intervals in the integration configuration, but very small intervals may result on the 12v battery being drain.

Check release 0.4.7 and let me know if the 102.3% SOC gets sorted (which should be the case).

im using 0.4.5 - agree that issue was fixed. If i reload the integration or restart HA the battery is reported fine. It only sets it to 102% if i press the new refresh button :)

Sorry, i have missed an update as HACS doesnt show updates for this custom repo. Let me update and recheck.

Agree there is nothing that can be done, im ok with updating once a day to avoid the 12v drain or when im plugged in. The MG app is terrible so what you have done with the integration is great.

It only sets it to 102% if i press the new refresh button :)

This was fixed on 0.4.6.

Sorry, i have missed an update as HACS doesnt show updates for this custom repo. Let me update and recheck.

Check now the 0.4.7 and let me know if it does work fine now.

Yeah, it's true. There are a lot of missed things on MG APP and the APi as well. Let's see if they improve something with time.