skodaconnect / myskoda

Python library for interacting with MySkoda APIs.
MIT License
9 stars 22 forks source link

combustion auxiliary-heater #226

Open prvakt opened 4 days ago

prvakt commented 4 days ago

auxiliary-heater for combustion cars is using different request format so it needs to be handled separately

prvakt commented 3 days ago

decided to have a look into decompiled MySkoda.apk and I think we need to rewrite it a little more. Following parameters are allowed for start-auxiliary-heating request

      name = "spin"
      name = "durationInSeconds"
      name = "startMode"
      name = "targetTemperature"

and there is one more request structure

      name = "spin"
      name = "targetTemperature"
      name = "heaterSource"
      name = "airConditioningWithoutExternalPower"

which is used for most likely AIR_CONDITIONING_HEATING_SOURCE_AUXILIARY capability (the one which is working on my Superb)

WebSpider commented 3 days ago

Thanks @prvakt for putting your time into this!

Looking at the complexity of your last remark, it may be a good idea to use some models to work this out further, combined with

1) A generic method in myskoda to handle the uniform call to the library which then 2) Splits up into multiple myskoda.rest_api calls for addressing the specific API calls down the line

Also: If you have any defaults, such as the 600 seconds for the default heater duration, please add them to const.py and import them, avoid using those directly in code.

prvakt commented 3 days ago

Thanks @prvakt for putting your time into this!

Looking at the complexity of your last remark, it may be a good idea to use some models to work this out further, combined with

  1. A generic method in myskoda to handle the uniform call to the library which then
  2. Splits up into multiple myskoda.rest_api calls for addressing the specific API calls down the line

Also: If you have any defaults, such as the 600 seconds for the default heater duration, please add them to const.py and import them, avoid using those directly in code.

But there is always only single API call to myskoda just with different parameters ...

I don't know if I believe myself in such intervention in the code with my python knowledge especially If I don't have vehicle where I can test it before publishing to the world 🙈

Will try to figure out something heh

prvakt commented 2 days ago

tested everything & works as expected

prvakt commented 2 days ago

found something usefull now, need to test it first

    class Config(BaseConfig):
        serialize_by_alias = True
        omit_none = True
prvakt commented 20 hours ago

checked the decompiled apk one more time and seems like I need to implement 1 additional api request and separate auxiliary class because there are two GET methods

/v2/air-conditioning/{vin}
/v2/air-conditioning/{vin}/auxiliary-heating

the first is already implemented and for my Superb it returns also auxiliary-heating info but the second is probably for combustion vehicles with only auxiliary-heater and structure is slightly different (tried to send this one for my car but it return error 500

prvakt commented 18 hours ago

just to summarize my findings. There are 2 endpoints for retrieving air-conditioning related data

/v2/air-conditioning/{vin}
/v2/air-conditioning/{vin}/auxiliary-heating

PHEV vehicles (or at least my Superb iV) can retrieve AuxiliaryHeater status only from the first method ICE vehicles (based on the discussion and trace from discord) are using second endpoint to retrieve this data # PHEV vehicles can start auxiliary heating using both POST methods

/v2/air-conditioning/{vin}/start
/v2/air-conditioning/{vin}/auxiliary-heating/start

For both methods I can also choose targetTemperature # ICE vehicles can start auxiliary heater using only second POST method

/v2/air-conditioning/{vin}/auxiliary-heating/start

additionally there are follwing options depending on the car

I have implemented auxiliary-heater using the /v2/air-conditioning/{vin}/auxiliary-heating/start endpoint and with the possibility of pass all allowed parameters (source, duration, targetTemp and startMode). Only those which are not None will be serialized and sent inside the request

Retrieval of heating related data can be handled in HA by choosing get_air_conditioning() or get_auxiliary_heating() based on the car type / capability.