HomeAssistant-API 3.0.3.post5__tar.gz → 3.0.4__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.post5 → HomeAssistant-API-3.0.4}/PKG-INFO +2 -2
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/asyncclient.py +8 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/models/domains.py +15 -7
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/models/entity.py +1 -1
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/__init__.py +5 -1
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/domains.py +12 -3
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/pyproject.toml +2 -2
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/setup.py +2 -2
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/LICENSE +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/README.md +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/__init__.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/__init__.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/models/__init__.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/models/events.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/client.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/const.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/errors.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/mixins.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/base.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/entity.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/events.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/history.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/logbook.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/states.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/processing.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/py.typed +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/rawapi.py +0 -0
- {HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/rawclient.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: homeassistant-api
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.4
|
|
4
4
|
Summary: Python Wrapper for Homeassistant's REST API
|
|
5
5
|
Home-page: https://github.com/GrandMoff100/HomeAssistantAPI
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -14,7 +14,7 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.9
|
|
15
15
|
Requires-Dist: aiohttp (>=3.8.1,<4.0.0)
|
|
16
16
|
Requires-Dist: aiohttp-client-cache (>=0.6.1,<0.7.0)
|
|
17
|
-
Requires-Dist: pydantic (
|
|
17
|
+
Requires-Dist: pydantic (<=1.9.0)
|
|
18
18
|
Requires-Dist: requests (>=2.26.0,<3.0.0)
|
|
19
19
|
Requires-Dist: requests-cache (>=0.9.2,<0.10.0)
|
|
20
20
|
Requires-Dist: simplejson (>=3.17.6,<4.0.0)
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/asyncclient.py
RENAMED
|
@@ -206,6 +206,14 @@ class RawAsyncClient(RawWrapper, JsonProcessingMixin):
|
|
|
206
206
|
)
|
|
207
207
|
return tuple(services)
|
|
208
208
|
|
|
209
|
+
async def async_get_domain(self, domain_id: str) -> Optional[Domain]:
|
|
210
|
+
"""Fetchers all services under a particular domain."""
|
|
211
|
+
domains = await self.async_get_domains()
|
|
212
|
+
for domain in domains:
|
|
213
|
+
if domain.domain_id == domain_id:
|
|
214
|
+
return domain
|
|
215
|
+
return None
|
|
216
|
+
|
|
209
217
|
async def async_trigger_service(
|
|
210
218
|
self,
|
|
211
219
|
domain: str,
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/models/domains.py
RENAMED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, cast
|
|
4
4
|
|
|
5
|
-
from pydantic import
|
|
5
|
+
from pydantic import Field, validator
|
|
6
6
|
|
|
7
|
-
from ...models import State
|
|
8
|
-
from ...models.domains import ServiceField
|
|
7
|
+
from ...models import ServiceField, State, base
|
|
9
8
|
|
|
10
9
|
if TYPE_CHECKING:
|
|
11
10
|
from homeassistant_api import Client
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
class AsyncDomain(BaseModel):
|
|
13
|
+
class AsyncDomain(base.BaseModel):
|
|
15
14
|
"""A class representing the domain that services belong to."""
|
|
16
15
|
|
|
17
16
|
domain_id: str
|
|
@@ -30,7 +29,7 @@ class AsyncDomain(BaseModel):
|
|
|
30
29
|
}
|
|
31
30
|
)
|
|
32
31
|
|
|
33
|
-
def get_service(self, service_id: str):
|
|
32
|
+
def get_service(self, service_id: str) -> Optional["AsyncService"]:
|
|
34
33
|
"""Return a Service with the given service_id, returns None if no such service exists"""
|
|
35
34
|
return self.services.get(service_id)
|
|
36
35
|
|
|
@@ -43,16 +42,25 @@ class AsyncDomain(BaseModel):
|
|
|
43
42
|
return super().__getattribute__(attr)
|
|
44
43
|
|
|
45
44
|
|
|
46
|
-
class AsyncService(BaseModel):
|
|
45
|
+
class AsyncService(base.BaseModel):
|
|
47
46
|
"""Class representing services from homeassistant"""
|
|
48
47
|
|
|
49
48
|
service_id: str
|
|
50
|
-
domain: AsyncDomain
|
|
49
|
+
domain: AsyncDomain = Field(exlude=True, repr=False)
|
|
51
50
|
name: Optional[str] = None
|
|
52
51
|
description: Optional[str] = None
|
|
53
52
|
fields: Optional[Dict[str, ServiceField]] = None
|
|
54
53
|
target: Optional[Dict[str, dict]] = None
|
|
55
54
|
|
|
55
|
+
@classmethod
|
|
56
|
+
@validator("domain")
|
|
57
|
+
def validate_domain(cls, domain: AsyncDomain) -> AsyncDomain:
|
|
58
|
+
"""
|
|
59
|
+
Explicitly do nothing to validate the parent domain.
|
|
60
|
+
Elimintates recursive validation errors.
|
|
61
|
+
"""
|
|
62
|
+
return domain
|
|
63
|
+
|
|
56
64
|
async def async_trigger(self, **service_data) -> Tuple[State, ...]:
|
|
57
65
|
"""Triggers the service associated with this object."""
|
|
58
66
|
data = await self.domain.client.async_trigger_service(
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/models/entity.py
RENAMED
|
@@ -34,7 +34,7 @@ class AsyncEntity(BaseModel):
|
|
|
34
34
|
|
|
35
35
|
slug: str
|
|
36
36
|
state: State
|
|
37
|
-
group: AsyncGroup
|
|
37
|
+
group: AsyncGroup = Field(exclude=True, repr=False)
|
|
38
38
|
|
|
39
39
|
async def async_get_state(self) -> State:
|
|
40
40
|
"""Asks Home Assistant for the state of the entity and sets it locally"""
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/__init__.py
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""The Model objects for the entire library."""
|
|
2
2
|
from .base import BaseModel
|
|
3
|
-
from .domains import Domain, Service
|
|
3
|
+
from .domains import Domain, Service, ServiceField
|
|
4
4
|
from .entity import Entity, Group
|
|
5
5
|
from .events import Event
|
|
6
6
|
from .history import History
|
|
@@ -10,6 +10,10 @@ from .states import State
|
|
|
10
10
|
__all__ = (
|
|
11
11
|
"Domain",
|
|
12
12
|
"Service",
|
|
13
|
+
"BaseModel",
|
|
14
|
+
"Domain",
|
|
15
|
+
"Service",
|
|
16
|
+
"ServiceField",
|
|
13
17
|
"Entity",
|
|
14
18
|
"Group",
|
|
15
19
|
"Event",
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/domains.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""File for Service and Domain data models"""
|
|
2
2
|
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple
|
|
3
3
|
|
|
4
|
-
from pydantic import Field
|
|
4
|
+
from pydantic import Field, validator
|
|
5
5
|
|
|
6
6
|
from .base import BaseModel
|
|
7
7
|
from .states import State
|
|
@@ -29,7 +29,7 @@ class Domain(BaseModel):
|
|
|
29
29
|
}
|
|
30
30
|
)
|
|
31
31
|
|
|
32
|
-
def get_service(self, service_id: str):
|
|
32
|
+
def get_service(self, service_id: str) -> Optional["Service"]:
|
|
33
33
|
"""Return a Service with the given service_id, returns None if no such service exists"""
|
|
34
34
|
return self.services.get(service_id)
|
|
35
35
|
|
|
@@ -56,12 +56,21 @@ class Service(BaseModel):
|
|
|
56
56
|
"""Model representing services from homeassistant"""
|
|
57
57
|
|
|
58
58
|
service_id: str
|
|
59
|
-
domain: Domain
|
|
59
|
+
domain: Domain = Field(exlucde=True, repr=False)
|
|
60
60
|
name: Optional[str] = None
|
|
61
61
|
description: Optional[str] = None
|
|
62
62
|
fields: Optional[Dict[str, ServiceField]] = None
|
|
63
63
|
target: Optional[Dict[str, dict]] = None
|
|
64
64
|
|
|
65
|
+
@classmethod
|
|
66
|
+
@validator("domain")
|
|
67
|
+
def validate_domain(cls, domain: Domain) -> Domain:
|
|
68
|
+
"""
|
|
69
|
+
Explicitly do nothing to validate the parent domain.
|
|
70
|
+
Elimintates recursive validation errors.
|
|
71
|
+
"""
|
|
72
|
+
return domain
|
|
73
|
+
|
|
65
74
|
def trigger(self, **service_data) -> Tuple[State, ...]:
|
|
66
75
|
"""Triggers the service associated with this object."""
|
|
67
76
|
return self.domain.client.trigger_service(
|
|
@@ -17,11 +17,11 @@ 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.
|
|
20
|
+
version = "3.0.4"
|
|
21
21
|
[tool.poetry.dependencies]
|
|
22
22
|
aiohttp = "^3.8.1"
|
|
23
23
|
aiohttp-client-cache = "^0.6.1"
|
|
24
|
-
pydantic = "
|
|
24
|
+
pydantic = "<=1.9.0"
|
|
25
25
|
python = "^3.8"
|
|
26
26
|
requests = "^2.26.0"
|
|
27
27
|
requests-cache = "^0.9.2"
|
|
@@ -13,14 +13,14 @@ package_data = \
|
|
|
13
13
|
install_requires = \
|
|
14
14
|
['aiohttp-client-cache>=0.6.1,<0.7.0',
|
|
15
15
|
'aiohttp>=3.8.1,<4.0.0',
|
|
16
|
-
'pydantic
|
|
16
|
+
'pydantic<=1.9.0',
|
|
17
17
|
'requests-cache>=0.9.2,<0.10.0',
|
|
18
18
|
'requests>=2.26.0,<3.0.0',
|
|
19
19
|
'simplejson>=3.17.6,<4.0.0']
|
|
20
20
|
|
|
21
21
|
setup_kwargs = {
|
|
22
22
|
'name': 'homeassistant-api',
|
|
23
|
-
'version': '3.0.
|
|
23
|
+
'version': '3.0.4',
|
|
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
|
|
File without changes
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/_async/models/events.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/entity.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/events.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/history.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/logbook.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.3.post5 → HomeAssistant-API-3.0.4}/homeassistant_api/models/states.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|