Lucid API

spencerp

New Member
Verified Owner
Joined
Nov 27, 2023
Messages
12
Reaction score
15
Does anyone have any experience connecting to the lucid's api they use with the mobile app through something like postman or something similar? I am hoping to use this to create a teslascope/teslafi alternative for lucid
 
Does anyone have any experience connecting to the lucid's api they use with the mobile app through something like postman or something similar? I am hoping to use this to create a teslascope/teslafi alternative for lucid
Lucid has not released an official API.
 
So I know nothing is official, but the way all the original Tesla implementations worked (such as teslascope) wasn't technically through an official api either; the endpoints were originally discovered by checking outgoing network calls on the app I believe and was wondering if anyone has attempted anything like this before
 
So I know nothing is official, but the way all the original Tesla implementations worked (such as teslascope) wasn't technically through an official api either; the endpoints were originally discovered by checking outgoing network calls on the app I believe and was wondering if anyone has attempted anything like this before
Maybe @borski ?
 
I meant to post a new thread about this, but you did it for me, so thanks. :)

Python bindings for the REST API here: https://github.com/nshp/python-lucidmotors

There is a branch called grpc-api where @segbrk has reversed most of the grpc api: https://github.com/nshp/python-lucidmotors/tree/grpc-api

And there is a working Home Assistant integration, through HACS: https://github.com/borski/ha-lucidmotors

There is a discord where we are working on this here: https://discord.gg/uWa5nSxr

Please only join if you can contribute. We do not want it to turn into a spam server or general interest server.

What’s presently left is filling out the rest of the protobuf stuff (assigning the numbers to states, etc.) and then ensuring HA uses the grpc api, which seems to be a superset of the REST API. My guess is REST is old, grpc is new. It *could* be the other way around, and the REST api hasn’t caught up to feature parity yet, but either way the library supports both at the moment.

@joec has been working on a new iOS app using the reversed bindings, but it’s very early and not for release - the rest I’ll leave to him.

PRs and issues welcome! Please post them to GitHub.

If you run into issues, please checkout python-lucidmotors, generate an anonymized test case from your data, using `python examples/anonymize_login_response.py`. This will log in, remove identifying information from the API response, and write it to a file. Check the file to ensure anonymization actually worked, then you can share it as a test case.
 
I meant to post a new thread about this, but you did it for me, so thanks. :)

Python bindings for the REST API here: https://github.com/nshp/python-lucidmotors

There is a branch called grpc-api where @segbrk has reversed most of the grpc api: https://github.com/nshp/python-lucidmotors/tree/grpc-api

And there is a working Home Assistant integration, through HACS: https://github.com/borski/ha-lucidmotors

There is a discord where we are working on this here: https://discord.gg/uWa5nSxr

Please only join if you can contribute. We do not want it to turn into a spam server or general interest server.

What’s presently left is filling out the rest of the protobuf stuff (assigning the numbers to states, etc.) and then ensuring HA uses the grpc api, which seems to be a superset of the REST API. My guess is REST is old, grpc is new. It *could* be the other way around, and the REST api hasn’t caught up to feature parity yet, but either way the library supports both at the moment.

@joec has been working on a new iOS app using the reversed bindings, but it’s very early and not for release - the rest I’ll leave to him.

PRs and issues welcome! Please post them to GitHub.

If you run into issues, please checkout python-lucidmotors, generate an anonymized test case from your data, using `python examples/anonymize_login_response.py`. This will log in, remove identifying information from the API response, and write it to a file. Check the file to ensure anonymization actually worked, then you can share it as a test case.
No idea what you are talking about or what any of this means(only have basic python knowledge lol) but it sounds really useful! What will Joe's app be doing?
 
No idea what you are talking about or what any of this means(only have basic python knowledge lol) but it sounds really useful! What will Joe's app be doing?
To make a long story short: the Lucid mobile app talks to the internet via an API. Every time you tap a button, or every time it loads any information, it isn’t talking directly to your car. It talks to some Lucid servers on the internet which then, in turn, talk to your car, and report back those servers who then report back to you.

Those APIs can exist in many forms, but are generally well-defined - meaning that if you can snoop on or listen to the communication, or find out by reverse engineering the app how it communicates, you can pretend to be the mobile app and get the info yourself, or issue commands.

That is what the Python bindings (a fancy word for “the thing that does the communication, but in Python”) do. You ask it for info or give it commands, and then it talks to Lucid’s servers, and so on. As a result, now Home Assistant can talk to your car, and you can set up any automations you want - with the full power of all your other home integrations.

For example, you could have your garage open/close when you arrive/leave. I don’t have to wait for Lucid to implement that, and neither do you.

You could have it automatically set the temperature in the car 10 minutes before you have an event on your calendar with a location that isn’t at home.

And so on.

As for @joec’s mobile app, it’s not my place to say. But I can tell you what *my* goal would be - not to re-implement the whole mobile app, but just give quick access to various commands and info.

The Lucid first party app does a lot - mobile key, support, analytics, and so on.

A simpler app that only does a few important things would thus be likely much faster.
 
To make a long story short: the Lucid mobile app talks to the internet via an API. Every time you tap a button, or every time it loads any information, it isn’t talking directly to your car. It talks to some Lucid servers on the internet which then, in turn, talk to your car, and report back those servers who then report back to you.

Those APIs can exist in many forms, but are generally well-defined - meaning that if you can snoop on or listen to the communication, or find out by reverse engineering the app how it communicates, you can pretend to be the mobile app and get the info yourself, or issue commands.

That is what the Python bindings (a fancy word for “the thing that does the communication, but in Python”) do. You ask it for info or give it commands, and then it talks to Lucid’s servers, and so on. As a result, now Home Assistant can talk to your car, and you can set up any automations you want - with the full power of all your other home integrations.

For example, you could have your garage open/close when you arrive/leave. I don’t have to wait for Lucid to implement that, and neither do you.

You could have it automatically set the temperature in the car 10 minutes before you have an event on your calendar with a location that isn’t at home.

And so on.

As for @joec’s mobile app, it’s not my place to say. But I can tell you what *my* goal would be - not to re-implement the whole mobile app, but just give quick access to various commands and info.

The Lucid first party app does a lot - mobile key, support, analytics, and so on.

A simpler app that only does a few important things would thus be likely much faster.
I knew what APIs and bindings were, just not the protobuf, states, etc. All of that is nonsense to me lol.

And that does sound very useful.. you previously mentioned turning off all headlights for example! Perhaps some stuff could be knocked off the mega polls for features?

Also, would it be possible to turn on heated seats remotely for example?
 
I knew what APIs and bindings were, just not the protobuf, states, etc. All of that is nonsense to me lol.

And that does sound very useful.. you previously mentioned turning off all headlights for example! Perhaps some stuff could be knocked off the mega polls for features?

Also, would it be possible to turn on heated seats remotely for example?
You can only do what's available from Lucid's servers. And only then what can be gleaned via lots of sleuthing.

The mobile app can't do heated seats. So likely there is no API for it. Yet. It could exist, perhaps, as something they plan to implement in the future. But that would make it much harder to find.

So generally speaking, if the current mobile app can't do it, likely any API reverse-engineering won't be able to, either. There are some small exceptions. But nothing as great as turning on seat heat thus far.
 
I knew what APIs and bindings were, just not the protobuf, states, etc. All of that is nonsense to me lol.

And that does sound very useful.. you previously mentioned turning off all headlights for example! Perhaps some stuff could be knocked off the mega polls for features?

Also, would it be possible to turn on heated seats remotely for example?
States are just that. For example, the POWER_STATE may be something like AWAKE, ASLEEP, WINK, or LIVE_CHARGE or LIVE_UPDATE. But underneath they’re like 1 or 2 or 3 or 4 or 5. Figuring out which is which is what I’m talking about.

As for protobuf: https://protobuf.dev/
 
Following
 
This single-handedly convinced me to finally update my HA setup so I can use this integration. Thank you for the amazing work!
Feel free to join the discord if you're interested. Now that most of the work is done, we'd love feedback; just bear in mind we have day jobs 🤣
 
Feel free to join the discord if you're interested. Now that most of the work is done, we'd love feedback; just bear in mind we have day jobs 🤣
Oh, I get it. Why do you think my HA isn't updated every month? And my home server UPS has needed new batteries for 3 years? And my curtains aren't fully automated yet? And my closet is full of unopened Lego sets? And the aluminum I bought to make hub covers for my Touring is still sitting next to my lathe?
 
Oh, I get it. Why do you think my HA isn't updated every month? And my home server UPS has needed new batteries for 3 years? And my curtains aren't fully automated yet? And my closet is full of unopened Lego sets? And the aluminum I bought to make hub covers for my Touring is still sitting next to my lathe?
It’s okay, I had half a lamp for about six months
 
No a programmer but can hack together code that sorta works. Tried vehicle_info then test_all_actions on Mac. Killed test_all_actions after a minute or two since I didn't see anything on console. Looked outside and saw doors unlocked, frunk and trunk opened and the fan blowing. Thanks @borski for putting this together and sharing! Is there a special discord server for this?
 
No a programmer but can hack together code that sorta works. Tried vehicle_info then test_all_actions on Mac. Killed test_all_actions after a minute or two since I didn't see anything on console. Looked outside and saw doors unlocked, frunk and trunk opened and the fan blowing. Thanks @borski for putting this together and sharing! Is there a special discord server for this?
 
Thanks for creating this thread. I will also be following.
When I had Tesla I meant to start using HA. Now I don't have Tesla but I am glad the Lucid community is also working on it.
With no background in coding, I hope to set up my HA in a month or so and start integrating Lucid along with other home stuff I have.
 
Hi,
I used the Unofficial Lucid API to grab the data from my vehicle. Link: https://testmycode.cc/
<snippet>

Field 1, battery: <br> &lt;class 'vehicle_state_service_pb2.BatteryState'&gt;:<br> Field 1, remaining_range: 230.0<br> Field 2, charge_percent: 35.50000052899122<br> Field 3, kwhr: 28.73999935761094<br> Field 4, capacity_kwhr: 80.9499981906265<br> Field 5, battery_health: WARNING_OFF (1)<br> Field 6, low_charge_level: WARNING_OFF (1)<br> Field 7, critical_charge_level: WARNING_OFF (1)<br> Field 9, preconditioning_status: BATTERY_PRECON_OFF (1)<br> Field 10, preconditioning_time_remaining: 255<br> Field 11, battery_health_level: 95.20000141859055<br> Field 13, bmu_software_version_major: 4<br> Field 14, bmu_software_version_minor: 12<br> Field 15, bmu_software_version_micro: 22<br> Field 16, battery_cell_type: BATTERY_CELL_TYPE_PANA_2170M (3)<br> Field 17, battery_pack_type: BATTERY_PACK_TYPE_AIR_16 (3)<br> Field 18, max_cell_temp: 32.300001971423626<br> Field 19, min_cell_temp: 29.500001929700375
<snippet>

Some questions if you don't mind... Is this data obtained in real time once you logged in?

Field 1, remaining_range: 230.0 ; But, currently this doesn't match what's shown in my Lucid App. App shows 142 miles remaining.

Field 4, capacity_kwhr: 80.9499981906265<br>

Field 11, battery_health_level: 95.20000141859055<br>

It seems to me, if I can read this Field 4 data correctly, my capacity is 80kWh (down from 88kWh original spec) so I have lost 9% ?
My vehicle build date is 9/2023 and I took delivery Sept 20th.

Field 11 is indicating current batt health/capacity? i.e. 95% ; but the above Field 4 suggests a loss of 9% already.

Seems confusing... and thus, any insights is most appreciated. Thanks.
 
Back
Top