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

publish charge rate to MQTT #4130

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mat1990dj
Copy link

User @jonnylangefeld had implemented some changes in order to capture the charge_rate. I think this data is crucial in being able to accurately calculate the charging efficiency, in summer for instance I can be "charging" at 7kW at home and teslamate reports 7kW, but due to cooling I'm in fact not charging as the charge_rate is 0 because the car is using all the energy for HVAC.
I did get the changes that were done on a previous unfinished PR and I'm just getting knowledge on how the project works behind the scenes so any comments are appreciated, I'll do my best.

User @jonnylangefeld had implemented some changes in order to capture the charge_rate. I think this data is crucial in being able to accurately calculate the charging efficiency, in summer for instance I can be "charging" at 7kW at home and teslamate reports 7kW, but due to cooling I'm in fact not charging as the charge_rate is 0 because the car is using all the energy for HVAC.
Copy link

netlify bot commented Aug 7, 2024

Deploy Preview for teslamate ready!

Name Link
🔨 Latest commit f7faba7
🔍 Latest deploy log https://app.netlify.com/sites/teslamate/deploys/66cc795d701b310009475bae
😎 Deploy Preview https://deploy-preview-4130--teslamate.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JakobLichterfeld JakobLichterfeld added area:dashboard Related to a Grafana dashboard area:teslamate Related to TeslaMate core enhancement New feature or request and removed area:dashboard Related to a Grafana dashboard labels Aug 8, 2024
@JakobLichterfeld JakobLichterfeld changed the title Re add changes for charge_rate publish charge rate to MQTT Aug 8, 2024
Copy link
Collaborator

@JakobLichterfeld JakobLichterfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your effort. Really nice first PR!
Love that you added the corresponding test as well.

@@ -120,6 +120,7 @@ defmodule TeslaMate.ImportTest do
address_id: nil,
cost: nil,
duration_min: 70,
charge_rate: decimal(123),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if 123 is a realistic charge rate

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, if configured in km it would be an equivalent ~17kW

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then charge_rate is not a self explaining variable name. duration_min is clear, but charge_rate is not.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the rate in distance/time et which you're effectively charging, it has the same name in the API. It's the number that gets displayed when you switch your cars battery level to distance.

@@ -43,6 +43,7 @@ defmodule TeslaMate.Vehicles.Vehicle.ChargingTest do
date: _,
charge_energy_added: 0.1,
rated_battery_range_km: 1.61,
charge_rate: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with a charge_rate of 0 no energy would have been added, innit?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If plugged into a charger and using more energy to precondition the cabin than the charger can supply, charge rate becomes 0 when charging. This is why I want to track this specifically.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah understood, but I do want to introduce a separate test case for this.

@@ -54,6 +55,7 @@ defmodule TeslaMate.Vehicles.Vehicle.ChargingTest do
date: _,
charge_energy_added: 0.2,
rated_battery_range_km: 3.22,
charge_rate: 2,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these values should set to realisitc values

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're , 2km/h would be equivalent to 300w, attached you can see a 32Amp pull from a charger (7.4kW) but as preconditioning is on, only mere 240W are going to the battery (1 mi/h in this case)
IMG_2895

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as before, charge_rate unit is not obvious

@@ -64,6 +66,7 @@ defmodule TeslaMate.Vehicles.Vehicle.ChargingTest do
date: _,
charge_energy_added: 0.3,
rated_battery_range_km: 4.83,
charge_rate: 10,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these values should set to realisitc values

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before, realistic value of preconditioning lowering requirement

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as before

@@ -76,6 +79,7 @@ defmodule TeslaMate.Vehicles.Vehicle.ChargingTest do
date: _,
charge_energy_added: 0.4,
rated_battery_range_km: 6.44,
charge_rate: 10,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these values should set to realisitc values

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as before

@@ -316,6 +317,7 @@ defmodule TeslaMateWeb.CarControllerTest do
charging_state: "Charging",
charge_energy_added: "4.32",
ideal_battery_range: 200,
charge_rate: 123,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if 123 is a realistic charge rate

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comments

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as before

@@ -263,6 +263,7 @@ defmodule TeslaMateWeb.CarControllerTest do
charger_voltage: 229,
charger_actual_current: 16,
battery_range: 200,
charge_rate: 123,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if 123 is a realistic charge rate

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comments

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as before

Copy link
Collaborator

@JakobLichterfeld JakobLichterfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then charge_rate is not a self explaining variable name. duration_min is clear, but charge_rate is not.

@mat1990dj
Copy link
Author

Then charge_rate is not a self explaining variable name. duration_min is clear, but charge_rate is not.

Being the variable name in the API, isn't it best to keep it the same? How would you name it better?

Add charge_rate to logger
@mat1990dj
Copy link
Author

Is there anything I can do to improve the PR? Would you change the variable name? I used what tesla uses on https://developer.tesla.com/docs/fleet-api/endpoints/vehicle-endpoints#vehicle-data
Being a variable that describes the rate in distance at which you're currently charging, would actual_charging_rate be more meaningfull?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:teslamate Related to TeslaMate core enhancement New feature or request waiting for feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants