HomeAssistant-API 3.0.3.post5__py3-none-any.whl → 3.0.4__py3-none-any.whl
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/_async/asyncclient.py +8 -0
- homeassistant_api/_async/models/domains.py +15 -7
- homeassistant_api/_async/models/entity.py +1 -1
- homeassistant_api/models/__init__.py +5 -1
- homeassistant_api/models/domains.py +12 -3
- {homeassistant_api-3.0.3.post5.dist-info → homeassistant_api-3.0.4.dist-info}/METADATA +2 -2
- {homeassistant_api-3.0.3.post5.dist-info → homeassistant_api-3.0.4.dist-info}/RECORD +9 -9
- {homeassistant_api-3.0.3.post5.dist-info → homeassistant_api-3.0.4.dist-info}/LICENSE +0 -0
- {homeassistant_api-3.0.3.post5.dist-info → homeassistant_api-3.0.4.dist-info}/WHEEL +0 -0
|
@@ -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,
|
|
@@ -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(
|
|
@@ -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"""
|
|
@@ -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",
|
|
@@ -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(
|
|
@@ -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)
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
homeassistant_api/__init__.py,sha256=AH9XX6azCAhlYkvfAKlPpH4PJllEHDZafCw0BFoMe3Y,1063
|
|
2
2
|
homeassistant_api/_async/__init__.py,sha256=XEF5FPZYe_jT-ivHrAZh90P946aAV3yDMPOmgI7_Oks,319
|
|
3
|
-
homeassistant_api/_async/asyncclient.py,sha256=
|
|
3
|
+
homeassistant_api/_async/asyncclient.py,sha256=qR_FGaAt0wlhKwcvLcVTK7uAuMMwBUKH7BCuy4pJBpE,11850
|
|
4
4
|
homeassistant_api/_async/models/__init__.py,sha256=A2C8C-7Pnp7cs5jc6xm12FdSShbEMpNnGeQlRB-mj9Y,255
|
|
5
|
-
homeassistant_api/_async/models/domains.py,sha256=
|
|
6
|
-
homeassistant_api/_async/models/entity.py,sha256=
|
|
5
|
+
homeassistant_api/_async/models/domains.py,sha256=ubiJp0uOh_ZPdp2G8swr8dlZ9ePthR1jXNWzxfCsxHM,2430
|
|
6
|
+
homeassistant_api/_async/models/entity.py,sha256=lDmQ4Q9vAbErRuPPk94_1699UXYlTk6w5su6pcVG7q8,2808
|
|
7
7
|
homeassistant_api/_async/models/events.py,sha256=bs86N92XMJQXJeVzWGz5YkjXH8zLWDzKO2OscFwd5Gk,792
|
|
8
8
|
homeassistant_api/client.py,sha256=L9bWMQKPh0fOyW9USli16JjGODEzqSvkNR3eiZiie1E,225
|
|
9
9
|
homeassistant_api/const.py,sha256=XSNCLYcEsdE5ji2LjpMmfeKdMACPhuRY3nHxhPJXXqA,84
|
|
10
10
|
homeassistant_api/errors.py,sha256=lH_AQC7yGJujj4fLcFntn_mwlHBG36QFJRJfgWH87tk,2081
|
|
11
11
|
homeassistant_api/mixins.py,sha256=Ii0t8JD9vncvtErTeo0ng7hK0GZD-Y0H6xBDEQdI1_s,2018
|
|
12
|
-
homeassistant_api/models/__init__.py,sha256=
|
|
12
|
+
homeassistant_api/models/__init__.py,sha256=x6jKJJofsQcmVknEpbUaf0bq9nS7v0RpiJytjAYYLYM,474
|
|
13
13
|
homeassistant_api/models/base.py,sha256=-5XsyKSTVzQHtaHNUgLPMAtiSgh_AUfvoyFnSAAtUx4,393
|
|
14
|
-
homeassistant_api/models/domains.py,sha256=
|
|
14
|
+
homeassistant_api/models/domains.py,sha256=78Amwtcry-WVR1tvE9NkIMSJggQXs8NI-Od_oQlfwaI,2533
|
|
15
15
|
homeassistant_api/models/entity.py,sha256=BkhgRentgWIypLIs3cs25X2BqL9jwru4k1E1WytHCAY,3151
|
|
16
16
|
homeassistant_api/models/events.py,sha256=zHB8dNGEkgMlS0pg6NzRstxpjCRYvaz2d9ezM04IlMw,752
|
|
17
17
|
homeassistant_api/models/history.py,sha256=a5HHV7bw4qeFtOYSqpmun98Kx5yV0DesTmLNi0WLoTo,634
|
|
@@ -21,7 +21,7 @@ homeassistant_api/processing.py,sha256=WqworL2RdlvdfoQUfu7t-ISdJjmwYxB3pWvvjnlkC
|
|
|
21
21
|
homeassistant_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
homeassistant_api/rawapi.py,sha256=ScPe4pRy32iwOqpQFplzyZXcS1O4v6-3AhQOoecUS_I,6023
|
|
23
23
|
homeassistant_api/rawclient.py,sha256=JCaH8e8ufDCPYatlBj4yRXcpNcGkfMWPP-0Ow88lbk0,11018
|
|
24
|
-
homeassistant_api-3.0.
|
|
25
|
-
homeassistant_api-3.0.
|
|
26
|
-
homeassistant_api-3.0.
|
|
27
|
-
homeassistant_api-3.0.
|
|
24
|
+
homeassistant_api-3.0.4.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
25
|
+
homeassistant_api-3.0.4.dist-info/WHEEL,sha256=DA86_h4QwwzGeRoz62o1svYt5kGEXpoUTuTtwzoTb30,83
|
|
26
|
+
homeassistant_api-3.0.4.dist-info/METADATA,sha256=LXCsCos2V2TsDaHgCL7_ha2Mr6YjMYMGe2-3izgE4kI,2889
|
|
27
|
+
homeassistant_api-3.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|