-
Notifications
You must be signed in to change notification settings - Fork 876
Add charge_rate to MQTT broker
#2952
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ defmodule TeslaMate.Vehicles.Vehicle.Summary do | |
| car display_name state since healthy latitude longitude heading battery_level usable_battery_level | ||
| ideal_battery_range_km est_battery_range_km rated_battery_range_km charge_energy_added | ||
| speed outside_temp inside_temp is_climate_on is_preconditioning locked sentry_mode | ||
| plugged_in scheduled_charging_start_time charge_limit_soc charger_power windows_open doors_open | ||
| plugged_in scheduled_charging_start_time charge_limit_soc charger_power charge_rate windows_open doors_open | ||
| odometer shift_state charge_port_door_open time_to_full_charge charger_phases | ||
| charger_actual_current charger_voltage version update_available update_version is_user_present geofence | ||
| model trim_badging exterior_color wheel_type spoiler_type trunk_open frunk_open elevation power | ||
|
|
@@ -87,6 +87,7 @@ defmodule TeslaMate.Vehicles.Vehicle.Summary do | |
| charge_current_request_max: charge(vehicle, :charge_current_request_max), | ||
| charge_energy_added: charge(vehicle, :charge_energy_added), | ||
| charge_limit_soc: charge(vehicle, :charge_limit_soc), | ||
| charge_rate: charge(vehicle, :charge_rate), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adding a test to one of the following would be good:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fields added to the |
||
| charge_port_door_open: charge(vehicle, :charge_port_door_open), | ||
| charger_actual_current: charge(vehicle, :charger_actual_current), | ||
| charger_phases: charge(vehicle, :charger_phases), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,7 @@ Vehicle data will be published to the following topics: | |
| | `teslamate/cars/$car_id/plugged_in` | true | If car is currently plugged into a charger | | ||
| | `teslamate/cars/$car_id/charge_energy_added` | 5.06 | Last added energy in kWh | | ||
| | `teslamate/cars/$car_id/charge_limit_soc` | 90 | Charge Limit Configured in Percentage | | ||
| | `teslamate/cars/$car_id/charge_rate` | 0.0 | Charge rate in km per hour | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to https://developer.tesla.com/docs/fleet-api?python#vehicle_data,
Is this always km/hr and Teslamate converts it to the user's desired units, or is km/hr your experience because your GUI settings reflect that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @parkr , are you sure? As for the odometer the value extracted from the API does not change based on the gui_distance_units (always in miles), I believe it only indicates what is shown on the dashboard (gui). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this PR seemed abandoned and I want to have this feature I've redonde some of the changes in this new PR: #4130 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, I'm not a user of Teslamate, so I cannot judge the PR you are proposing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Charge rate is effectively always in mph. And your discrepancy is not only efficiency, is energy not going into the battery but being used for other things. Charge rate is a very good indicator of how the energy coming from the charge port is being used: |
||
| | `teslamate/cars/$car_id/charge_port_door_open` | true | Indicates if the charger door is open | | ||
| | `teslamate/cars/$car_id/charger_actual_current` | 2.05 | Current amperage supplied by charger | | ||
| | `teslamate/cars/$car_id/charger_phases` | 3 | Number of charger power phases (1-3) | | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this change to the tests? https://github.com/teslamate-org/teslamate/blob/master/test/teslamate/mqtt/pubsub/vehicle_subscriber_test.exs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as my knowledge extends, if the goal of this PR is to add a new field to MQTT that only gets updated when its value changes, then changes to the
VehicleSubscribermodule might be unnecessary. The existing logic in this module already handles conditional publishing based on whether field values have changed. Therefore, just adding the new field to the Summary struct should be sufficient, provided it's not included in the @always_published list, which forces fields to be published regardless of value changes.