Skip to content

Commit 6a4e00a

Browse files
committed
fix(energy): align AuthorizedClientType with Tesla protobuf enum
Replace placeholder LAN=1 with the three values defined in Tesla's AuthorizedClientType enum, as reverse-engineered in pypowerwall's tedapi_combined.proto: INVALID = 0 CUSTOMER_MOBILE_APP = 1 VEHICLE = 2 There is no WiFi-specific value — WiFi vs LAN refers to the transport, not the client type. pypowerwall registers its RSA key as CUSTOMER_MOBILE_APP, so that becomes the default for add_authorized_client. Also document that AuthorizedClientKeyType.RSA=1 is empirically derived; Tesla has not published the full key_type enum body publicly.
1 parent 4e810f3 commit 6a4e00a

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

tesla_fleet_api/const.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,31 @@ class EnergyDeviceIdentifierType(IntEnum):
209209

210210

211211
class AuthorizedClientKeyType(IntEnum):
212-
"""Key type for energy gateway authorized clients."""
212+
"""Key type for energy gateway authorized clients.
213+
214+
Note: Tesla has not published the full ``key_type`` enum body. The RSA
215+
value below is empirically known to work for registering an RSA-4096
216+
key via ``add_authorized_client_request``; other values may exist but
217+
are not publicly documented.
218+
"""
213219

214220
RSA = 1
215221

216222

217223
class AuthorizedClientType(IntEnum):
218-
"""Client type used when registering an authorized client on an energy gateway."""
224+
"""Client type used when registering an authorized client on an energy gateway.
225+
226+
Sourced from Tesla's ``AuthorizedClientType`` protobuf enum (as
227+
reverse-engineered in pypowerwall's ``tedapi_combined.proto``).
228+
229+
There is no WiFi-specific value: WiFi vs LAN refers to the transport,
230+
not the client type. pypowerwall's v1r flow registers its RSA key as
231+
``CUSTOMER_MOBILE_APP``.
232+
"""
219233

220-
LAN = 1
234+
INVALID = 0
235+
CUSTOMER_MOBILE_APP = 1
236+
VEHICLE = 2
221237

222238

223239
class AuthorizedClientState(IntEnum):

tesla_fleet_api/tesla/energysite.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ async def add_authorized_client(
7474
public_key: bytes | str,
7575
description: str = "Powerwall LAN Client",
7676
key_type: AuthorizedClientKeyType | int = AuthorizedClientKeyType.RSA,
77-
authorized_client_type: AuthorizedClientType | int = AuthorizedClientType.LAN,
77+
authorized_client_type: AuthorizedClientType
78+
| int = AuthorizedClientType.CUSTOMER_MOBILE_APP,
7879
) -> dict[str, Any]:
7980
"""Register an authorized client (public key) with the energy gateway.
8081

0 commit comments

Comments
 (0)