Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vehicleLockState missing for unlocked vehicle? #87

Open
AloisKlingler opened this issue Jan 17, 2025 · 3 comments · May be fixed by #95
Open

vehicleLockState missing for unlocked vehicle? #87

AloisKlingler opened this issue Jan 17, 2025 · 3 comments · May be fixed by #95

Comments

@AloisKlingler
Copy link
Contributor

hi,

I do:
curl -X POST http://192.168.0.242:8080/api/1/vehicles/XXX/command/door_lock -d ""
{"response":{"result":true,"reason":"The command was successfully received and will be processed shortly.","vin":"XXX","command":"door_lock"}}

afterwards looking into http://192.168.0.242:8080/api/1/vehicles/XXX/body_controller_state
{"response":{"result":true,"reason":"The request was successfully processed.","vin":"XXX","command":"body-controller-state","response":{"vehicleLockState":"VEHICLELOCKSTATE_LOCKED","vehicleSleepStatus":"VEHICLE_SLEEP_STATUS_AWAKE","userPresence":"VEHICLE_USER_PRESENCE_NOT_PRESENT"}}}

if I do:
curl -X POST http://192.168.0.242:8080/api/1/vehicles/XXX/command/door_unlock -d ""
{"response":{"result":true,"reason":"The command was successfully received and will be processed shortly.","vin":"XXX","command":"door_unlock"}}

it removes the vehicleLockState:
{"response":{"result":true,"reason":"The request was successfully processed.","vin":"XXX","command":"body-controller-state","response":{"vehicleSleepStatus":"VEHICLE_SLEEP_STATUS_AWAKE","userPresence":"VEHICLE_USER_PRESENCE_NOT_PRESENT"}}}

is this intended? I would expect to have there "vehicleLockState":"VEHICLELOCKSTATE_UNLOCKED" in the json

also, is there a possibility to request and deliver the body_controller_state also with http://192.168.0.242:8080/api/1/vehicles/XXX/vehicle_data ?

Thanks

@Lenart12
Copy link
Contributor

This "bug" is because most fields have json:omitifempty tag defined for them by Tesla. To avoid this, proxy manually crafts json response for vehicle_data, but is missing for body controller state. I have already fixed this on my fork

func BodyControllerStateFromBle(vehicleData *vcsec.VehicleStatus) map[string]interface{} {
cs := &vehicleData.ClosureStatuses
dcs := &vehicleData.DetailedClosureStatus
return map[string]interface{}{
"closure_statuses": map[string]interface{}{
"front_driver_door": flatten((*cs).GetFrontDriverDoor().String()),
"front_passenger_door": flatten((*cs).GetFrontPassengerDoor().String()),
"rear_driver_door": flatten((*cs).GetRearDriverDoor().String()),
"rear_passenger_door": flatten((*cs).GetRearPassengerDoor().String()),
"rear_trunk": flatten((*cs).GetRearTrunk().String()),
"front_trunk": flatten((*cs).GetFrontTrunk().String()),
"charge_port": flatten((*cs).GetChargePort().String()),
"tonneau": flatten((*cs).GetTonneau().String()),
},
"detailed_closure_status": map[string]interface{}{
"tonneau_percent_open": (*dcs).GetTonneauPercentOpen(),
},
"user_presence": flatten(vehicleData.GetUserPresence().String()),
"vehicle_lock_state": flatten(vehicleData.GetVehicleLockState().String()),
"vehicle_sleep_status": flatten(vehicleData.GetVehicleSleepStatus().String()),
}
}
but im waiting on a PR inside vehicle-command before making a PR here

@AloisKlingler
Copy link
Contributor Author

@Lenart12 do you know, is it possible to deliver body_controller_state with vehicle_data aswell?

@Lenart12
Copy link
Contributor

It would be possible to implement, but I don't why that would make sense... just use the provided endpoint for b-c-s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants