Skip to content

Commit

Permalink
Add documentation about usage of undocumentet API usage (#128)
Browse files Browse the repository at this point in the history
* Add documentation about usage of undocumented API usage
* Remove comments
  • Loading branch information
sveinse authored Oct 20, 2024
1 parent 8ca7d6e commit 549f665
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ Next the **Zaptec setup** dialog is presented. Fill in the form:

# Usage

> :information_source: This integration use the
[official Web API](https://api.zaptec.com/help/index.html) provided by Zaptec.
However, this integration also use a few functions that are not officially
supported by the API. Use at own risk and they might break at any time.
>
> * Setting authorization required
> * Circuit info
> * Setting charger min and max current
> * Authorize charging
> * Setting cable lock
## Zaptec device concept

The Zaptec cloud API use three levels of abstractions in their EVCP setup. These are
Expand Down
9 changes: 7 additions & 2 deletions custom_components/zaptec/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ async def state(self):
self.set_attributes(data)

async def live_stream_connection_details(self):
# NOTE: API call deprecated
data = await self._account._request(
f"installation/{self.id}/messagingConnectionDetails"
)
Expand All @@ -280,7 +281,6 @@ async def stream(self, cb=None) -> asyncio.Task:
from azure.servicebus.exceptions import ServiceBusError
except ImportError:
_LOGGER.debug("Azure Service bus is not available. Resolving to polling")
# https://github.com/custom-components/zaptec/issues
return

await self.cancel_stream()
Expand All @@ -297,7 +297,6 @@ async def _stream(self, cb=None):
_LOGGER.warning(
"Azure Service bus is not available. Resolving to polling"
)
# https://github.com/custom-components/zaptec/issues
return

# Get connection details
Expand Down Expand Up @@ -461,6 +460,7 @@ async def set_authentication_required(self, required: bool):
"Id": self.id,
"IsRequiredAuthentication": required,
}
# NOTE: Undocumented API call
result = await self._account._request(
f"installation/{self.id}", method="put", data=data
)
Expand Down Expand Up @@ -510,6 +510,7 @@ async def state(self):

async def circuit_info(self) -> TDict:
"""Raw request for circuit data"""
# NOTE: Undocumented API call. circuit is no longer part of the official docs
data = await self._account._request(f"circuits/{self.id}")
return data

Expand Down Expand Up @@ -598,6 +599,7 @@ async def state(self):

# Fetch some additional attributes from settings
try:
# NOTE: Undocumented API call
settings = await self._account._request(f"chargers/{self.id}/settings")
data = self.state_to_attrs(settings.values(), "SettingId", ZCONST.settings)
self.set_attributes(data)
Expand Down Expand Up @@ -631,6 +633,7 @@ async def live(self):

# This don't seems to be documented but the portal uses it
# FIXME check what it returns and parse it to attributes
# NOTE: Undocumented API call
data = await self._account._request(f"chargers/{self.id}/live")
# FIXME: Missing validator (see validate)
return data
Expand Down Expand Up @@ -678,6 +681,7 @@ async def set_settings(self, settings: dict[str, Any]):
raise ValueError(f"Unknown setting '{settings}'")

_LOGGER.debug("Settings %s", settings)
# NOTE: Undocumented API call
data = await self._account._request(
f"chargers/{self.id}/settings", method="post", data=values
)
Expand All @@ -700,6 +704,7 @@ async def upgrade_firmware(self):

async def authorize_charge(self):
_LOGGER.debug("Authorize charge")
# NOTE: Undocumented API call
data = await self._account._request(
f"chargers/{self.id}/authorizecharge", method="post"
)
Expand Down

0 comments on commit 549f665

Please sign in to comment.