staples
Well-Known Member
- Joined
- Jul 12, 2020
- Threads
- 4
- Messages
- 305
- Reaction score
- 543
- Location
- Chicago, IL
- Vehicles
- R1T, Zero FXS, Tesla Y
API seems to be working just fine for my lazy curl based integration to Home Assistant.
Sponsored
Tell me more! What have you integrated into HA so far?API seems to be working just fine for my lazy curl based integration to Home Assistant.
EDIT: Last post was before I found the source code..![]()
Python experts - running into this error after loading into pycharm. I've enabled the .env with my credentials. Any thoughts or guidance?
thanks!
I recognize that code (disclaimer it's mine![]()
Python experts - running into this error after loading into pycharm. I've enabled the .env with my credentials. Any thoughts or guidance?
No dice. Might be a Mac thing, but it doesn't see the file as just .env. In Finder it moves it to a hidden file. When mapping to it PyCharm Config it showing up to connect it.I recognize that code (disclaimer it's mine).
Try renaming `environment.env` to just `.env`.
Here's a screenshot of mine (Pycharm on Mac):No dice. Might be a Mac thing, but it doesn't see the file as just .env. In Finder it moves it to a hidden file. When mapping to it PyCharm Config it showing up to connect it.
That fixed it! Gracias sir!Here's a screenshot of mine (Pycharm on Mac):
![]()
`.env` is the default filename that the dotenv library will load. If you rename it to anything else then you need to change L9 to something like `conf = dotenv_values("environment.env")`.
yes and yes. It simply compares the full json response to its last known one, and if Theres a difference it will text the full latest response.Got the Twilio info added. Will it only text if something changes? And is it watching for all the fields?
Awesome! So normal that on the initial run no text received?yes and yes. It simply compares the full json response to its last known one, and if Theres a difference it will text the full latest response.
yep.Awesome! So normal that on the initial run no text received?
# Modified get_order_status to return all orderSnapshots, I also added some additional data
# from the order items so I could see whether it was my R1S or R1T order
def get_order_statuses(csrf_token, a_sess, u_sess):
headers = {
'Content-Type': CONTENT_TYPE,
'dc-cid': DC_CID,
'csrf-token': csrf_token,
'a-sess': a_sess,
'u-sess': u_sess
}
payload = "{\"query\":\"query {\\n\\tuser {\\n \\t\\torderSnapshots (filterTypes: [PRE_ORDER, VEHICLE, RETAIL]) {\\n\\t\\t id\\n\\t\\t state\\n\\t\\t configurationStatus\\n\\t\\t fulfillmentSummaryStatus\\n\\t\\t vehicleId\\n \\t\\titems {\\n id\\n total\\n unitPrice\\n quantity\\n productDetails {\\n ... on VehicleProduct {\\n sku\\n store {\\n country\\n __typename\\n }\\n __typename\\n }\\n }\\n }} \\n\\t}\\n}\\n\",\"variables\":{}}"
response = session.post(url=GQL_ORDERS_URL, headers=headers, data=payload)
if response.status_code != 200:
print(response)
return response.json()['data']['user']['orderSnapshots']
# I modified the def single_status_check(): method:
def single_status_check():
access_token, refresh_token = create_session()
csrf_token = create_csrf_token()
a_sess, u_sess = create_graph_session(csrf_token, access_token, refresh_token)
order_statuses = get_order_statuses(csrf_token, a_sess, u_sess)
dt_string = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
for order_status in order_statuses:
vehicle_type = "Unkown"
for each_item in order_status['items']:
if 'sku' in each_item['productDetails']:
vehicle_type = each_item['productDetails']['sku']
order_status_message = "{}:\n\tvehicle: {}\n\tstate: {}\n\tconfigurationStatus: {}\n\tfulfillmentSummaryStatus: {}\n\tvehicleId: {}".format(
dt_string,
vehicle_type,
order_status['state'],
order_status['configurationStatus'],
order_status['fulfillmentSummaryStatus'],
order_status['vehicleId'])
print(order_status_message)
# note: I didn't fix up the last_order_status stuff to support multi-orders yet
# Nor did I tackle the 8-step as I am no where near that.