HomeAssistant-API 3.0.3.post2__tar.gz → 3.0.3.post3__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.
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/PKG-INFO +1 -1
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/_async/asyncclient.py +8 -2
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/processing.py +4 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/rawapi.py +4 -4
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/rawclient.py +6 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/pyproject.toml +3 -3
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/setup.py +1 -1
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/LICENSE +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/README.md +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/__init__.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/_async/__init__.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/_async/models/__init__.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/_async/models/domains.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/_async/models/entity.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/_async/models/events.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/client.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/const.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/errors.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/mixins.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/__init__.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/base.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/domains.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/entity.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/events.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/history.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/logbook.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/states.py +0 -0
- {HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/py.typed +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Module for interacting with Home Assistant asyncronously."""
|
|
2
2
|
import asyncio
|
|
3
|
+
import logging
|
|
3
4
|
from typing import Any, AsyncGenerator, Dict, List, Optional, Tuple, Union, cast
|
|
4
5
|
from urllib.parse import urljoin as join
|
|
5
6
|
|
|
@@ -13,6 +14,8 @@ from ..processing import Processing
|
|
|
13
14
|
from ..rawapi import RawWrapper
|
|
14
15
|
from .models import AsyncEntity, AsyncGroup
|
|
15
16
|
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
16
19
|
|
|
17
20
|
class RawAsyncClient(RawWrapper, JsonProcessingMixin):
|
|
18
21
|
"""
|
|
@@ -26,7 +29,10 @@ class RawAsyncClient(RawWrapper, JsonProcessingMixin):
|
|
|
26
29
|
_async_session: Optional[CachedSession] = None
|
|
27
30
|
|
|
28
31
|
async def __aenter__(self):
|
|
29
|
-
self._async_session = CachedSession(
|
|
32
|
+
self._async_session = CachedSession(
|
|
33
|
+
expire_after=self.cache_expire_after, cache=self.cache_backend
|
|
34
|
+
)
|
|
35
|
+
logger.debug(f"Entering cached requests session {self._async_session!r}")
|
|
30
36
|
await self._async_session.__aenter__()
|
|
31
37
|
await self.async_check_api_running()
|
|
32
38
|
return self
|
|
@@ -197,7 +203,7 @@ class RawAsyncClient(RawWrapper, JsonProcessingMixin):
|
|
|
197
203
|
) -> List[State]:
|
|
198
204
|
"""Tells Home Assistant to trigger a service, returns stats changed while being called"""
|
|
199
205
|
data = await self.async_request(
|
|
200
|
-
|
|
206
|
+
f"services/{domain}/{service}",
|
|
201
207
|
method="POST",
|
|
202
208
|
json=service_data,
|
|
203
209
|
)
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/processing.py
RENAMED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import inspect
|
|
4
4
|
import json
|
|
5
|
+
import logging
|
|
5
6
|
import sys
|
|
6
7
|
from typing import Any, Callable, ClassVar, Dict, Tuple, Union, cast
|
|
7
8
|
|
|
@@ -22,6 +23,8 @@ from .errors import (
|
|
|
22
23
|
)
|
|
23
24
|
from .models import BaseModel
|
|
24
25
|
|
|
26
|
+
logger = logging.getLogger(__name__)
|
|
27
|
+
|
|
25
28
|
|
|
26
29
|
class Processing(BaseModel):
|
|
27
30
|
"""Uses to processor functions to convert json data into common python data types."""
|
|
@@ -49,6 +52,7 @@ class Processing(BaseModel):
|
|
|
49
52
|
mimetype = self.response.headers.get("content-type", "text/plain") # type: ignore[arg-type]
|
|
50
53
|
for processor in self._processors.get(mimetype, ()):
|
|
51
54
|
if not _async ^ inspect.iscoroutinefunction(processor):
|
|
55
|
+
logger.debug(f"Using processor {processor!r} on {self.response!r}")
|
|
52
56
|
return processor(self.response)
|
|
53
57
|
if _async:
|
|
54
58
|
raise ProcessorNotFoundError(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"""Module for parent RawWrapper class"""
|
|
2
2
|
|
|
3
|
-
import os
|
|
4
3
|
import re
|
|
5
4
|
from datetime import datetime
|
|
6
5
|
from typing import Dict, Optional, Tuple, Union
|
|
6
|
+
from urllib.parse import urljoin as join
|
|
7
7
|
|
|
8
8
|
from .const import DATE_FMT
|
|
9
9
|
from .models import Entity
|
|
@@ -42,7 +42,7 @@ class RawWrapper:
|
|
|
42
42
|
|
|
43
43
|
def endpoint(self, path: str) -> str:
|
|
44
44
|
"""Joins the api base url with a local path to an absolute url"""
|
|
45
|
-
return
|
|
45
|
+
return join(self.api_url, path)
|
|
46
46
|
|
|
47
47
|
@property
|
|
48
48
|
def _headers(self) -> Dict[str, str]:
|
|
@@ -122,7 +122,7 @@ class RawWrapper:
|
|
|
122
122
|
if start_timestamp is not None:
|
|
123
123
|
if isinstance(start_timestamp, datetime):
|
|
124
124
|
formatted_timestamp = start_timestamp.strftime(DATE_FMT)
|
|
125
|
-
url =
|
|
125
|
+
url = join("history/period", formatted_timestamp)
|
|
126
126
|
else:
|
|
127
127
|
raise TypeError(f"timestamp needs to be of type {datetime!r}")
|
|
128
128
|
else:
|
|
@@ -148,7 +148,7 @@ class RawWrapper:
|
|
|
148
148
|
if start_timestamp is not None:
|
|
149
149
|
if isinstance(start_timestamp, datetime):
|
|
150
150
|
formatted_timestamp = start_timestamp.strftime(DATE_FMT)
|
|
151
|
-
url =
|
|
151
|
+
url = join("logbook", formatted_timestamp)
|
|
152
152
|
else:
|
|
153
153
|
url = "logbook"
|
|
154
154
|
return params, url
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/rawclient.py
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Module for all interaction with homeassistant."""
|
|
2
2
|
|
|
3
|
+
import logging
|
|
3
4
|
from typing import Any, Dict, Generator, List, Optional, Tuple, Union, cast
|
|
4
5
|
from urllib.parse import urljoin as join
|
|
5
6
|
|
|
@@ -12,6 +13,8 @@ from .models import Domain, Entity, Event, Group, History, LogbookEntry, State
|
|
|
12
13
|
from .processing import Processing
|
|
13
14
|
from .rawapi import RawWrapper
|
|
14
15
|
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
15
18
|
|
|
16
19
|
class RawClient(RawWrapper, JsonProcessingMixin):
|
|
17
20
|
"""
|
|
@@ -29,12 +32,14 @@ class RawClient(RawWrapper, JsonProcessingMixin):
|
|
|
29
32
|
expire_after=self.cache_expire_after,
|
|
30
33
|
backend=self.cache_backend,
|
|
31
34
|
)
|
|
35
|
+
logger.debug(f"Entering cached requests session {self._session!r}")
|
|
32
36
|
self._session.__enter__()
|
|
33
37
|
self.check_api_running()
|
|
34
38
|
self.check_api_config()
|
|
35
39
|
return self
|
|
36
40
|
|
|
37
41
|
def __exit__(self, *args):
|
|
42
|
+
logger.debug(f"Exiting requests session {self._session!r}")
|
|
38
43
|
self._session.__exit__()
|
|
39
44
|
self._session = None
|
|
40
45
|
|
|
@@ -49,6 +54,7 @@ class RawClient(RawWrapper, JsonProcessingMixin):
|
|
|
49
54
|
try:
|
|
50
55
|
if self.global_request_kwargs is not None:
|
|
51
56
|
kwargs.update(self.global_request_kwargs)
|
|
57
|
+
logger.debug(f"{method} request to {self.endpoint(path)}")
|
|
52
58
|
if self._session is not None:
|
|
53
59
|
resp = self._session.request(
|
|
54
60
|
method,
|
|
@@ -17,7 +17,7 @@ name = "HomeAssistant-API"
|
|
|
17
17
|
readme = "README.md"
|
|
18
18
|
include = ["homeassistant_api/py.typed"]
|
|
19
19
|
repository = "https://github.com/GrandMoff100/HomeAssistantAPI"
|
|
20
|
-
version = "3.0.3.
|
|
20
|
+
version = "3.0.3.post3"
|
|
21
21
|
[tool.poetry.dependencies]
|
|
22
22
|
aiohttp = "^3.8.1"
|
|
23
23
|
aiohttp-client-cache = "^0.6.1"
|
|
@@ -27,7 +27,7 @@ requests = "^2.26.0"
|
|
|
27
27
|
requests-cache = "^0.9.2"
|
|
28
28
|
simplejson = "^3.17.6"
|
|
29
29
|
[tool.poetry.dev-dependencies]
|
|
30
|
-
black = "^
|
|
30
|
+
black = "^22.3.0"
|
|
31
31
|
flake8 = "^4.0.1"
|
|
32
32
|
isort = "^5.10.1"
|
|
33
33
|
pre-commit = "^2.17.0"
|
|
@@ -50,4 +50,4 @@ include = "homeassistant_api"
|
|
|
50
50
|
extension-pkg-whitelist = ["pydantic"]
|
|
51
51
|
ignore-paths = ["examples"]
|
|
52
52
|
[tool.pylint.messages_control]
|
|
53
|
-
disable = ["invalid-name", "duplicate-code", "no-member", "too-few-public-methods", "too-many-arguments"]
|
|
53
|
+
disable = ["invalid-name", "duplicate-code", "no-member", "too-few-public-methods", "too-many-arguments", "logging-fstring-interpolation"]
|
|
@@ -20,7 +20,7 @@ install_requires = \
|
|
|
20
20
|
|
|
21
21
|
setup_kwargs = {
|
|
22
22
|
'name': 'homeassistant-api',
|
|
23
|
-
'version': '3.0.3.
|
|
23
|
+
'version': '3.0.3.post3',
|
|
24
24
|
'description': "Python Wrapper for Homeassistant's REST API",
|
|
25
25
|
'long_description': '# HomeassistantAPI\n\n[](https://pypi.org/project/homeassistant_api)\n\n[](https://homeassistantapi.readthedocs.io/en/latest/?badge=latest)\n[](https://github.com/GrandMoff100/HomeassistantAPI/releases)\n\n[](https://home-assistant.io)\n\n## Python wrapper for Homeassistant\'s [REST API](https://developers.home-assistant.io/docs/api/rest/)\n\nHere is a quick example.\n```py\nfrom homeassistant_api import Client\n\nwith Client(\n \'<API Server URL>\',\n \'<Your Long Lived Access-Token>\'\n) as client:\n\n light = client.get_domain("light")\n\n light.turn_on(entity_id=\'light.living_room_lamp\')\n```\nAll the methods also support async!\n\n## Documentation\nAll documentation, API reference, contribution guidelines and pretty much everything else\nyou\'d want to know is on our readthedocs site [here](https://homeassistantapi.readthedocs.io)\n\nIf there is something missing, open an issue and let us know! Thanks!\n\nGo make some cool stuff! Maybe come back and tell us about it in a\n[discussion](https://github.com/GrandMoff100/HomeAssistantAPI/discussions)?\nWe\'d love to hear about how you use our library!!\n\n## License\n\nThis project is under the GNU GPLv3 license, as defined by the Free Software Foundation.\n',
|
|
26
26
|
'author': 'GrandMoff100',
|
|
File without changes
|
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/__init__.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/_async/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/__init__.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/base.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/domains.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/entity.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/events.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/history.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/logbook.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post2 → HomeAssistant-API-3.0.3.post3}/homeassistant_api/models/states.py
RENAMED
|
File without changes
|
|
File without changes
|