Skip to content

Commit

Permalink
Added charge_history()
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieb9 committed Mar 29, 2023
1 parent 7a8d5f3 commit c29c5b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Revision history for Tesla-Vehicle
cache to object instances of that library
- Add constants for geocoding API request attributes
- Bump prereq of Tesla::API to 1.03
- Added charge_history()

0.08 2022-07-18
- Return 0 if charge_actual_current() is undef
Expand Down
7 changes: 7 additions & 0 deletions examples/address.pl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@
my $car = Tesla::Vehicle->new(auto_wake => 1);

my $address = $car->address;
my $id = $car->id;

print "\n";

say "online: " . $car->online;
say "id: $id";

print Dumper $car->charge_history;
exit;

say "road: $address->{road}";

for (sort keys %$address) {
Expand Down
12 changes: 11 additions & 1 deletion lib/Tesla/Vehicle.pm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ sub state {
sub summary {
return $_[0]->api(endpoint => 'VEHICLE_SUMMARY', id => $_[0]->id);
}
sub charge_history {
return $_[0]->api(endpoint => 'VEHICLE_CHARGE_HISTORY', id => $_[0]->id);
}
sub charge_state {
my ($self) = @_;
$self->_online_check;
Expand Down Expand Up @@ -285,7 +288,7 @@ sub charging_sites_nearby {
}
sub charging_state {
return $_[0]->data->{charge_state}{charging_state};
}
}
sub minutes_to_full_charge {
return $_[0]->data->{charge_state}{minutes_to_full_charge};
}
Expand Down Expand Up @@ -1118,6 +1121,13 @@ odometer reading, whether sentry mode is enabled or not etc.
I<Return>: Hash reference.
=head2 charge_history
Returns raw information on the charge history of the vehicle.
There is no internal mechanism that organizes the data; it's up to the user to
decipher the data currently.
=head2 charge_state
Returns information regarding battery and charging information of your vehicle.
Expand Down

0 comments on commit c29c5b8

Please sign in to comment.