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

add switch for cable lock #139

Closed
Jorn72 opened this issue Oct 5, 2022 · 14 comments
Closed

add switch for cable lock #139

Jorn72 opened this issue Oct 5, 2022 · 14 comments
Assignees
Labels
enhancement New feature or request

Comments

@Jorn72
Copy link

Jorn72 commented Oct 5, 2022

First thanks for this awesome component.

I tried to make a automation to unlock the charging port when i am at home (location of my phone). This way i can easily unplug my car when at home. When i am not at home the charging port should be locked. (If i am at a public station i don't want somebody unplug my car). I see that there is a binary sensor in home assistant that shows if the port is locked or unlocked but it doesn't have a switch to lock or unlock it from home assistant. The Skoda app has a option to turn the lock on or off like you will see in the attached picture.

myskoda cable lock

So shortly i would like to see a switch being added to unlock the cable from home assistant. If easier a service call to unlock the port would also work fine.

Thanks again for your work.

@Farfar Farfar added the enhancement New feature or request label Oct 23, 2022
@Farfar Farfar self-assigned this Oct 23, 2022
@Farfar
Copy link
Collaborator

Farfar commented Oct 23, 2022

I would need debugs from app to incorporate this, I don't have an Enyaq myself so it might take a while. I'll see if I can get relevant info to fix this in the future.

@Jorn72
Copy link
Author

Jorn72 commented Oct 23, 2022

Hi @Farfar thanks for your reply. I looked in the debug log in Home Assistant but i didn't find anything that might be useful for you. I didn't find anything related to the cable lock or charging in general. I do only get specifications of my car and climate info. I think the Home assistant log is also not interesting for you because you need to see the command for the cable lock instead of the incoming data from: https://api.connect.skoda-auto.cz
(correct me if i am wrong)

Is there anything i can help you with this? Can i somehow get a debug log of me switching the cable lock on and off?
Or is there something else i can help you with?

@ChristophCaina
Copy link
Contributor

@Jorn72 What @Farfar means is, that he would need some "debug" information from the skoda app directly - to reverse engeneer the cable lock mechanism...

@Jorn72
Copy link
Author

Jorn72 commented Nov 2, 2022

Hi @ChristophCaina thanks for your reply. That's what I thought as well. On android you have a debug folder automatically made by the myskoda app. Sadly it has always been empty for me. It will probably only create a log when the app crashes or if it detects some sort of problem. Is there any way to activate debugging in the myskoda app?

@ChristophCaina
Copy link
Contributor

it's not that kind of "debug" :)

In this case, debug probably means some kind of reverse engeneer - which means, that you probably need to emulate an android device in a development environment and run the app in proper debug modes - and also where you can keep track of the incomming and outgoing traffic from that app.

Unfortunately, I am not really used to this kind of environment and had no time to really start investigating how to set this up... as of now - I can live without this functionallity - although it would be nice to have.
Maybe - I can give it a try at some point - but I cannot make any promisses as of now, since I don't know, when I would have the time for this... :-(

@sreichholf
Copy link

sreichholf commented Dec 9, 2022

This is actually already"prepared" in the skodaconnect python lib.
At least the actual API call seems to be well-known.

https://github.com/lendy007/skodaconnect/blob/main/skodaconnect/vehicle.py#L366

@RamonQu
Copy link

RamonQu commented Dec 12, 2022

I will try to fetch the calls, however the cable-lock option is currently not available in my app because the car is fully charged (80% in battery care mode). I will update when I get the calls.

For now, here are the GET-calls related to the Cable-lock switch

GET on https://api.connect.skoda-auto.cz/api/v1/charging/{VIN}/status

{
	"plug": {
		"connectionState": "Connected",
		"lockState": "Locked"     # Current lock-state charging plug
	},
	"charging": {
		"state": "ReadyForCharging",
		"remainingToCompleteInSeconds": 0,
		"chargingPowerInWatts": 0.0,
		"chargingRateInKilometersPerHour": 0.0,
		"chargingType": "Invalid",
		"chargeMode": "MANUAL",
		"chargingSettings": "PROFILE"
	},
	"battery": {
		"cruisingRangeElectricInMeters": 335000,
		"stateOfChargeInPercent": 80
	}
}

GET on https://api.connect.skoda-auto.cz/api/v1/charging/{VIN}/settings

{
	"maxChargeCurrentAc": "Maximum",
	"autoUnlockPlugWhenCharged": "Off",  # Current auto unlock-setting charging plug
	"targetStateOfChargeInPercent": 80
}

@RamonQu
Copy link

RamonQu commented Dec 12, 2022

Off-topic: I just found out an additional state is introduced while it's freezing over here. It's look like a state to prevent the battery from becoming too cold.

	"charging": {
		"state": "ChargePurposeReachedAndConservation",

@ChristophCaina
Copy link
Contributor

I think, I have See this once in my Car.
It was plugged in to my charger - and charged to 80%.

On the Display it showed: charging Limit reached - and will be hold' (or something Like that).

Means: it will start charging whenever Something will use battery (climatization, etc) and the Car will asure that the battery does stay at 80%

@sreichholf
Copy link

sreichholf commented Dec 12, 2022

Means: it will start charging whenever Something will use battery (climatization, etc) and the Car will asure that the battery does stay at 80%

This is exactly what happens in the App, too and.
Once the car is "fully" charged (to the set limit) but stays connected, any kind of consumption will request the required power from the charger.
The german android app, for example, will then show the state as "Erhaltung", which translates to "conservation".

According to https://github.com/tillsteinbach/WeConnect-python/blob/27684caaf15546c31456c922eea25be40a58884c/weconnect/elements/charging_status.py#L110
I would also expect another related state to exist for skoda, too:

'chargePurposeReachedAndNotConservationCharging'

@RamonQu
Copy link

RamonQu commented Dec 12, 2022

Hmm, option doesn't seem to be available in my app currently. Not really sure under which conditions it is available. I will try again later.

@RamonQu
Copy link

RamonQu commented Dec 16, 2022

I successfully managed to retrieve the messages between the app and the skoda servers. The cablelock-setting is not available in the MySkoda-app when the Enyaq is located on a stored charging location (e.g. home) in the car. Don't ask me why ;)

autoUnlockPlugWhenCharged has two states:

	"autoUnlockPlugWhenCharged": "Permanent", // Socket is unlocked after charging is complete
	"autoUnlockPlugWhenCharged": “Off”,       // Socket is locked after charging is complete

The current status (AutoUnlockPlugWhenCharged) is retrieved with GET from https://api.connect.skoda-auto.cz/api/v1/charging/{VIN}/settings

{
	"maxChargeCurrentAc": "Maximum",
	"autoUnlockPlugWhenCharged": "Permanent",
	"targetStateOfChargeInPercent": 80
}

Setting is changed with a POST to https://api.connect.skoda-auto.cz/api/v1/charging/operation-requests?vin={VIN}

Request:
{
	"type": "UpdateSettings",
	"chargingSettings": {
		"targetStateOfChargeInPercent": 80,
		"maxChargeCurrentAc": "Maximum",
		"autoUnlockPlugWhenCharged": "Off"
	},
	"deeplink": "skodaconnect:\/\/addon\/RemoteBatteryChargingAddon?vin={VIN}”
}

Response:

{
	"id": "{transactionID}“,
	"status": "InProgress",
	"deeplink": "skodaconnect://addon/RemoteBatteryChargingAddon?vin={VIN}"
}

Status of mutation is retrieved with GET from

https://api.connect.skoda-auto.cz/api/v1/charging/operation-requests/{transactionID}

{
	"id": "{transactionID}",
	"status": "InProgress",
	"deeplink": "skodaconnect://addon/RemoteBatteryChargingAddon?vin={VIN}"
}

Which keeps polling (currently every 6 seconds) until Successful is retrieved in the status. Changing the setting took me 107 seconds this morning.

{
	"id": "[transactionID}",
	"status": "Successful",
	"deeplink": "skodaconnect://addon/RemoteBatteryChargingAddon?vin={VIN}"
}

@Farfar
Copy link
Collaborator

Farfar commented Dec 25, 2022

Thank you @RamonQu !
Implemented in >=1.1.1 and reported as working.

@Farfar Farfar closed this as completed Dec 25, 2022
@RamonQu
Copy link

RamonQu commented Dec 26, 2022

Great! Just updated to 1.1.4 and tried the cable lock switch. Indeed, works like a charm.

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

No branches or pull requests

5 participants