Skip to content

Commit

Permalink
v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Mar 25, 2024
1 parent 9798834 commit ff3ffe7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="teslemetry_stream",
version="0.2.0",
version="0.2.1",
author="Brett Adams",
author_email="[email protected]",
description="Teslemetry Streaming API library for Python",
Expand Down
36 changes: 36 additions & 0 deletions teslemetry_stream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,42 @@ async def get_config(self, vin: str | None = None) -> None:
if not response.get("synced"):
LOGGER.warning("Vehicle configuration not active")

async def change_hostname(self, hostname: str, vin: str | None = None) -> dict:
"""Update Fleet Telemetry hostname"""
resp = await self._session.patch(
f"https://api.teslemetry.com/api/config/{vin or self.vin}",
headers=self._headers,
json={"hostname": hostname},
raise_for_status=True,
)
if resp.ok:
self.server = hostname
return await resp.json()

async def update_fields(self, fields: dict, vin: str | None = None) -> dict:
"""Update Fleet Telemetry configuration"""
resp = await self._session.patch(
f"https://api.teslemetry.com/api/config/{vin or self.vin}",
headers=self._headers,
json={"fields": fields},
raise_for_status=True,
)
if resp.ok:
self.fields = {**self.fields, **fields}
return await resp.json()

async def replace_fields(self, fields: dict, vin: str | None = None) -> dict:
"""Replace Fleet Telemetry configuration"""
resp = await self._session.post(
f"https://api.teslemetry.com/api/config/{vin or self.vin}",
headers=self._headers,
json={"fields": fields},
raise_for_status=True,
)
if resp.ok:
self.fields = fields
return await resp.json()

@property
def config(self) -> dict:
"""Return current configuration."""
Expand Down

0 comments on commit ff3ffe7

Please sign in to comment.