ad-ha / mg-saic-ha

MG SAIC Custom Integration for Home Assistant
MIT License
2 stars 0 forks source link

SOC not showing in HA #6

Closed wj-brown closed 1 week ago

wj-brown commented 1 week ago

Hi,

Set up the integration via HACS - logged in fine and has pulled through number of sensors, however I'm missing State of Charge. Car is a MG ZS EV (fully electric). Have run debug per the comments on the HA community page and have noted that vehicle type on the output is ICE rather than BEV which I'm assuming is causing the SOC sensor to not be added to HA.

I don't really know coding but the way the vehicle type is classified makes sense so I think this may be an issue caused by the data on the SAIC/MG side.

Attached the log output. Just let me know if you need anything further. Thanks for creating the integration, looking forward to hopefully getting SOC sensor working.

home-assistant_2024-09-18T21-17-59.097Z.log

ad-ha commented 1 week ago

Hi @wj-brown

Thanks for this. Let me have a look and will let you know.

In the meanwhile, can you try to reload the integration? During my tests, the same happened to me, as a Marvel R Electric came as a PHEV because the MG API reports wrong data on the vehicle type (mine, is Electric but for MG API it is not, as the API returns a 0 on the Electric check).. Odd things from MG/SAIC. That's why I had to add an additional check for "Electric" in the name.

Try to reload and see if it changes on new data check. Thanks

ad-ha commented 1 week ago

And found it. Looking into your log, it happens the same as myself: with the EV check from the API.

VehicleModelConfiguration(itemCode='EV', itemName='EV', itemValue='0'),

The issue is that your model name does not mention Electric on it. Although, having Battery and so forth the integration should mark it as a PHEV.

Again, try to reload the integration and see if it works.

I will try to mess a bit around and see if there is a way that I can make this check into the configuration process and get the user to correct any issue during the setup process. Although, that will take me a while to figure it out.

If not, I will try to add additional checks based on the data available.

Let me know if reloading resulted in any change.

wj-brown commented 1 week ago

Hi @ad-ha

Reloaded the integration and no change unfortunately. Also tried logging back into the MG iSmart app then reloading to see if it did anything but no change.

Don't know if it will help but in the Vehicle Charging Data bmsPackSOCDsp=774 is the current state of charge of the battery - it's 77% at the moment.

Will be taking the car out tomorrow so will see if running it for a bit triggers any changes and will let you know.

ad-ha commented 1 week ago

HI @wj-brown

Thanks for checking. I guess that not having anything mentioning "Electric" on the name results as the integration not identifying the model as electric. The issue is on MG for not being providing the data correctly.

I will check the API and see if I find a workaround.

Don't know if it will help but in the Vehicle Charging Data bmsPackSOCDsp=774 is the current state of charge of the battery - it's 77% at the moment.

That's where the integration is looking for the SOC. The thing is that I've tried to get the sensors to be related to the vehicle type, so, for example, a BEV would not have a Fuel Level or Fuel Range sensor showing with a 0 value. The same for an ICE, that does not need a SOC sensor. IN hindsight maybe I added an additional complexity layer, but I thought that it would be better for the users... until is not and MG does not record their vehicles correctly.

Let me see if in the upcoming days I am able to find a solution for the matter.

Thanks for the feedback

ad-ha commented 1 week ago

Hi @wj-brown

Just released a new version addressing what I commented yesterday. I found a way to easily add an additional step to the configuration so you may select the correct vehicle type.

You will need to remove the integration and add it again. Check if it works that way and let me know.

Thanks again for the help.

wj-brown commented 1 week ago

Hi @ad-ha

Updated and added again - works perfectly.

Thanks so much

ad-ha commented 1 week ago

Glad it did work out.

Hope you enjoy it.

Cheers