Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charging Binary Sensor Not Working - Ariya #77

Closed
RGx01 opened this issue Nov 13, 2024 · 44 comments · Fixed by #79 or #90
Closed

Charging Binary Sensor Not Working - Ariya #77

RGx01 opened this issue Nov 13, 2024 · 44 comments · Fixed by #79 or #90
Assignees
Labels
bug Something isn't working

Comments

@RGx01
Copy link

RGx01 commented Nov 13, 2024

What happened?
Since release 0.7.0 Binary Sensor Charging does not report charging when charging. Also noting a high number of "Error communicating with API" in logs.

To Reproduce
Charge an Ariya and check sensor status after polling.

Expected behavior
Binary Sensor should report Charging whilst charging.

Log Output
2024-11-13 16:48:01.491 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Poll Coordinator data in 0.321 seconds (success: True)
2024-11-13 16:48:03.748 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Update Coordinator data in 2.258 seconds (success: True)
2024-11-13 16:48:09.628 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Statistics Coordinator data in 2.410 seconds (success: True)
2024-11-13 17:03:03.066 WARNING (MainThread) [custom_components.nissan_connect.coordinator] Error communicating with API
2024-11-13 17:03:03.067 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Update Coordinator data in 0.025 seconds (success: True)
2024-11-13 17:18:03.766 WARNING (MainThread) [custom_components.nissan_connect.coordinator] Error communicating with API
2024-11-13 17:18:03.767 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Update Coordinator data in 0.725 seconds (success: True)
2024-11-13 17:33:03.066 WARNING (MainThread) [custom_components.nissan_connect.coordinator] Error communicating with API
2024-11-13 17:33:03.066 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Update Coordinator data in 0.024 seconds (success: True)
2024-11-13 17:48:01.458 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Poll Coordinator data in 0.288 seconds (success: True)
2024-11-13 17:48:02.841 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Update Coordinator data in 1.383 seconds (success: True)
2024-11-13 17:48:02.844 DEBUG (MainThread) [custom_components.nissan_connect.sensor] Updating odometer state
2024-11-13 17:48:11.138 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Statistics Coordinator data in 1.919 seconds (success: True)
2024-11-13 18:03:02.678 WARNING (MainThread) [custom_components.nissan_connect.coordinator] Error communicating with API
2024-11-13 18:03:02.678 DEBUG (MainThread) [custom_components.nissan_connect.coordinator] Finished fetching Update Coordinator data in 0.636 seconds (success: True)

Home Assistant Version
Core
2024.11.1
Supervisor
2024.11.2
Operating System
13.2
Frontend
20241106.2

Integration Version
v0.7.0

Additional context
polling interval = 60
polling interval while charging = 15
update interval = 15
update interval for stats = 60

@RGx01 RGx01 added the bug Something isn't working label Nov 13, 2024
@dan-r
Copy link
Owner

dan-r commented Nov 16, 2024

The errors communicating with the API seems to be some sort of Nissan issue that I'm getting too.

Does the plugged in sensor update correctly?

@RGx01
Copy link
Author

RGx01 commented Nov 17, 2024

Not 100% sure as I've rolled back to v0.6.0.

My primary use case for using this sensor is to determine which utility meter bucket to put the consumed energy in as we have several vehicles. If I get time this week I'll roll back up and see if I could also use plugged in sensor to do the same job.

@adammccormack162
Copy link

Ive got the same issue...

Yes, the plugged in sensor updates correctly on 0.7 - but the charging state doesnt show

@dan-r
Copy link
Owner

dan-r commented Nov 22, 2024

I appreciate this is a bit annoying, but could one (or both) of you please install v0.7.1-beta.2 before your next charge. You'll see in the log messages like this:
2024-11-22 10:16:57.545 WARNING (SyncWorker_12) [custom_components.nissan_connect.kamereon.kamereon] FetchBatteryStatusAriya: {'lastUpdateTime': '2024-11-22T10:12:10Z', 'timeRequiredToFullSlow': 330, 'timeRequiredToFullNormal': 180, 'timeRequiredToFullFast': 90, 'batteryLevel': 92, 'batteryBarLevel': 223, 'rangeHvacOn': 196, 'rangeHvacOff': 203, 'plugStatus': 0, 'chargeStatus': 0, 'chargePower': 1, 'batteryCapacity': 40000}

If possible, can you please grab one of these messages when you are charging and one when you are not.

Thanks in advance!

@adammccormack162
Copy link

FetchBatteryStatusAriya: {'lastUpdateTime': '2024-11-22T10:50:07Z', 'batteryLevel': 77, 'batteryTemperature': 0, 'batteryAutonomy': 196, 'plugStatus': 0, 'chargingStatus': 0.0, 'chargingRemainingTime': 68, 'batteryCapacity': 63, 'batteryAvailableEnergy': 44, 'rangeHvacOn': 0, 'rangeHvacOff': 0}

FetchBatteryStatusAriya: {'lastUpdateTime': '2024-11-22T11:08:50Z', 'batteryLevel': 77, 'batteryTemperature': 0, 'batteryAutonomy': 196, 'plugStatus': 1, 'chargingStatus': 0.0, 'chargingRemainingTime': 97, 'batteryCapacity': 63, 'batteryAvailableEnergy': 44, 'rangeHvacOn': 0, 'rangeHvacOff': 0}

@dan-r
Copy link
Owner

dan-r commented Nov 28, 2024

Thats really strange - chargingStatus is what I'd expect to update but it doesnt seem to.

Do any of your logs show chargingStatus to be anything other than 0?

@adammccormack162
Copy link

I'd have to check the old version - to see what was coming out on that... (assuming thats what you meant) - but it must do - as it was updating the status to charging

@dan-r dan-r closed this as completed in #79 Dec 5, 2024
@dan-r dan-r reopened this Dec 5, 2024
@pusur333
Copy link

My does also not change. Can I be in any help with logs etc or have you seen the error?

@RGx01
Copy link
Author

RGx01 commented Feb 17, 2025

@dan-r do you need anything to help get a resolution to this?

@dan-r
Copy link
Owner

dan-r commented Feb 18, 2025

Apologies - I haven't had the time to look into this. It could really do with a developer who owns an Ariya looking at it :)

The root of the issue is that the changes I made in 0.7.0 (should?) fix the range not showing for the Ariya but seem to have also broken charging binary sensor. This change was to use a different API endpoint to the Leaf.

It seems like we actually need to be hitting both endpoints to keep both working.

@RGx01
Copy link
Author

RGx01 commented Feb 18, 2025

Apologies - I haven't had the time to look into this. It could really do with a developer who owns an Ariya looking at it :)

The root of the issue is that the changes I made in 0.7.0 (should?) fix the range not showing for the Ariya but seem to have also broken charging binary sensor. This change was to use a different API endpoint to the Leaf.

It seems like we actually need to be hitting both endpoints to keep both working.

Thanks @dan-r. I wish I could help but I'm not a dev :| I'm just worried that at some point v0.6 will end up being deprecated/left behind. I appreciate the work you've done so far.

@dan-r
Copy link
Owner

dan-r commented Feb 18, 2025

I'll try to get a beta out over the weekend and put a message here when its done. Might take a bit of back and forth but shouldn't take too long

@dan-r
Copy link
Owner

dan-r commented Feb 18, 2025

@RGx01 would you mind trying v0.7.4-beta.1?

@RGx01
Copy link
Author

RGx01 commented Feb 18, 2025

@dan-r looking good so far. I'd like to see what happens when the charge finishes (that won't happen until tomorrow)

Image

@dan-r
Copy link
Owner

dan-r commented Feb 18, 2025

Not a problem, just let me know. Do the range sensors work for you too?

@RGx01
Copy link
Author

RGx01 commented Feb 18, 2025

Not a problem, just let me know. Do the range sensors work for you too?

no they don't

Image Image

@RGx01
Copy link
Author

RGx01 commented Feb 19, 2025

@dan-r
Ariya Plugged in and Ariya Charging seem to reflect each other. The Zappi sensor says the EV is still plugged in (which it is). Not a deal breaker for me though.

Image

@wralb
Copy link

wralb commented Feb 19, 2025

I also tried this beta last night, here are my observations (I'm guessing some of this might be expected in this test version):

Car: Nissan Ariya 2022

V0.7.3 - All Ariya sensors provide values except binary_sensor.ariya_charging which shows as unknown
For the avoidance of doubt, the following sensors do provide data in the current production release:

  • binary_sensor.ariya_plugged_in accurately tracks plugged in status
  • sensor.ariya_range_ac_on and sensor.ariya_range_ac_off provide values (the same value - as expected in the code).
  • sensor.ariya_charge_time_3kw & sensor.ariya_charge_time_6kw provide values (the same value - as expected in the code) - not sure what they actually represent.

V0.7.4 beta-1 - Several sensors are now missing and 'Plugged In' is no-longer accurate.

  • binary_sensor.ariya_charging accurately tracks charging status -
  • binary_sensor.ariya_plugged_in is inaccurate, it mirrors binary_sensor.ariya_charging exactly
  • sensor.ariya_range_ac_on , sensor.ariya_range_ac_off, sensor.ariya_charge_time_3kw & sensor.ariya_charge_time_6kw all now show as unknown.

It looks like some blend of the two versions could provide values for all sensors.

The images below show the status of using each of the versions; the first is the beta, the second is production.

Image

Image

@dididu
Copy link

dididu commented Feb 21, 2025

I'd like to confirm @RGx01 's findings.
Ariya - I am observing exactly same issues with versions.

@dan-r
Copy link
Owner

dan-r commented Feb 21, 2025

Thanks all, I appreciate your time getting this right! How about with v0.7.4-beta.2?

There's a really weird mix here. So pre v0.7.0 everything came from the 'Leaf' endpoint. In v0.7.0 I moved everything to the 'Ariya' endpoint if you drive an Ariya.

So now, for the Ariya, everything comes from the 'Leaf' endpoint except for the following which come from the 'Ariya' endpoint:

  • Range remaining
  • Charging speed/times
  • Plugged in status

I think I've managed to capture everything from your feedback, but let me know how it works for you.

@RGx01
Copy link
Author

RGx01 commented Feb 21, 2025

Thanks @dan-r , I've put the beta 2 on but the Ariya won't be back till Monday.

Thanks also to @wralb, your analysis was spot on 👍

@dididu
Copy link

dididu commented Feb 21, 2025

Looking at v0.7.4-beta.2

Unplugged - looking good:
Image

Plugged in but not charging - looking good, although it took a bit of time to show "plugged in"
Image

Charging - also looking good

Image

@dan-r
Copy link
Owner

dan-r commented Feb 21, 2025

Good to hear its looking good. From experience, I think the service in general is just pretty slow.

So for the range and charge times, there's only one value for the Ariya whereas the Leaf splits them both out into AC on/off and 3kw/6kw.

Charge times seem to change based on if its charging or not, so no idea there. For the range, I'd rather just provide one sensor - do you know whether it looks like the AC on or the AC off range?

@dididu
Copy link

dididu commented Feb 21, 2025

Good shout @dan-r about reducing duplication.
I just got the car this month and here in Scotland driving with no AC in Feb is bonkers, so no idea. But given the fact that Ariya has a heat pump, I don't think the difference is going to be that big.

@dan-r
Copy link
Owner

dan-r commented Feb 21, 2025

@dididu I'm leaning towards taking that value as AC On, but would you mind checking the range from in the car with heating/cooling on and seeing if it is? For my Leaf (with heat pump) there's only 2 miles difference currently so not a big deal really.

@dididu
Copy link

dididu commented Feb 21, 2025

@dan-r Ariya doesn't change the GOM with AC on/off. Should have said it in the initial message. :)

@dan-r
Copy link
Owner

dan-r commented Feb 21, 2025

Ah - that explains the one value then, thanks for that!

@wralb
Copy link

wralb commented Feb 21, 2025

Thanks @dan-r

I agree on Range... I see little difference with AC on or Off neither numerically nor practically. We can definitely simplify the sensors for Ariya.

I also have some observations of "Charge Time", see later.

I made a little test plan and did a sneaky charge... I can corroborate the results from: @dididu as shown here:

Image

Regarding charge time, for the first time I think I understand it. It seems that the value returned by the API is adaptive according to actual charging current, with some sort of default high-current value when unplugged. This is what happened today, The big jump up happens at charge-start, and the big drop at unplugging. So, charge time is only really useful during a charge, and there should certainly only be one sensor for the Ariya, perhaps "Charge Time (adaptive)"?

Image

@dan-r
Copy link
Owner

dan-r commented Feb 21, 2025

Thanks for that testing, its really helpful! I've released a new beta that shouldn't change anything except:

  1. Only one range number
  2. Only one charge speed number

Would you mind testing it out over the weekend? - I'll do the same to make sure I haven't messed up anything for the Leaf/non-Ariyas.

@natterangell
Copy link

Unlike @dididu, I still get unknown on several of the sensors, even on v.0.7.4-beta.2.

I should note that the car is brand new (2024 model, FE0-24, Norway), I've had it for less than 24 hours and haven't charged it yet. But the official NissanConnect app shows both estimated range and last updated fields.

Image

@dan-r
Copy link
Owner

dan-r commented Feb 22, 2025

@natterangell what about beta 3?

@wralb
Copy link

wralb commented Feb 22, 2025

@dan-r Thanks. We're nearly there I think.

Here are my observations of beta2 vs. beta3.

  • Range (AC off) and Charge Time (3 kW) are no-longer exposed - Great
  • Range (AC on) - correctly displays the (single value the Ariya exposes) for range. - Great
  • Charge Time (6 kW) is still exposed, but now has the value 'unknown' - ??
  • No new "Charge Time" sensors are exposed

I, therefore, cannot see a sensor that exposes Range, unlike in beta 2. I'm not sure what your intention was... to re-use Charge Time (6 kW) or to add a new "Charge Time" sensor, but whichever, it doesn't seem to have quite worked:

Image

@natterangell
Copy link

beta 3 is as follows. "Last updated" and both range estimates is unknown, charge time is unavailable (which might be correct when the car is not connected?).

Image

@natterangell
Copy link

natterangell commented Feb 22, 2025

No, wait. Three sensors were no longer provided by the integration. The following is correct on beta 3 for me, so it seems identical to what @wralb got, except "Range (AC ON)" and "Last updated" are unknown for me. Plus I don't have a "charge time" sensor anymore. The car has only been active in Nissan's systems for about 24 hour, maybe data needs to propagate somehow(?)

Image

@dan-r
Copy link
Owner

dan-r commented Feb 22, 2025

@wralb oops, my bad, typo in the code. How about now with beta 4?

@natterangell odd that it isnt working for you... In beta 4 I've added something in to fallback to the Leaf endpoint if the Ariya one doesnt provide anything. Mind trying this?

@natterangell
Copy link

Hmm. I don't see any difference.

Image

@wralb
Copy link

wralb commented Feb 23, 2025

@dan-r Looks good now.

Comparing beta-3 to beta-4:

  • Charge Time (6kW) no-longer is exposed
  • Charge Time (adaptive) is now available with the expected value
  • All other sensors, as you kindly sorted through these betas, are available and have sensible values

Image

@dididu
Copy link

dididu commented Feb 23, 2025

@dan-r Morning.
On beta-4 we got a situation this morning.
NissanConnect app shows battery % fine.

Image

@dan-r
Copy link
Owner

dan-r commented Feb 23, 2025

@dididu hm that's very strange. Would you mind downgrading to 0.6.x temporarily and letting me know if the battery percentage shows for that? If so, it'll be an easy fix, if not it'll require some more investigation.

@natterangell
Copy link

Is there some pattern to why certain sensors only show values for some users? Could there be API-differences between car firmware versions? As previously, I have a 2024 model firmware verison FE0-24.

@dididu
Copy link

dididu commented Feb 23, 2025

@dididu hm that's very strange. Would you mind downgrading to 0.6.x temporarily and letting me know if the battery percentage shows for that? If so, it'll be an easy fix, if not it'll require some more investigation.

Looks like after some driving the battery percentage value appeared again. Same beta4 version.
It look likely that NissanConnect app just carries the last known value forward, while the integration returns 'unknown' if the api returned nothing. Maybe the integration should persist the last known value to carry it forward as well.

@dan-r
Copy link
Owner

dan-r commented Feb 23, 2025

@wralb glad its working for you now!

@natterangell I'm really not sure on this one - I wouldn't have thought it would differ. All supported Leaf models seem to use the same API and present the same data.

@dididu do you see any errors in the logs?

@RGx01
Copy link
Author

RGx01 commented Feb 24, 2025

Image

looking good

@dan-r
Copy link
Owner

dan-r commented Feb 24, 2025

Right it looks like for most of you the values are now being provided. I've released v0.7.4 stable now (exactly the same code as beta 4 though).

Because this issue is getting quite long, I'll close it now. If any of you are still having issues, could you please raise it as a new issue with any relevant logs and screenshots. Thank you

@dan-r dan-r mentioned this issue Feb 24, 2025
@dan-r dan-r closed this as completed in #90 Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
7 participants