Smart #1 API / Smart Home Integration

  • chriscat

    When I got the car in late April, it worked for a few months without a problem. But yes, obviously they broke this functionality somehow. Really frustrating, so many bugs! :rolleyes:


    If you set up the widget on your homescreen by just using the parameters, you can setup multiple widgets simply by using different vins - no need to touch the script at all. So it's both more secure and more flexible.

  • chriscat

    When I got the car in late April, it worked for a few months without a problem. But yes, obviously they broke this functionality somehow. Really frustrating, so many bugs! :rolleyes:


    If you set up the widget on your homescreen by just using the parameters, you can setup multiple widgets simply by using different vins - no need to touch the script at all. So it's both more secure and more flexible.

    Thanks. actually the trick was just to use the VIN for the 2nd car. I was looking for an index.


    I created a 2nd API user so that I could get 2 widgets at the same times.


    Do we have to wait for a while after we connected in the app with that user to accept the sharing? I lost access also to the 1st one which worked before.

    IMG_1827.jpeg

  • Danke Dir,

    Ich habe einfach alles neu installiert, jetzt findet er das file.


    Jedoch bekomme ich jetzt eine Fehlermeldung zum Sessioninfo login token.

    Ich habe mich in der App mal abgemeldet, als ich mich anmelden wollte bekam ich mitgeteilt das ich vorübergehend gesperrt wurde.

    Oh, nicht so schön. Das sollte sich nach einiger Zeit wieder beheben. Eventuell hast du bzw. das Skript zu oft versucht, sich einzuloggen und das ging irgendwie schief wegen fehlender/falscher Datei.


    Ich werde einen weiteren Check einbauen, ob die abhängige Datei überhaupt gefunden werden kann und falls nicht, eine Fehlermeldung anzeigen.


    Grundsätzlich loggt sich das Skript so selten wie möglich neu ein. Wenn die Credentials und Token einmal vorhanden sind, werden sie so lange wieder verwendet, bis die Smart API sagt, sie sind abgelaufen. Also eigentlich sollte das nicht passieren wie bei dir. Hatte ich bisher nicht. Kennne den Fall nur von damals, als ich den Login für die automatische Bestellung gebaut habe.

  • Thanks. actually the trick was just to use the VIN for the 2nd car. I was looking for an index.


    I created a 2nd API user so that I could get 2 widgets at the same times.


    Do we have to wait for a while after we connected in the app with that user to accept the sharing? I lost access also to the 1st one which worked before.

    Basically you don't need one user per car in order to setup multiple widgets as long as your single user has access to all cars.


    So there are two options for you (I'd prefer the first):

    1. leave the script as it is (from github) and set up the parameters only in the widget configuration: username;password;vin (works as long as there is no semicolon in your password)
    2. set up the script multiple times in Scriptable (with different names) and hard code your user, pass and vin in each script (line 21-23) - in this case, leave the widget params empty in the configuration!
  • Basically you don't need one user per car in order to setup multiple widgets as long as your single user has access to all cars.


    So there are two options for you (I'd prefer the first):

    1. leave the script as it is (from github) and set up the parameters only in the widget configuration: username;password;vin (works as long as there is no semicolon in your password)
    2. set up the script multiple times in Scriptable (with different names) and hard code your user, pass and vin in each script (line 21-23) - in this case, leave the widget params empty in the configuration!

    I tried with both solutions. Neither worked. I suspect my users are blocked but I still can connect into the app


    Using twice the same user, I thought it might explain why i had credentials error. You said one account can connect only once so I tried with 2.

    It worked for the first car. But when I added a 2nd car, it never worked and the 1st started failing too.


    I’ll give it a couple of hours and see again. Maybe just a temporary block because I logon onto the app to share the cars.

  • Ah, my bad, Sorry. Actually multiple users are not supported yet. Only one user with multiple cars.


    This is because I store the credentials and tokens for the user inside a file in iCloud Drive in order to cache them. This way I can reuse the tokens as long as possible without having to log in again.


    Please do the following:

    • delete all your Smart widgets from the home screen (to stop them running automatically every few minutes)
    • go to your iCloud Drive Scriptable folder (e.g. in the Files app) and delete the file smart-credentials.json
    • setup one script/widget again and see if it works (it should!)

    After that you can set up another car but it has to be the same user! All scripts/widgets use the same user tokens as of now.

  • Ah, my bad, Sorry. Actually multiple users are not supported yet. Only one user with multiple cars.


    This is because I store the credentials and tokens for the user inside a file in iCloud Drive in order to cache them. This way I can reuse the tokens as long as possible without having to log in again.


    Please do the following:

    • delete all your Smart widgets from the home screen (to stop them running automatically every few minutes)
    • go to your iCloud Drive Scriptable folder (e.g. in the Files app) and delete the file smart-credentials.json
    • setup one script/widget again and see if it works (it should!)

    After that you can set up another car but it has to be the same user! All scripts/widgets use the same user tokens as of now.

    I wonder if with this method it means we don't have to fear to setup also on iPad and Macbook in addition to iPhone, with same credentials. Because iCloud sync the file between devices.


    When you said "setup one script/widget". Do you mean one script per widget? I like it better if I plan to re-use it on more devices.


    I can get only one working at a time. one or the other.


    After a few tries, it seems it's the lastest car I used on the app. it would mean it's impossible to avoid this issue. I would be able to get only the one I used last in the app for each user


    IMG_62E2C592F6CA-1.jpeg    IMG_23023BDD0FD9-1.jpeg