diff --git a/Changes b/Changes index bb1e7bf..22ae8ed 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/examples/address.pl b/examples/address.pl index 23ea5f2..70d3de2 100755 --- a/examples/address.pl +++ b/examples/address.pl @@ -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) { diff --git a/lib/Tesla/Vehicle.pm b/lib/Tesla/Vehicle.pm index 86ef2bc..5cf0865 100644 --- a/lib/Tesla/Vehicle.pm +++ b/lib/Tesla/Vehicle.pm @@ -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; @@ -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}; } @@ -1118,6 +1121,13 @@ odometer reading, whether sentry mode is enabled or not etc. I: 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.