gboudreau / LEAF_Carwings_EasyAccess

One-click access to LEAF Carwings remote actions
16 stars 9 forks source link

2017 Leaf - getting Battery: 160/12 (1333%) #3

Closed dlarue closed 7 years ago

dlarue commented 7 years ago

Is this because I have a 30KWh battery or is there a place to set this up for a more accurate %? Nissan Connect web page shows 71% charged.

gboudreau commented 7 years ago

Maybe; never saw a value above 12.

You should be able to simply change the two 12 found on this line: https://github.com/gboudreau/LEAF_Carwings_EasyAccess/blob/master/status.php#L14

Just check the status when you are at 100% to find the value to use. (225 maybe?)

dlarue commented 7 years ago

it worked! I noticed it was at 75% now and I saw 1500% so I doubled 12 to 24 and added a factor of 10( 240).

Now to see if I can add a "Stop Charge" option. I'd like to work towards a 'Stop Charge at xx%'.

Thanks.

jeremyakers commented 7 years ago

It's 240 on the 2016+ leaf with 30kw battery.

But in the newer leafs you can get the exact battery SoC and don't need to use the x/12 or y/240 to determine percentage.

-Jeremy

On Aug 17, 2017 1:56 PM, "Guillaume Boudreau" notifications@github.com wrote:

Maybe; never saw a value above 12.

You should be able to simply change the two 12 found on this line: https://github.com/gboudreau/LEAF_Carwings_EasyAccess/blob/ master/status.php#L14

Just check the status when you are at 100% to find the value to use. (225 maybe?)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gboudreau/LEAF_Carwings_EasyAccess/issues/3#issuecomment-323163049, or mute the thread https://github.com/notifications/unsubscribe-auth/ANDiTgc7Rg4Shgc9l01JL9JE60p_8BNKks5sZIzXgaJpZM4O6oBP .

dlarue commented 7 years ago

Thanks @jeremyakers! I'm still new to the Leaf and this process of gaining access to the vehicle remotely. If you happen to have a link to the API where I can read about getting and setting things please post. Thanks again.

jeremyakers commented 7 years ago

There's no docs for the API, but there are a number of folks (Myself included) who have reverse engineered it by sniffing traffic from the mobile app.

I've posted most of my findings to this thread: http://www.mynissanleaf.com/viewtopic.php?f=31&t=20576

-Jeremy

On Thu, Aug 17, 2017 at 2:09 PM, Doug LaRue notifications@github.com wrote:

Thanks @jeremyakers https://github.com/jeremyakers! I'm still new to the Leaf and this process of gaining access to the vehicle remotely. If you happen to have a link to the API where I can read about getting and setting things please post. Thanks again.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gboudreau/LEAF_Carwings_EasyAccess/issues/3#issuecomment-323166493, or mute the thread https://github.com/notifications/unsubscribe-auth/ANDiTj__1sANQJaLn8N0l_pPgxM7SSpyks5sZJAEgaJpZM4O6oBP .

dlarue commented 7 years ago

Should this too be a config setting like BATTERY_SIZE?

gboudreau commented 7 years ago

Pretty sure there is something in the API response that could tell us the battery size. Can you try to var_dump($response); in NissanConnect.class.php, around line 170, and send me the result at guillaume@pommepause.com ?

dlarue commented 7 years ago

Looks like if $result->BatteryCapacity is used it works on my model and I saw the SOC listed in that dump:

Battery: <?php echo "$result->BatteryRemainingAmount/$result->BatteryCapacity (" . round($result->BatteryRemainingAmount*100.0/$result->BatteryCapacity) . "%)" ?>


gboudreau commented 7 years ago

Thx. Fixed.

dlarue commented 7 years ago

Great. FYI, I found it interesting that the Leaf software stated 76% SOC while the calculated is 75%. Not a big deal but it is different. On my local copy I added a "reported" value next to the calculated using $result->SOC .

jeremyakers commented 7 years ago

That's because the "calculated" value is probably based on:

"BatteryRemainingAmount" / "BatteryCapacity"

And "BatteryRemainingAmount" moves in increments of 10 up to 240:

10 (10/240=4%), 20 (20/240=8%), 30 (30/240=13%), ... 180 (180/240=75%), ... 230 (230/240=96%), 240 (240/240=100%)

As you can see, the "calculation" moves in increments of roughly 4.16%

There is an additional field (Called "SOC") in the response from only the newer model LEAFs (2015 or 2016+) that gives the exact SoC %. That's what the LEAF app is reporting when you see 76% there. It's more precise than calculating it from the "BatteryRemainingAmount" field but for older LEAFs there was no SOC field so you had to calculate from "BatteryRemainingAmount".

-Jeremy

On Thu, Aug 17, 2017 at 6:42 PM, Doug LaRue notifications@github.com wrote:

Great. FYI, I found it interesting that the Leaf software stated 76% SOC while the calculated is 75%. Not a big deal but it is different. On my local copy I added a "reported" value next to the calculated using $result->SOC .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gboudreau/LEAF_Carwings_EasyAccess/issues/3#issuecomment-323222811, or mute the thread https://github.com/notifications/unsubscribe-auth/ANDiTriM5y9nTATEfTHeR-kgLe_6U947ks5sZM_lgaJpZM4O6oBP .

dlarue commented 7 years ago

With the increment by 10 stepping of BatteryRemainingAmount that makes perfect sense.

I suppose, since so far the the new 30KWh battery and battery ECU and BMS only support that SOC data element, we could use the BatteryCapacity as the trigger to call/use SOC instead of calculating. One would think that Nissan knew they were coming out with a 2018 model while they were doing the 2016/17 updates for the 30KWh battery so the same SOC will be available in all models with a capacity equal to or greater than 240.

And I have had no luck finding an API to turn off the charge.

jeremyakers commented 7 years ago

I'm pretty sure the newer models have the SOC fields even if they have the 24kwh battery. I think it's just a new field in the newer models but some of those newer models may have 24kwh batteries rather than 30kwh.

The 2016 model especially since the S trim had 24kwh but the SV/SL had 30kwh.

On Aug 17, 2017 7:40 PM, "Doug LaRue" notifications@github.com wrote:

With the increment by 10 stepping of BatteryRemainingAmount that makes perfect sense.

I suppose, since so far the the new 30KWh battery and battery ECU and BMS only support that SOC data element, we could use the BatteryCapacity as the trigger to call/use SOC instead of calculating. One would think that Nissan knew they were coming out with a 2018 model while they were doing the 2016/17 updates for the 30KWh battery so the same SOC will be available in all models with a capacity equal to or greater than 240.

And I have had no luck finding an API to turn off the charge.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/gboudreau/LEAF_Carwings_EasyAccess/issues/3#issuecomment-323230056, or mute the thread https://github.com/notifications/unsubscribe-auth/ANDiTsg-UNrEuarl0ZDoU9sTcEpcxZpSks5sZN2QgaJpZM4O6oBP .

dlarue commented 7 years ago

The 2016 SV and SL all got the 30KWh but early S models got the remaining 24KWh batteries and then all models received 30KWh batteries once the 24KWh inventory was depleted. At least that's how it was explained at 2 dealerships while I was hunting for a 2016 with a 30KWh battery. I also read that the Battery ECU and battery pack BMC were unique in the 30KWh batteries and is why it was said no 24KWh battery could be replaced with 30KWh battery. But with the way they did the batteries in the 2016 S models I still would be surprised if those 24KWh batteries were "special" and had the upgraded Batt ECU and BMS.

And all 2017 models got the 30KWh batteries just like the 2018 are supposed to get 40KWh batteries standard.

But as you said, it probably all future models will have the SOC data elements so it's a fair bet that testing for BatteryCapacity >= 240 will result in $response->SOC being valid.

dlarue commented 7 years ago

Learning a bit of PHP.... The "Battery:" line can be replace with this to do both SOC for newer vehicle and calculate on previous models(< 30KWh batteries).

Replace-

Battery: <?php echo "$result->BatteryRemainingAmount/$result->BatteryCapacity (" . round($result->BatteryRemainingAmount*100.0/$result->BatteryCapacity) ."%)" ?>

with-

Battery: <?php function SOC($result) { if ($result->BatteryCapacity < "240") { echo "$result->BatteryRemainingAmount/$result->BatteryCapacity (" . round($result->BatteryRemainingAmount*100.0/$result->BatteryCapacity) ."%)"; } else { echo "SOC ($result->SOC %)"; } } SOC($result); ?>

Results are either: Battery: SOC (76 %) or Battery: 180/240 (75%)