Hyundai Bluelink: add Australia and New Zealand regions#30037
Hyundai Bluelink: add Australia and New Zealand regions#30037aldasilva0 wants to merge 4 commits into
Conversation
- Add region parameter to hyundai template (defaults to Europe) - Add AU/NZ config constants to vehicle/bluelink.go - Add TokenURL, UseBasicAuth, and APIHost fields to bluelink.Config - AU region uses Basic auth header instead of client_id/secret in body - AU region uses /api/v1/user/oauth2/token instead of EU token path - Tested with Hyundai Kona, Australian Bluelink account Revives stale PR evcc-io#22760
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- The AU-specific constants added in identity.go (HyundaiAUBaseURI, HyundaiAUCCSPServiceID, etc.) are currently unused and duplicate values defined in bluelink.go; consider removing them or wiring everything through a single source of truth to avoid drift.
- The AU CCSPServiceSecret string in NewHyundaiFromConfig contains a space (
...pviaP p3rf4t3S6k9...), which likely breaks the credential and should be verified and corrected. - There are a few formatting inconsistencies introduced (tabs vs spaces and misaligned struct fields like APIHost in the AU config); cleaning these up will keep the codebase style consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The AU-specific constants added in identity.go (HyundaiAUBaseURI, HyundaiAUCCSPServiceID, etc.) are currently unused and duplicate values defined in bluelink.go; consider removing them or wiring everything through a single source of truth to avoid drift.
- The AU CCSPServiceSecret string in NewHyundaiFromConfig contains a space (`...pviaP p3rf4t3S6k9...`), which likely breaks the credential and should be verified and corrected.
- There are a few formatting inconsistencies introduced (tabs vs spaces and misaligned struct fields like APIHost in the AU config); cleaning these up will keep the codebase style consistent.
## Individual Comments
### Comment 1
<location path="vehicle/bluelink.go" line_range="42-51" />
<code_context>
+ Brand: "hyundai",
+ }
+ case "Australia", "New Zealand":
+ settings = bluelink.Config{
+ URI: "https://au-apigw.ccs.hyundai.com.au:8080",
+ CCSPServiceID: "855c72df-dfd7-4230-ab03-67cbf902bb1c",
+ CCSPServiceSecret: "e6fbwHM32YNbhQl0pviaP p3rf4t3S6k91eceA3MJLdbdThCO",
+ CCSPApplicationID: "f9ccfdac-a48d-4c57-bd32-9116963c24ed",
+ Cfb: "nGDHng3k4Cg9gWV+C+A6Yk/ecDopUNTkGmDpr2qVKAQXx9bvY2/YLoHPfObliK32mZQ=",
</code_context>
<issue_to_address>
**issue (bug_risk):** The AU CCSPServiceSecret contains an embedded space, which is likely to break authentication.
The AU/NZ `CCSPServiceSecret` includes an internal space:
```go
CCSPServiceSecret: "e6fbwHM32YNbhQl0pviaP p3rf4t3S6k91eceA3MJLdbdThCO",
```
Please confirm this matches the exact production secret. If not intentional, remove the space so token requests for AU/NZ don’t fail.
</issue_to_address>
### Comment 2
<location path="vehicle/bluelink/identity.go" line_range="29-34" />
<code_context>
LanguageURL = "/api/v1/user/language"
LoginURL = "/api/v1/user/signin"
TokenURL = "/auth/api/v2/user/oauth2/token"
+ // AU region constants (sourced from hyundai_kia_connect_api KiaUvoApiAU.py)
+ HyundaiAUBaseURI = "https://au-apigw.ccs.hyundai.com.au:8080"
+ HyundaiAUCCSPServiceID = "855c72df-dfd7-4230-ab03-67cbf902bb1c"
+ HyundaiAUCCSPAppID = "f9ccfdac-a48d-4c57-bd32-9116963c24ed"
+ HyundaiAUBasicToken = "Basic ODU1YzcyZGYtZGZkNy00MjMwLWFiMDMtNjdjYmY5MDJiYjFjOmU2ZmJ3SE0zMllOYmhRbDBwdmlhUHAzcmY0dDNTNms5MWVjZUEzTUpMZGJkVGhDTw=="
+ HyundaiAUCfb = "nGDHng3k4Cg9gWV+C+A6Yk/ecDopUNTkGmDpr2qVKAQXx9bvY2/YLoHPfObliK32mZQ="
)
</code_context>
<issue_to_address>
**suggestion:** AU configuration values are duplicated here and in NewHyundaiFromConfig, which may lead to divergence.
These AU constants (base URI, service ID, app ID, basic token, CFB) are also hard-coded in `NewHyundaiFromConfig`, which creates a risk of them getting out of sync. Please centralize the AU configuration (e.g., via these constants or a shared helper) and have `NewHyundaiFromConfig` reuse that single source.
Suggested implementation:
```golang
LanguageURL = "/api/v1/user/language"
LoginURL = "/api/v1/user/signin"
TokenURL = "/auth/api/v2/user/oauth2/token"
// AU region constants (sourced from hyundai_kia_connect_api KiaUvoApiAU.py)
// Centralized here so NewHyundaiFromConfig and any other AU users share a single source.
HyundaiAUBaseURI = "https://au-apigw.ccs.hyundai.com.au:8080"
HyundaiAUCCSPServiceID = "855c72df-dfd7-4230-ab03-67cbf902bb1c"
HyundaiAUCCSPAppID = "f9ccfdac-a48d-4c57-bd32-9116963c24ed"
HyundaiAUBasicToken = "Basic ODU1YzcyZGYtZGZkNy00MjMwLWFiMDMtNjdjYmY5MDJiYjFjOmU2ZmJ3SE0zMllOYmhRbDBwdmlhUHAzcmY0dDNTNms5MWVjZUEzTUpMZGJkVGhDTw=="
HyundaiAUCfb = "nGDHng3k4Cg9gWV+C+A6Yk/ecDopUNTkGmDpr2qVKAQXx9bvY2/YLoHPfObliK32mZQ="
)
```
```golang
// Config is the bluelink API configuration
Cfb string
LoginFormHost string
Brand string
TokenURL string
APIHost string // used as Host header for AU-style APIs
UseBasicAuth bool
}
```
To fully centralize the AU configuration and avoid divergence:
1. In `NewHyundaiFromConfig` (and any other AU-specific initialization logic in `identity.go`), replace any hard-coded AU literals with references to these constants:
- `"https://au-apigw.ccs.hyundai.com.au:8080"` → `HyundaiAUBaseURI`
- `"855c72df-dfd7-4230-ab03-67cbf902bb1c"` → `HyundaiAUCCSPServiceID`
- `"f9ccfdac-a48d-4c57-bd32-9116963c24ed"` → `HyundaiAUCCSPAppID`
- `"Basic ODU1YzcyZGYtZGZkNy00MjMwLWFiMDMtNjdjYmY5MDJiYjFjOmU2ZmJ3SE0zMllOYmhRbDBwdmlhUHAzcmY0dDNTNms5MWVjZUEzTUpMZGJkVGhDTw=="` → `HyundaiAUBasicToken`
- `"nGDHng3k4Cg9gWV+C+A6Yk/ecDopUNTkGmDpr2qVKAQXx9bvY2/YLoHPfObliK32mZQ="` → `HyundaiAUCfb`
2. If `NewHyundaiFromConfig` currently sets `APIHost`, `Cfb`, `UseBasicAuth`, etc. based on region with AU literals, update those assignments to use the corresponding constants above.
3. If there are unit tests that assert on the literal AU values, update them to assert against the constants, or at least derive their expectations from these constants to keep a single source of truth.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| settings = bluelink.Config{ | ||
| URI: "https://prd.eu-ccapi.hyundai.com:8080", | ||
| CCSPServiceID: "6d477c38-3ca4-4cf3-9557-2a1929a94654", | ||
| CCSPServiceSecret: "KUy49XxPzLpLuoK0xhBC77W6VXhmtQR9iQhmIFjjoY4IpxsV", | ||
| CCSPApplicationID: "014d2225-8495-4735-812d-2616334fd15d", | ||
| Cfb: "RFtoRq/vDXJmRndoZaZQyfOot7OrIqGVFj96iY2WL3yyH5Z/pUvlUhqmCxD2t+D65SQ=", | ||
| BasicToken: "NmQ0NzdjMzgtM2NhNC00Y2YzLTk1NTctMmExOTI5YTk0NjU0OktVeTQ5WHhQekxwTHVvSzB4aEJDNzdXNlZYaG10UVI5aVFobUlGampvWTRJcHhzVg==", | ||
| PushType: "GCM", | ||
| LoginFormHost: "https://idpconnect-eu.hyundai.com", | ||
| Brand: "hyundai", |
There was a problem hiding this comment.
issue (bug_risk): The AU CCSPServiceSecret contains an embedded space, which is likely to break authentication.
The AU/NZ CCSPServiceSecret includes an internal space:
CCSPServiceSecret: "e6fbwHM32YNbhQl0pviaP p3rf4t3S6k91eceA3MJLdbdThCO",Please confirm this matches the exact production secret. If not intentional, remove the space so token requests for AU/NZ don’t fail.
| // AU region constants (sourced from hyundai_kia_connect_api KiaUvoApiAU.py) | ||
| HyundaiAUBaseURI = "https://au-apigw.ccs.hyundai.com.au:8080" | ||
| HyundaiAUCCSPServiceID = "855c72df-dfd7-4230-ab03-67cbf902bb1c" | ||
| HyundaiAUCCSPAppID = "f9ccfdac-a48d-4c57-bd32-9116963c24ed" | ||
| HyundaiAUBasicToken = "Basic ODU1YzcyZGYtZGZkNy00MjMwLWFiMDMtNjdjYmY5MDJiYjFjOmU2ZmJ3SE0zMllOYmhRbDBwdmlhUHAzcmY0dDNTNms5MWVjZUEzTUpMZGJkVGhDTw==" | ||
| HyundaiAUCfb = "nGDHng3k4Cg9gWV+C+A6Yk/ecDopUNTkGmDpr2qVKAQXx9bvY2/YLoHPfObliK32mZQ=" |
There was a problem hiding this comment.
suggestion: AU configuration values are duplicated here and in NewHyundaiFromConfig, which may lead to divergence.
These AU constants (base URI, service ID, app ID, basic token, CFB) are also hard-coded in NewHyundaiFromConfig, which creates a risk of them getting out of sync. Please centralize the AU configuration (e.g., via these constants or a shared helper) and have NewHyundaiFromConfig reuse that single source.
Suggested implementation:
LanguageURL = "/api/v1/user/language"
LoginURL = "/api/v1/user/signin"
TokenURL = "/auth/api/v2/user/oauth2/token"
// AU region constants (sourced from hyundai_kia_connect_api KiaUvoApiAU.py)
// Centralized here so NewHyundaiFromConfig and any other AU users share a single source.
HyundaiAUBaseURI = "https://au-apigw.ccs.hyundai.com.au:8080"
HyundaiAUCCSPServiceID = "855c72df-dfd7-4230-ab03-67cbf902bb1c"
HyundaiAUCCSPAppID = "f9ccfdac-a48d-4c57-bd32-9116963c24ed"
HyundaiAUBasicToken = "Basic ODU1YzcyZGYtZGZkNy00MjMwLWFiMDMtNjdjYmY5MDJiYjFjOmU2ZmJ3SE0zMllOYmhRbDBwdmlhUHAzcmY0dDNTNms5MWVjZUEzTUpMZGJkVGhDTw=="
HyundaiAUCfb = "nGDHng3k4Cg9gWV+C+A6Yk/ecDopUNTkGmDpr2qVKAQXx9bvY2/YLoHPfObliK32mZQ="
)// Config is the bluelink API configuration
Cfb string
LoginFormHost string
Brand string
TokenURL string
APIHost string // used as Host header for AU-style APIs
UseBasicAuth bool
}To fully centralize the AU configuration and avoid divergence:
-
In
NewHyundaiFromConfig(and any other AU-specific initialization logic inidentity.go), replace any hard-coded AU literals with references to these constants:"https://au-apigw.ccs.hyundai.com.au:8080"→HyundaiAUBaseURI"855c72df-dfd7-4230-ab03-67cbf902bb1c"→HyundaiAUCCSPServiceID"f9ccfdac-a48d-4c57-bd32-9116963c24ed"→HyundaiAUCCSPAppID"Basic ODU1YzcyZGYtZGZkNy00MjMwLWFiMDMtNjdjYmY5MDJiYjFjOmU2ZmJ3SE0zMllOYmhRbDBwdmlhUHAzcmY0dDNTNms5MWVjZUEzTUpMZGJkVGhDTw=="→HyundaiAUBasicToken"nGDHng3k4Cg9gWV+C+A6Yk/ecDopUNTkGmDpr2qVKAQXx9bvY2/YLoHPfObliK32mZQ="→HyundaiAUCfb
-
If
NewHyundaiFromConfigcurrently setsAPIHost,Cfb,UseBasicAuth, etc. based on region with AU literals, update those assignments to use the corresponding constants above. -
If there are unit tests that assert on the literal AU values, update them to assert against the constants, or at least derive their expectations from these constants to keep a single source of truth.
| LoginFormHost: "https://au-apigw.ccs.hyundai.com.au:8080", | ||
| TokenURL: "/api/v1/user/oauth2/token", | ||
| Brand: "hyundai", | ||
| APIHost: "au-apigw.ccs.hyundai.com.au:8080", |
|
ping @aldasilva0 pls check if you want to finish this ;) |
Problem
Australian Hyundai Bluelink users receive a
400 Bad Requestregardlessof credentials because their accounts are on a different backend
(au-apigw.ccs.hyundai.com.au:8080) with a different auth flow than the
EU API. There is no way to configure the region in the current template.
Solution
regionparameter to thehyundaitemplate (defaults toEurope— fully backward compatible, no existing configs break)Authorization: Basicheader auth instead ofclient_id/client_secretin the request body/api/v1/user/oauth2/tokeninstead of the EU token pathhyundai_kia_connect_apilibrary(KiaUvoApiAU.py), the same library used by the Home Assistant
Kia/Hyundai integration which already supports AU
Testing
Tested with Hyundai Kona, Australian Bluelink account,
region: Australia.Successfully retrieves SoC via
evcc vehiclecommand.Relates to
Revives stale PR #22760, fix #29987