Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/psacc_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@
17. Get the vehicle trips:

http://localhost:5000/vehicles/trips

18. Get vehicle doors state

http://localhost:5000/get_doors_state/YOURVIN
3 changes: 3 additions & 0 deletions psa_car_controller/psa/RemoteClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, account_info: AccountInformation, vehicles_list: Cars, manage
self.remoteCredentials: RemoteCredentials = remoteCredentials
self.manager = manager
self.precond_programs = {}
self.doors_state = {}
self.account_info = account_info
self.headers = {
"x-introspect-realm": self.account_info.realm,
Expand Down Expand Up @@ -83,6 +84,8 @@ def _on_mqtt_message(self, client, userdata, msg): # pylint: disable=unused-arg
elif msg.topic.startswith(MQTT_EVENT_TOPIC):
charge_info = data["charging_state"]
programs = data["precond_state"].get("programs", None)
if "door_state" in data:
self.doors_state[data["vin"]] = data["doors_state"]
if programs:
self.precond_programs[data["vin"]] = data["precond_state"]["programs"]
self._fix_not_updated_api(charge_info, data["vin"])
Expand Down
15 changes: 15 additions & 0 deletions psa_car_controller/web/view/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ def get_vehicle_info(vin):
)
return response

/**
@return {'doors_opening_state': number[]; 'doors_locking_state': number}
*/
@app.route('/get_doors_state/<string:vin>')
def get_doors_state(vin):
doors_state = APP.myp.remote_client.doors_state.get(vin)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you document possible value for door_state ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

/**
    @return {'doors_opening_state': number[]; 'doors_locking_state': number}
*/

Have you an example of documentation? And where i set? Thank you

if doors_state is None:
return jsonify({"error": "VIN not in list"})
logger.log(10, f"doors_state: {doors_state}")
response = app.response_class(
response=json.dumps(doors_state, default=str),
status=200,
mimetype='application/json'
)
return response

@app.route("/style.json")
def get_style():
Expand Down