G-Two / subarulink

A python package for interacting with Subaru STARLINK remote vehicle services.
Apache License 2.0
82 stars 14 forks source link

Is it possible to embed this into a flaskapp so it can be used with siri shortcuts? #64

Open krushil1 opened 1 year ago

krushil1 commented 1 year ago

I was trying to add flask app to the current codebase, so I could use the Siri shortcuts to interact with my car but I needed some assistance. Can someone help me out?

G-Two commented 1 year ago

Yes, you should be able to use this package in a flask app. You'll need to make sure to deal with the 2FA on the initial login, but after that, it should be pretty straightforward. Is there a particular part you're having trouble with?

krushil1 commented 1 year ago

Thanks for getting back! I was having trouble setting up my flask app with this package where I can start my car and use the preset climate controls.

krushil1 commented 1 year ago

I am a little confused regarding how I can call the commands using the subarulink package inside the flask app. Should I use subarulink(lock) to lock the car?

krushil1 commented 1 year ago

I believe I got the commands working! I need assistance with storing the subarulink.cfg file in the root directory of the flask app so when I host it, its easier to access

krushil1 commented 1 year ago

Is it possible to edit the default path of the config file? I keep getting stuck with the config file path when deploying it to WayScript for hosting.

G-Two commented 1 year ago

I'm not too familiar with how WayScript (or even Flask) environments work. Can you paste in a snippet of your code that uses the subarulink module? If you're using subarulink.cfg, then I'm assuming you are invoking the example CLI app that comes with the module (since subarulink.controller itself has no concept of a config file). If you are calling the CLI app as a shell command, then you can specify a config file path with the -c option.

FYI, you can also use subarulink.controller directly without dealing with config files. There is an example using aws-lambda that doesn't use the CLI app and accesses your Subaru account information secrets via environment variables. The code is a bit dated from a previous version of subarulink, but it shows that you can have finer control instead of depending on the CLI app. Additional subarulink documentation is here.

krushil1 commented 1 year ago

Thanks for getting back! The way I had my flask app set up was that when I request a door command or engine command, it would use the subprocess module to run the CLI command for subarulink. I tried using the -c option to change the config file location, but that didn't work for me :/

I later checked out the repo with aws-lambda-function, I couldn't get the car to start, as it kept giving me a 500 error, but I did have success with using the door unlock/lock command. So I was thinking of using the subaru.controller to access all of my car's functionality. Can you please provide me with a sample file for subaru.controller where I can lock/unlock, start, and stop my car? It would be a great help as I am a rookie with python 😭

csmarshall commented 1 year ago

this works for me: homebridge -> Homebridge Cmdtriggerswitch -> subarulink cli