bretterer / home-assistant-rivian

Rivian (Unofficial) Integration for Home Assistant
Apache License 2.0
113 stars 19 forks source link

Thoughts on miles/kwh? #155

Open disruptivepatternmaterial opened 4 months ago

disruptivepatternmaterial commented 4 months ago

As I as I am sure everyone knows the trucks report miles/kwh I the '15 min" view and in the details of the operation of the vehicle. But I cannot figure out how to calculate this from the data this integration returns. Has anyone been able to do that? Thought I would ask before I dig through the code / lib under it to see if this is possible or available...

jrgutier commented 4 months ago

Not directly. You can do some math between batteryCapacity, SOC, and the Odometer sensors to get it.

--

J.R. Gutierrez

On Thu, May 16, 2024 at 9:40 AM disruptive pattern material < @.***> wrote:

As I as I am sure everyone knows the trucks report miles/kwh I the '15 min" view and in the details of the operation of the vehicle. But I cannot figure out how to calculate this from the data this integration returns. Has anyone been able to do that? Thought I would ask before I dig through the code / lib under it to see if this is possible or available...

— Reply to this email directly, view it on GitHub https://github.com/bretterer/home-assistant-rivian/issues/155, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACTMOZ3KCWUJSWPQPF5AFTZCTAOTAVCNFSM6AAAAABH2L3376VHI2DSMVQWIX3LMV43ASLTON2WKOZSGMYDANRQGE4TMMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

AlanJohnWilliams commented 4 months ago

I started playing around with this using Influxdb (FLUX) and Grafana. I've got two dashboards - a status focused dashboard (https://gist.github.com/AlanJohnWilliams/ca789ed2b2313c82369101eb6a36ecc7) and a stats focused dashboard (https://gist.github.com/AlanJohnWilliams/9e6cce34412d3f4eb6b21df197c229c2). Feel free to lift out the FLUX queries I have for mi/kWh.

Some notes on this:

  1. Edit the vehicleName dashboard for the name (entity prefix) for your vehicle. The dashboards should support multiple Rivians in the family.
  2. I have hard coded 130 kWh battery capacity in some spots. I have older Rivian integration data that exists prior to this being reported by the integration. You may need to fix that hard coded if you have standard or max pack.
  3. As for efficiency reporting, the resolution of time points is too sparse to get what you get on the dash. But still useful for trip level perspectives.
  4. Not tested extensively, so let me know if you see anything off.

Stats Dashboard:

image

Status Dashboard:

image
AlanJohnWilliams commented 4 months ago

RE the dashboards, my influxdb and Grafana instances are running outside of Home Assistant (not as plugins). The main thing is you may need to jump through some hoops to enable FLUX on the influxdb plugin.

disruptivepatternmaterial commented 4 months ago

RE the dashboards, my influxdb and Grafana instances are running outside of Home Assistant (not as plugins). The main thing is you may need to jump through some hoops to enable FLUX on the influxdb plugin.

Yeah mine too because everything else in my house dumps into influx (which I cannot stand and am working to move toward a normal database so I can do normal rdbms stuff, like modify data, rename thing, fix mistakes, etc...).

So those dashboards are kind of cool, I will give them a shot. I was hoping someone would have solved the math, because what you need is to look for + and - derivative to detect charging and discharging, then take the max value of the charge in between those intervals. If you have those values you can average them divide the miles by that number and boom you have the same data as the dash. I am a tad perplexed why or how the truck has this data point and clearly knows the lifetime charge but doesnt report it out. Seems vastly more useful and obvious than 80% of the data the API is reporting.

AlanJohnWilliams commented 4 months ago

Yeah, it would be nice if they reported it out directly! I'm still not 100% confident in the underlying data and assumptions made to get the mi/kWh results. In flux I'm able to get diff on the state of charge for each interval and then multiply it by the battery capacity to get the kWh used. I also sum the kW added from charging over the same interval to then calculate the mi/kWh. I calculate mi/kWh overall (includes phantom drain) and also calculate the value specifically associated with vehicle motion which required a bit more work to filter based on power_state and then split the SoC diff between "Go" state and all other states.

tmack8001 commented 4 months ago

why or how the truck has this data point and clearly knows the lifetime charge but doesnt report it out.

Lifetime Efficiency is reported by the truck. We used to have that before an API deprecation and added API authorization removed it from our view since there currently isn't no need for that data within the Android/iOS mobile clients - we only have visibility to the data that these apps have permission to request. The trucks report much more than what we can see.