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

Added Window-Heater Handling for Skoda Enyaq #62

Merged
merged 13 commits into from
Nov 25, 2022
Merged

Conversation

scoutice
Copy link
Contributor

Added special handling for Skoda Enyaq to read the window heating status

  • added attributes to window_heater for front and rear window
  • read current status from airConditioning/windowsHeatingStatuses instead of airConditioningSettings/windowsHeatingEnabled

Note: airConditioningSettings/windowsHeatingEnabled has been used before. as it it not clear, if this is needed by some car, it was kept and priorizied below the new code

Added special handling for Skoda Enyaq to read the window heating status
* added attributes to window_heater for front and rear window
* read current status from airConditioning/windowsHeatingStatuses instead of airConditioningSettings/windowsHeatingEnabled

Note: airConditioningSettings/windowsHeatingEnabled has been used before. as it it not clear, if this is needed by some car, it was kept and priorizied below the new code
Added special handling for Skoda Enyaq to read the window heating status
* added attributes to window_heater for front and rear window
* read current status from airConditioning/windowsHeatingStatuses instead of airConditioningSettings/windowsHeatingEnabled

Note: airConditioningSettings/windowsHeatingEnabled has been used before. as it it not clear, if this is needed by some car, it was kept and priorizied below the new code
Copy link
Collaborator

@Farfar Farfar left a comment

Choose a reason for hiding this comment

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

The changes to dashboard.py is good for including the attributes of the window heater. It will only benefit the Enyaq though since the attributes included only will get populated for the Enyaq. Keep in mind that the Enyaq is hosted on it's own API (so far) and all other connected Skoda cars are hosted on another API with different endpoints and data structures.
The change would remove the timestamp attribute of when start/stop climatisation was last triggered and the result without adding anything new.
A better way to add the front and rear window heating attributes for the Enyaq would be to create a check if the attributes are supported and then include them as well.

@Farfar
Copy link
Collaborator

Farfar commented Nov 23, 2022

The changes to dashboard.py is good for including the attributes of the window heater. It will only benefit the Enyaq though since the attributes included only will get populated for the Enyaq. Keep in mind that the Enyaq is hosted on it's own API (so far) and all other connected Skoda cars are hosted on another API with different endpoints and data structures. The change would remove the timestamp attribute of when start/stop climatisation was last triggered and the result without adding anything new. A better way to add the front and rear window heating attributes for the Enyaq would be to create a check if the attributes are supported and then include them as well.

I take that back, I forgot that the legacy API also have states for both front and rear windows. The last_result and last_timestamp should still be kept though.

@Farfar
Copy link
Collaborator

Farfar commented Nov 23, 2022

Overall a good addition. I will review the code some more to try and have the same functionality but with fewer rows of code.

@scoutice
Copy link
Contributor Author

shall i add the last_result and last_timestamp again and re-pull or do you merge the code?

@Farfar
Copy link
Collaborator

Farfar commented Nov 23, 2022

shall i add the last_result and last_timestamp again and re-pull or do you merge the code?

I'll readd when I merge 👍🏻

@scoutice
Copy link
Contributor Author

oh, sorry, i just saw that my tests for git (commit within eclipse, add and delete files) seem to be forwarded to the whole pull-request i made.

@Farfar Farfar self-assigned this Nov 25, 2022
Minor changes, variable names and added potential error handling
Copy link
Collaborator

@Farfar Farfar left a comment

Choose a reason for hiding this comment

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

Overall I think this looks good now, thanks for your help!

@@ -597,8 +597,8 @@ def assumed_state(self):
@property
def attributes(self):
return {
'last_result': self.vehicle.climater_action_status,
'last_timestamp': self.vehicle.climater_action_timestamp
"Front":self.vehicle.window_heater_attributes.get("Front", ''),
Copy link
Collaborator

Choose a reason for hiding this comment

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

A better way is to keep the "last_result" and "last_timestamp" and then create a check for if "attributes" are supported, and if so include them as well.

@@ -2143,7 +2143,18 @@ def window_heater(self):
status_rear = self.attrs.get('climater', {}).get('status', {}).get('windowHeatingStatusData', {}).get('windowHeatingStateRear', {}).get('content', '')
if status_rear == 'on':
return True
elif self.attrs.get('airConditioningSettings', {}):
elif self.attrs.get('airConditioning', {}).get('windowsHeatingStatuses', False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

The "windowHeatingStatuses" should be redundant since this check is only to enter this code block if the vehicle is hosted on the new API (Enyaq)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This whole def code block could be shorter if the specific "gets" are kept short for the different API flavors. Then a more generic check can be done for the status_front and status_rear to return True if heating is enabled for either front or rear and both API's.

@Farfar Farfar merged commit 99e2c7d into skodaconnect:main Nov 25, 2022
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 this pull request may close these issues.

None yet

2 participants