itchannel/fordpass-ha

BEV - DC Fast Charging kW Not Appearing

Closed this issue · 12 comments

When pulling sensor.fordpass_elvehcharging attribute of Charging kW it will not show a value at all when DC Fast charging. AC charging appears fine. Just DC isn't. This once is particularly useful when monitoring BEV charging.

This happened when using a Tesla station with Plug & Charge. Other data recorded except charging kw and charging amperage.

Are they hiding it in a different attribute? Or somewhere else entirely?

@itchannel or @SquidBytes Any ideas on this one? Seems odd that it won't show any value for the attributes since FordPass itself shows the charge rates. Thinking the data is leaking out somewhere?

That is odd.
Do you know if the Charging Type updated under Charging Status?

I don't DC Fast charge often so I've never really checked.
The way to know would be to DC Fast charge and then try to get the data in the json to see if its missing, or mapped somewhere else. (aka running autonomicData.py while DC Fast charging)

I've had virtually 0 time to look into anything with this integration or any personal projects really.
The last time I poked at things I was hoping to get a Stop/Start Charge button - but I just haven't had time to continue looking into it.

If I DC Fast charge I'll try to grab a json file and see if I can find out what is odd.
Or if you frequently do and are able to provide one that can help.

@SquidBytes Yes, the charging type does actually update correctly. It's odd since even Time Remaining is correct. The only two attributes that are showing 0 during a DC Charge event are charging kW and charging amperage.

I have charged frequently lately since I've taken a few road trips and used the Tesla Superchargers with the NACS adapter. Even a EA station, but as I'm sure you know they are at the bottom of my preferred list.

I am not too familiar with how to grab a json file for it (Pretty new to HA and been a long time since I've scripted anything but HTML / PHP) Any direction there and I can certainly help and see what I can find!

The Charging kW attribute is calculated based on the Voltage and Amperage.
I'm guessing I didn't properly account for DC charging with one of those values because if any of them are 0 - it will default to 0

if "xevBatteryChargerVoltageOutput" in self.data:
    cs["Charging Voltage"] = float(self.data.get("xevBatteryChargerVoltageOutput", {}).get("value", 0))
    ch_volt = cs["Charging Voltage"]

if "xevBatteryChargerCurrentOutput" in self.data:
    cs["Charging Amperage"] = float(self.data.get("xevBatteryChargerCurrentOutput", {}).get("value", 0))
    ch_amps = cs["Charging Amperage"]

# Returning 0 in else - to prevent attribute from not displaying
if "xevBatteryChargerVoltageOutput" in self.data and "xevBatteryChargerCurrentOutput" in self.data:
    if ch_volt != 0 and ch_amps != 0:
        cs["Charging kW"] = round((ch_volt * ch_amps) / 1000, 2)
    else:
        cs["Charging kW"] = 0

So if the amperage is showing 0 then the kW will show 0 because its the kW math is not mathing - it just displays 0.
Which is odd, because I would think DC Charging would still show amperage.
I think I could add a check in there that would check if the plug is connected and then just display it - ignoring the 0 check that is there currently. I'm not sure if that is the proper way to do things (I'm not a programmer, I just poke things) and I put the 0 check in there because it gave errors earlier lol

There is a tutorial on the Wiki about running the autonomicData.py, but it will probably be easier to just add another check to display it and see what happens.

Aw that makes sense for what you were going for there. Yes, it should still show amperage since that is what the vehicle negotiates for power. Voltage should always be pretty close to the same as a charger must match pack voltage to charge and all that good stuff.

If you need me to test anything out. Let me know where to make any changes and what to change to, and I can hit up a DC later today.

@SquidBytes Didn't get a chance to charge, but was just looking and thinking about the issue. I think you're onto something about the checks causing it to drop to 0. With DC charging, I do not think XevBatteryChargerVoltageOutput will show anything since a DC charger will only adjust amps. They would be set to the pack voltage which is XevBatteryVoltage. So when DC charging, it should be XevBatteryVoltage x XevBatteryChargerCurrentOutput instead.

I'll try to DC charge and see if this is in fact true. Will just need to make sure XevBatteryChargerCurrentOutput shows a value.

Yeah, the easiest solution would be to know what those values report when DC charging. Just kinda have to wait to get that data.

Well I got that data for you. So here are some details I found.

While DC Fast Charging, fordpass_elveh attributes for battery show the following numbers:

  • Battery Voltage:365.5
  • Battery Amerage -224.87012
  • Battery Kw -82.19

So it appears the math error is due to the way the car reads DC charging as a negative value instead of positive.

I also found the following in fordpass_metrics attributes

  • xevBatteryIoCurrent: -224.87012
  • xevBatteryVoltage: 365.5
  • xevBatteryChargerCurrentOutput: 0
  • xevBatteryChargerVoltageOutput: 365

So I believe the issue is just it's not displayed because of the negative number error. These numbers are positive when AC charging.

Perfect, thanks for the data.
The issue is the elveh_charging sensor is using xevBatteryChargerCurrentOutput and xevBatteryChargerVoltageOutput to assign the Charging kW line.
If either of those are 0 - it will display as 0 to prevent "division by 0 error"

This works fine for AC charging, but as you have found out - DC Fast charging doesn't update the xevBatteryChargerCurrentOutput instead, the xevBatteryIoCurrent is updated.

This should fix the issue if you want to add this to sensor.py replacing the section it was
It should start at line 366 in sensor.py
Save and restart HomeAssistant and it will be using this code, and you could check next time you charge

 # Returning 0 in else - to prevent attribute from not displaying
  if "xevBatteryChargerVoltageOutput" in self.data and "xevBatteryChargerCurrentOutput" in self.data:
      # AC Charging
      if ch_volt != 0 and ch_amps != 0:
          cs["Charging kW"] = round((ch_volt * ch_amps) / 1000, 2)
      # DC Fast Charging
      elif ch_volt != 0 and batt_amps != 0:
          cs["Charging kW"] = round ((ch_volt * batt_amps) / 1000, 2)
      else:
          cs["Charging kW"] = 0

Perfect, I’ll try that out once the entire integration gets fixed. As it all broke this morning. :(

Regarding you comment here: #488 (comment)

I didn't get a chance to actually add that fix before things broke. I was planning on testing it myself before pushing it but since things broke I figured I would tweaked it some more to ensure it properly works and hopefully avoid any errors or issues.

You can see the new code here - which you can add to your file
master...1.68

Can confirm the DC fix in 1.68 works!