Mazda EU API Shutdown: Integration Broken After App Update

by Alex Johnson 59 views

Understanding the Impact of the Mazda EU API v1 Shutdown

The Mazda EU API v1 shutdown has caused a significant disruption for users of the mazda_cs integration, particularly those in the European (MME) region. This issue arose following the release of the MyMazda App update 9.0.3, which rendered the existing API integration non-functional. The primary cause is Mazda's migration from API v1 to API v2, leaving the older API endpoints obsolete. This transition has led to a breaking issue that affects login, encryption key retrieval, and authentication processes, effectively disabling the integration for EU users. Identifying the root cause and understanding the scope of the problem are crucial first steps in addressing this challenge. The migration to API v2 necessitates a comprehensive update to the mazda_cs integration, including new API base paths, encryption flows, authentication logic, headers, signature methods, and SDK versions. This is not a minor adjustment but a significant overhaul to align with Mazda's new infrastructure. The complexity of the required changes underscores the importance of a systematic approach, involving detailed analysis, testing, and phased implementation. Furthermore, this situation highlights the importance of proactive communication from Mazda regarding API changes. Clear and timely notifications about API deprecations and transitions can prevent disruptions and allow developers to prepare and adapt their integrations accordingly. In the absence of such communication, the community is left to reactively address issues, leading to frustration and potential service outages. As the integration community works to resolve this issue, it is essential to document the steps taken, the challenges encountered, and the solutions implemented. This documentation will not only aid in the current effort but also serve as a valuable resource for future API migrations and integrations. The collaborative effort required to address this issue underscores the importance of community involvement in maintaining and improving open-source integrations.

What's Broken? Detailed Analysis of the Integration Failure

When analyzing the broken integration, it becomes clear that the core issue lies in the failure to retrieve the encryption key during the login process. The integration attempts to access the following endpoint:

GET https://rz97suam.mazda.com/appapi/v1/system/encryptionKey?appId=MazdaApp&locale=de-DE&deviceId=<device_id>&sdkVersion=11.4.0000

However, instead of receiving the expected JSON response, the endpoint now returns an HTTP 502 Bad Gateway error with text/html content. This indicates that the endpoint is no longer functioning as intended, a clear sign of the API v1 shutdown. The error manifests itself in the Home Assistant logs as an aiohttp.client_exceptions.ContentTypeError, specifically highlighting the attempt to decode JSON with an unexpected mimetype (text/html). This error message provides a precise indication of the problem, allowing developers to focus their troubleshooting efforts. Examining the logs reveals that the issue is consistent across different SDK versions, suggesting that the problem is not specific to a particular version of the MyMazda app or SDK. This consistency reinforces the conclusion that the root cause is the deprecation of the API endpoint itself. The implications of this failure are far-reaching, as the encryption key is a critical component of the authentication process. Without it, the integration cannot establish a secure connection with the Mazda servers, preventing users from accessing vehicle data and functionality. This complete breakdown of the login process underscores the severity of the issue and the urgency of finding a solution. Understanding the technical details of the failure is essential for developing a targeted and effective response. This involves not only identifying the specific error messages but also tracing the flow of the integration to pinpoint the exact point of failure. By gaining a deep understanding of the problem, developers can devise a strategy for migrating to the new API v2 and restoring functionality for affected users.

Reproduction Steps and Affected Regions: Identifying the Scope

To effectively address the Mazda API issue, it's crucial to understand how to reproduce the error and which regions are affected. The reproduction steps are straightforward:

  1. Install the mazda_cs integration.
  2. Set the region to `