Tesla binding OH 3.1: Failed to retrieve refresh token - 403

Looks like the 3.1 tesla binding is no longer compatible with the tesla site for retrieving the refresh token?

openhab> openhab:tesla login
Username (email): me@gmail.com
me@gmail.com
Password: *****

Attempting login...
Failed to retrieve refresh token

Logs

2021-11-09 21:23:05.221 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - Obtained SSO login page
2021-11-09 21:23:05.404 [DEBUG] [sla.internal.handler.TeslaSSOHandler] - Failed to obtain code from SSO login page when submitting form, response status code: 403
2 Likes

Hi
I’m seeing the exact same problem, did you by any chance find a solution?

1 Like

Same problem here. Tesla binding (bridge) gives configuration error since 22 March. I upgraded to Openhab 3.3.0.M2, re-installed the binding, created a new Tesla account with new refresh token (Auth for Tesla), but still ‘Configuration_Error’.
Anyone having an idea how to go forward?

I can confirm. Since 22 March it is not working anymore. Same here for OH V 3.3.0.M2

Same issue here. OpenHAB 3.2 with openHABian.

+1

Both UI and console fails.

have a look at

1 Like

Thank you. If I understand it correctly, one file (TeslaSSOHandler.java) needs to be updated. Since I am a beginner, how can I do that with my current installation (openHAB 3.2 with openHABian)?

Check out this thread: [tesla] Configuration Error / Failed to obtain access token for API · Issue #12516 · openhab/openhab-addons · GitHub

You can install the openhab snapshot version (just install it over the existing openhab installation, worked fine for me) or update the binding manually via karaf console using this instruction.

2 Likes

Thank you. It worked via console!

Unfortunately car goes offline (ERROR:COMM) regularly. Have to disable and enable Tesla account in openHAB, then car goes online again until - after some time - it becomes offline.

Any suggestions?

Thank you!

I have the same issue

I have same issue

I managed to get around this issue with a rule that triggers when the car thing (not the bridge thing!) changes from ONLINE to OFFLINE or from ONLINE to UNKNOWN. You need to enable basic auth and the JSScripting addon. This is required because things can only be enabled/disabled by REST API or external commands, not from within OH3.

And of course you need to adjust to your environment - the REST URLs are easily copied from the API explorer.

var AccountUID, CarVIN, AccountThing, CarThing, RestUserPW, RestBaseURL, BridgeState, BridgeStateDetail, CarState, CarStateDetail, things, logger, BridgeUrl, CarUrl, putHeaders, putResponse;

things = Java.type('org.openhab.core.model.script.actions.Things')
logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);

AccountUID = '**********'; // take from bridge thing definition
CarVIN = '5YJSA7E26GF******'; // take from car thing definition
AccountThing = 'tesla:account:'+AccountUID;
CarThing = 'tesla:models:'+AccountUID+':'+CarVIN;
RestUserPW = '********:*********'; // user:password for REST API access
RestBaseURL = 'http://'+RestUserPW+'@openhab:8080/rest'; // obvious...
BridgeUrl = RestBaseURL+'/things/tesla%3Aaccount%3A'+AccountUID+'/enable';
CarUrl = RestBaseURL+'/things/tesla%3Amodels%3A'+AccountUID+'%3A'+CarVIN+'/enable';

let { actions } = require('openhab');

BridgeState = String( things.getThingStatusInfo(AccountThing).getStatus());
BridgeStateDetail = String( things.getThingStatusInfo(AccountThing).getStatusDetail());

CarState = String( things.getThingStatusInfo(CarThing).getStatus());
CarStateDetail = String( things.getThingStatusInfo(CarThing).getStatusDetail());

logger.info('[Trigger] - Tesla bridge state: '+BridgeState+' - Detail: '+BridgeStateDetail);
logger.info('[Trigger] - Tesla car state: '+CarState+' - Detail: '+CarStateDetail );

if ((BridgeState == 'ONLINE' || BridgeState == 'DISABLED')&& CarState != 'ONLINE' && CarState != 'DISABLED') {
  // try to disable/enable both bridge and car, hopefully it will recover...
  logger.error('[Trigger] - Bridge is online, but car ist not.');
  logger.info('[Trigger] - Trying to disable Tesla bridge...');
  putResponse = actions.HTTP.sendHttpPutRequest(BridgeUrl, "text/plain", "false", 5000);
  logger.info('[Trigger] - ' + putResponse);
  java.lang.Thread.sleep(2000)
  logger.info('[Trigger] - Trying to enable tesla bridge...');
  putResponse = actions.HTTP.sendHttpPutRequest(BridgeUrl, "text/plain", "true", 5000);
  logger.info('[Trigger] - ' + putResponse);
  java.lang.Thread.sleep(2000);
  logger.info('[Trigger] - Trying to disable tesla car...');
  putResponse = actions.HTTP.sendHttpPutRequest( CarUrl, "text/plain", "false", 5000);
  logger.info('[Trigger] - ' + putResponse);
  java.lang.Thread.sleep(2000);
  logger.info('[Trigger] - Trying to enable tesla car...');
  putResponse = actions.HTTP.sendHttpPutRequest( CarUrl, "text/plain", "true", 5000);
  logger.info('[Trigger] - ' + putResponse);
} else if (BridgeState != 'ONLINE' || CarState != 'ONLINE') {
  // log info if either bridge or car are not online, but combination does not allow automatic repair
  logger.warn('[Trigger] - No action taken, no sense to restart bridge if BridgeState != ONLINE.');
} else {
  logger.info('[Trigger] - Nothing to do, both Tesla bridge and car are online.')
}

BTW: Please be graceful - this was my first javascript ever…