daybetter-services-python 1.0.0__tar.gz → 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {daybetter_services_python-1.0.0/daybetter_services_python.egg-info → daybetter_services_python-1.0.1}/PKG-INFO +1 -1
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/daybetter_python/__init__.py +1 -1
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/daybetter_python/client.py +45 -1
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1/daybetter_services_python.egg-info}/PKG-INFO +1 -1
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/pyproject.toml +1 -1
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/setup.py +1 -1
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/LICENSE +0 -0
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/README.md +0 -0
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/daybetter_python/exceptions.py +0 -0
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/daybetter_services_python.egg-info/SOURCES.txt +0 -0
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/daybetter_services_python.egg-info/dependency_links.txt +0 -0
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/daybetter_services_python.egg-info/requires.txt +0 -0
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/daybetter_services_python.egg-info/top_level.txt +0 -0
- {daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/setup.cfg +0 -0
{daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/daybetter_python/client.py
RENAMED
|
@@ -15,7 +15,7 @@ class DayBetterClient:
|
|
|
15
15
|
def __init__(
|
|
16
16
|
self,
|
|
17
17
|
token: str,
|
|
18
|
-
base_url: str = "https://
|
|
18
|
+
base_url: str = "https://cloud.v2.dbiot.link/daybetter/hass/api/v1.0/"
|
|
19
19
|
):
|
|
20
20
|
"""Initialize the client.
|
|
21
21
|
|
|
@@ -248,6 +248,50 @@ class DayBetterClient:
|
|
|
248
248
|
_LOGGER.exception("Exception while fetching MQTT config: %s", e)
|
|
249
249
|
raise DayBetterError(f"Unexpected error: {e}")
|
|
250
250
|
|
|
251
|
+
async def fetch_device_statuses(self) -> List[Dict[str, Any]]:
|
|
252
|
+
"""Fetch statuses for all devices.
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
List of device status dictionaries. Example item:
|
|
256
|
+
{
|
|
257
|
+
"deviceName": str,
|
|
258
|
+
"type": int,
|
|
259
|
+
"online": bool,
|
|
260
|
+
"temp": int,
|
|
261
|
+
"humi": int,
|
|
262
|
+
"bettery": int
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
Raises:
|
|
266
|
+
AuthenticationError: If authentication fails
|
|
267
|
+
APIError: If API request fails
|
|
268
|
+
"""
|
|
269
|
+
try:
|
|
270
|
+
session = self._get_session()
|
|
271
|
+
url = f"{self.base_url}hass/status"
|
|
272
|
+
headers = self._get_headers()
|
|
273
|
+
|
|
274
|
+
async with session.post(url, headers=headers) as resp:
|
|
275
|
+
if resp.status == 200:
|
|
276
|
+
data = await resp.json()
|
|
277
|
+
self._auth_valid = True
|
|
278
|
+
# API expected to return { "data": [...] }
|
|
279
|
+
return data.get("data", [])
|
|
280
|
+
elif resp.status == 401:
|
|
281
|
+
_LOGGER.error("Authentication failed - token may be expired")
|
|
282
|
+
self._auth_valid = False
|
|
283
|
+
raise AuthenticationError("Authentication failed - token may be expired")
|
|
284
|
+
else:
|
|
285
|
+
error_text = await resp.text()
|
|
286
|
+
_LOGGER.error("Failed to fetch device statuses: %s", error_text)
|
|
287
|
+
raise APIError(f"API error {resp.status}: {error_text}")
|
|
288
|
+
except aiohttp.ClientError as e:
|
|
289
|
+
_LOGGER.exception("Client error while fetching device statuses: %s", e)
|
|
290
|
+
raise APIError(f"Client error: {e}")
|
|
291
|
+
except Exception as e:
|
|
292
|
+
_LOGGER.exception("Exception while fetching device statuses: %s", e)
|
|
293
|
+
raise DayBetterError(f"Unexpected error: {e}")
|
|
294
|
+
|
|
251
295
|
@property
|
|
252
296
|
def is_authenticated(self) -> bool:
|
|
253
297
|
"""Check if the API client is authenticated."""
|
|
File without changes
|
|
File without changes
|
{daybetter_services_python-1.0.0 → daybetter_services_python-1.0.1}/daybetter_python/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|