mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
[tesla] Adapt calls to new products API endpoint (#16331)
Signed-off-by: Paul Smedley <paul@smedley.id.au>
This commit is contained in:
parent
e68897c0a1
commit
541b40474b
@ -36,6 +36,7 @@ public class TeslaBindingConstants {
|
|||||||
public static final String URI_OWNERS = "https://owner-api.teslamotors.com";
|
public static final String URI_OWNERS = "https://owner-api.teslamotors.com";
|
||||||
public static final String VALETPIN = "valetpin";
|
public static final String VALETPIN = "valetpin";
|
||||||
public static final String VEHICLES = "vehicles";
|
public static final String VEHICLES = "vehicles";
|
||||||
|
public static final String PRODUCTS = "products";
|
||||||
public static final String VIN = "vin";
|
public static final String VIN = "vin";
|
||||||
|
|
||||||
// SSO URI constants
|
// SSO URI constants
|
||||||
|
@ -76,6 +76,7 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
|||||||
// REST Client API variables
|
// REST Client API variables
|
||||||
private final WebTarget teslaTarget;
|
private final WebTarget teslaTarget;
|
||||||
WebTarget vehiclesTarget; // this cannot be marked final as it is used in the runnable
|
WebTarget vehiclesTarget; // this cannot be marked final as it is used in the runnable
|
||||||
|
WebTarget productsTarget; // this cannot be marked final as it is used in the runnable
|
||||||
final WebTarget vehicleTarget;
|
final WebTarget vehicleTarget;
|
||||||
final WebTarget dataRequestTarget;
|
final WebTarget dataRequestTarget;
|
||||||
final WebTarget commandTarget;
|
final WebTarget commandTarget;
|
||||||
@ -107,6 +108,7 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
|||||||
this.thingTypeMigrationService = thingTypeMigrationService;
|
this.thingTypeMigrationService = thingTypeMigrationService;
|
||||||
|
|
||||||
this.vehiclesTarget = teslaTarget.path(API_VERSION).path(VEHICLES);
|
this.vehiclesTarget = teslaTarget.path(API_VERSION).path(VEHICLES);
|
||||||
|
this.productsTarget = teslaTarget.path(API_VERSION).path(PRODUCTS);
|
||||||
this.vehicleTarget = vehiclesTarget.path(PATH_VEHICLE_ID);
|
this.vehicleTarget = vehiclesTarget.path(PATH_VEHICLE_ID);
|
||||||
this.dataRequestTarget = vehicleTarget.path(PATH_DATA_REQUEST).queryParam("endpoints",
|
this.dataRequestTarget = vehicleTarget.path(PATH_DATA_REQUEST).queryParam("endpoints",
|
||||||
"location_data;charge_state;climate_state;vehicle_state;gui_settings;vehicle_config");
|
"location_data;charge_state;climate_state;vehicle_state;gui_settings;vehicle_config");
|
||||||
@ -211,7 +213,7 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
|||||||
|
|
||||||
if (authHeader != null) {
|
if (authHeader != null) {
|
||||||
// get a list of vehicles
|
// get a list of vehicles
|
||||||
Response response = vehiclesTarget.request(MediaType.APPLICATION_JSON_TYPE)
|
Response response = productsTarget.request(MediaType.APPLICATION_JSON_TYPE)
|
||||||
.header("Authorization", authHeader).get();
|
.header("Authorization", authHeader).get();
|
||||||
|
|
||||||
logger.debug("Querying the vehicle: Response: {}: {}", response.getStatus(),
|
logger.debug("Querying the vehicle: Response: {}: {}", response.getStatus(),
|
||||||
@ -374,7 +376,7 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
|||||||
|
|
||||||
if (authenticationResult.getStatus() == ThingStatus.ONLINE) {
|
if (authenticationResult.getStatus() == ThingStatus.ONLINE) {
|
||||||
// get a list of vehicles
|
// get a list of vehicles
|
||||||
Response response = vehiclesTarget.request(MediaType.APPLICATION_JSON_TYPE)
|
Response response = productsTarget.request(MediaType.APPLICATION_JSON_TYPE)
|
||||||
.header("Authorization", "Bearer " + logonToken.access_token).get();
|
.header("Authorization", "Bearer " + logonToken.access_token).get();
|
||||||
|
|
||||||
if (response != null && response.getStatus() == 200 && response.hasEntity()) {
|
if (response != null && response.getStatus() == 200 && response.hasEntity()) {
|
||||||
|
@ -791,8 +791,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||||||
if (authHeader != null) {
|
if (authHeader != null) {
|
||||||
try {
|
try {
|
||||||
// get a list of vehicles
|
// get a list of vehicles
|
||||||
synchronized (account.vehiclesTarget) {
|
synchronized (account.productsTarget) {
|
||||||
Response response = account.vehiclesTarget.request(MediaType.APPLICATION_JSON_TYPE)
|
Response response = account.productsTarget.request(MediaType.APPLICATION_JSON_TYPE)
|
||||||
.header("Authorization", authHeader).get();
|
.header("Authorization", authHeader).get();
|
||||||
|
|
||||||
logger.debug("Querying the vehicle, response : {}, {}", response.getStatus(),
|
logger.debug("Querying the vehicle, response : {}, {}", response.getStatus(),
|
||||||
|
Loading…
Reference in New Issue
Block a user