HomeAssistant-API 3.0.0__tar.gz → 3.0.2__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.0 → HomeAssistant-API-3.0.2}/PKG-INFO +17 -11
- HomeAssistant-API-3.0.2/README.md +42 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/asyncclient.py +8 -24
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/models/entity.py +3 -1
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/models/events.py +3 -1
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/mixins.py +3 -3
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/models/__init__.py +1 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/models/domains.py +3 -1
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/models/entity.py +3 -1
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/models/events.py +3 -1
- HomeAssistant-API-3.0.2/homeassistant_api/models/logbook.py +17 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/processing.py +5 -6
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/rawapi.py +28 -3
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/rawclient.py +8 -23
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/pyproject.toml +1 -1
- HomeAssistant-API-3.0.2/setup.py +38 -0
- HomeAssistant-API-3.0.0/README.md +0 -36
- HomeAssistant-API-3.0.0/setup.py +0 -38
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/LICENSE +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/__init__.py +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/__init__.py +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/models/__init__.py +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/models/domains.py +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/client.py +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/const.py +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/errors.py +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/models/base.py +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/models/history.py +0 -0
- {HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/models/states.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.2
|
|
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
|
|
@@ -26,16 +26,14 @@ Description-Content-Type: text/markdown
|
|
|
26
26
|
# HomeassistantAPI
|
|
27
27
|
|
|
28
28
|

|
|
29
|
-

|
|
29
|
+
[](https://pypi.org/project/homeassistant_api)
|
|
30
30
|

|
|
31
|
-
](https://img.shields.io/github/v/release/GrandMoff100/HomeassistantAPI?style=for-the-badge)
|
|
33
|
-

|
|
31
|
+
[](https://homeassistantapi.readthedocs.io/en/latest/?badge=latest)
|
|
32
|
+
[](https://github.com/GrandMoff100/HomeassistantAPI/releases)
|
|
34
33
|
|
|
35
|
-

|
|
34
|
+
[](https://home-assistant.io)
|
|
38
35
|
|
|
36
|
+
## Python wrapper for Homeassistant's [REST API](https://developers.home-assistant.io/docs/api/rest/)
|
|
39
37
|
|
|
40
38
|
Please ⭐️ the repo if you find this project useful or cool!
|
|
41
39
|
|
|
@@ -52,11 +50,19 @@ with Client(
|
|
|
52
50
|
|
|
53
51
|
light.turn_on(entity_id='light.living_room_lamp')
|
|
54
52
|
```
|
|
53
|
+
All the methods also support async!
|
|
55
54
|
|
|
56
55
|
## Documentation
|
|
57
|
-
All documentation, API reference,
|
|
56
|
+
All documentation, API reference, contribution guidelines and pretty much everything else
|
|
57
|
+
you'd want to know is on our readthedocs site [here](https://homeassistantapi.readthedocs.io)
|
|
58
|
+
|
|
59
|
+
If there is something missing, open an issue and let us know! Thanks!
|
|
60
|
+
|
|
61
|
+
Go make some cool stuff! Maybe come back and tell us about it in a
|
|
62
|
+
[discussion](https://github.com/GrandMoff100/HomeAssistantAPI/discussions)?
|
|
63
|
+
We'd love to hear about how you use our library!!
|
|
58
64
|
|
|
59
|
-
|
|
65
|
+
## License
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
This project is under the GNU GPLv3 license, as defined by the Free Software Foundation.
|
|
62
68
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# HomeassistantAPI
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://pypi.org/project/homeassistant_api)
|
|
5
|
+

|
|
6
|
+
[](https://homeassistantapi.readthedocs.io/en/latest/?badge=latest)
|
|
7
|
+
[](https://github.com/GrandMoff100/HomeassistantAPI/releases)
|
|
8
|
+
|
|
9
|
+
[](https://home-assistant.io)
|
|
10
|
+
|
|
11
|
+
## Python wrapper for Homeassistant's [REST API](https://developers.home-assistant.io/docs/api/rest/)
|
|
12
|
+
|
|
13
|
+
Please ⭐️ the repo if you find this project useful or cool!
|
|
14
|
+
|
|
15
|
+
Here is a quick example.
|
|
16
|
+
```py
|
|
17
|
+
from homeassistant_api import Client
|
|
18
|
+
|
|
19
|
+
with Client(
|
|
20
|
+
'<API Server URL>',
|
|
21
|
+
'<Your Long Lived Access-Token>'
|
|
22
|
+
) as client:
|
|
23
|
+
|
|
24
|
+
light = client.get_domain("light")
|
|
25
|
+
|
|
26
|
+
light.turn_on(entity_id='light.living_room_lamp')
|
|
27
|
+
```
|
|
28
|
+
All the methods also support async!
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
All documentation, API reference, contribution guidelines and pretty much everything else
|
|
32
|
+
you'd want to know is on our readthedocs site [here](https://homeassistantapi.readthedocs.io)
|
|
33
|
+
|
|
34
|
+
If there is something missing, open an issue and let us know! Thanks!
|
|
35
|
+
|
|
36
|
+
Go make some cool stuff! Maybe come back and tell us about it in a
|
|
37
|
+
[discussion](https://github.com/GrandMoff100/HomeAssistantAPI/discussions)?
|
|
38
|
+
We'd love to hear about how you use our library!!
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
This project is under the GNU GPLv3 license, as defined by the Free Software Foundation.
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"""Module for interacting with Home Assistant asyncronously."""
|
|
2
2
|
import asyncio
|
|
3
|
-
from datetime import datetime
|
|
4
3
|
from os.path import join
|
|
5
4
|
from typing import Any, AsyncGenerator, Dict, List, Optional, Tuple, Union, cast
|
|
6
5
|
|
|
7
6
|
import aiohttp
|
|
8
7
|
from aiohttp_client_cache import CachedSession
|
|
9
8
|
|
|
10
|
-
from ..const import DATE_FMT
|
|
11
9
|
from ..errors import APIConfigurationError, MalformedDataError, RequestError
|
|
12
10
|
from ..mixins import JsonProcessingMixin
|
|
13
|
-
from ..models import Domain, Event, History, State
|
|
11
|
+
from ..models import Domain, Event, History, LogbookEntry, State
|
|
14
12
|
from ..processing import Processing
|
|
15
13
|
from ..rawapi import RawWrapper
|
|
16
14
|
from .models import AsyncEntity, AsyncGroup
|
|
@@ -85,28 +83,14 @@ class RawAsyncClient(RawWrapper, JsonProcessingMixin):
|
|
|
85
83
|
|
|
86
84
|
async def async_logbook_entries(
|
|
87
85
|
self,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
) -> Tuple[Dict[str, Any], ...]:
|
|
86
|
+
*args,
|
|
87
|
+
**kwargs,
|
|
88
|
+
) -> AsyncGenerator[LogbookEntry, None]:
|
|
92
89
|
"""Returns a list of logbook entries from homeassistant."""
|
|
93
|
-
params
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if isinstance(end_timestamp, datetime):
|
|
98
|
-
end_timestamp = end_timestamp.strftime(DATE_FMT)
|
|
99
|
-
params.update(end_time=end_timestamp)
|
|
100
|
-
if start_timestamp is not None:
|
|
101
|
-
if isinstance(start_timestamp, datetime):
|
|
102
|
-
formatted_timestamp = start_timestamp.strftime(DATE_FMT)
|
|
103
|
-
url = join("logbook", formatted_timestamp)
|
|
104
|
-
else:
|
|
105
|
-
url = "logbook"
|
|
106
|
-
return cast(
|
|
107
|
-
Tuple[Dict[str, Any], ...],
|
|
108
|
-
await self.async_request(url, params=params),
|
|
109
|
-
)
|
|
90
|
+
params, url = self.prepare_get_logbook_entry_params(*args, **kwargs)
|
|
91
|
+
data = await self.async_request(url, params=params)
|
|
92
|
+
for entry in data:
|
|
93
|
+
yield LogbookEntry.parse_obj(entry)
|
|
110
94
|
|
|
111
95
|
async def async_get_entity_histories(
|
|
112
96
|
self,
|
{HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/models/entity.py
RENAMED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
from os.path import join
|
|
3
3
|
from typing import TYPE_CHECKING, Any, Dict, Optional, cast
|
|
4
4
|
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
5
7
|
from ...models import BaseModel, History, State
|
|
6
8
|
|
|
7
9
|
if TYPE_CHECKING:
|
|
@@ -12,7 +14,7 @@ class AsyncGroup(BaseModel):
|
|
|
12
14
|
"""Represents the groups that entities belong to"""
|
|
13
15
|
|
|
14
16
|
group_id: str
|
|
15
|
-
client: "Client"
|
|
17
|
+
client: "Client" = Field(exclude=True, repr=False)
|
|
16
18
|
entities: Dict[str, "AsyncEntity"] = {}
|
|
17
19
|
|
|
18
20
|
def add_entity(self, entity_slug: str, state: State) -> None:
|
{HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/models/events.py
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""Event Model File"""
|
|
2
2
|
from typing import TYPE_CHECKING, Dict, cast
|
|
3
3
|
|
|
4
|
+
from pydantic import Field
|
|
5
|
+
|
|
4
6
|
from ...models import BaseModel
|
|
5
7
|
|
|
6
8
|
if TYPE_CHECKING:
|
|
@@ -17,7 +19,7 @@ class AsyncEvent(BaseModel):
|
|
|
17
19
|
|
|
18
20
|
event_type: str
|
|
19
21
|
listener_count: int
|
|
20
|
-
client: "Client"
|
|
22
|
+
client: "Client" = Field(exclude=True, repr=False)
|
|
21
23
|
|
|
22
24
|
async def async_fire(self, **event_data) -> str:
|
|
23
25
|
"""Fires the event type in homeassistant. Ex. `on_startup`"""
|
|
@@ -21,7 +21,7 @@ class JsonProcessingMixin:
|
|
|
21
21
|
@staticmethod
|
|
22
22
|
def process_state_json(json: Dict[str, Any]) -> State:
|
|
23
23
|
"""Constructs State model from json data"""
|
|
24
|
-
return State(
|
|
24
|
+
return State.parse_obj(json)
|
|
25
25
|
|
|
26
26
|
def process_event_json(self, json: Dict[str, Any]) -> Event:
|
|
27
27
|
"""Constructs Event model from json data"""
|
|
@@ -43,11 +43,11 @@ class JsonProcessingMixin:
|
|
|
43
43
|
@staticmethod
|
|
44
44
|
async def async_process_state_json(json: Dict[str, Any]) -> State:
|
|
45
45
|
"""Constructs State model from json data"""
|
|
46
|
-
return State(
|
|
46
|
+
return State.parse_obj(json)
|
|
47
47
|
|
|
48
48
|
async def async_process_event_json(
|
|
49
49
|
self,
|
|
50
50
|
json: Dict[str, Any],
|
|
51
51
|
) -> AsyncEvent:
|
|
52
|
-
"""Constructs Event model from json data"""
|
|
52
|
+
"""Constructs Event model from json data."""
|
|
53
53
|
return AsyncEvent(**json, client=self)
|
|
@@ -1,6 +1,8 @@
|
|
|
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
|
|
5
|
+
|
|
4
6
|
from .base import BaseModel
|
|
5
7
|
from .states import State
|
|
6
8
|
|
|
@@ -12,7 +14,7 @@ class Domain(BaseModel):
|
|
|
12
14
|
"""Model representing the domain that services belong to."""
|
|
13
15
|
|
|
14
16
|
domain_id: str
|
|
15
|
-
client: "Client"
|
|
17
|
+
client: "Client" = Field(exclude=True, repr=False)
|
|
16
18
|
services: Dict[str, "Service"] = {}
|
|
17
19
|
|
|
18
20
|
def add_service(self, service_id: str, **data) -> None:
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
from os.path import join
|
|
4
4
|
from typing import TYPE_CHECKING, Any, Dict, Optional, cast
|
|
5
5
|
|
|
6
|
+
from pydantic import Field
|
|
7
|
+
|
|
6
8
|
from .base import BaseModel
|
|
7
9
|
from .history import History
|
|
8
10
|
from .states import State
|
|
@@ -15,7 +17,7 @@ class Group(BaseModel):
|
|
|
15
17
|
"""Represents the groups that entities belong to."""
|
|
16
18
|
|
|
17
19
|
group_id: str
|
|
18
|
-
client: "Client"
|
|
20
|
+
client: "Client" = Field(exclude=True, repr=False)
|
|
19
21
|
entities: Dict[str, "Entity"] = {}
|
|
20
22
|
|
|
21
23
|
def add_entity(self, entity_slug: str, state: State) -> None:
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING, Dict, cast
|
|
4
4
|
|
|
5
|
+
from pydantic import Field
|
|
6
|
+
|
|
5
7
|
from .base import BaseModel
|
|
6
8
|
|
|
7
9
|
if TYPE_CHECKING:
|
|
@@ -18,7 +20,7 @@ class Event(BaseModel):
|
|
|
18
20
|
|
|
19
21
|
event_type: str
|
|
20
22
|
listener_count: int
|
|
21
|
-
client: "Client"
|
|
23
|
+
client: "Client" = Field(exclude=True, repr=False)
|
|
22
24
|
|
|
23
25
|
def fire(self, **event_data) -> str:
|
|
24
26
|
"""Fires the corresponding event in Home Assistant."""
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Module for the Logbook Entry model."""
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from .base import BaseModel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class LogbookEntry(BaseModel):
|
|
9
|
+
"""Model representing"""
|
|
10
|
+
|
|
11
|
+
when: datetime
|
|
12
|
+
name: str
|
|
13
|
+
entity_id: str
|
|
14
|
+
state: Optional[str] = None
|
|
15
|
+
domain: Optional[str] = None
|
|
16
|
+
context_id: Optional[str] = None
|
|
17
|
+
icon: Optional[str] = None
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import inspect
|
|
4
4
|
import json
|
|
5
|
-
from typing import Callable, Dict, Tuple, Union
|
|
5
|
+
from typing import Callable, ClassVar, Dict, Tuple, Union
|
|
6
6
|
|
|
7
7
|
import simplejson
|
|
8
8
|
from aiohttp import ClientResponse
|
|
@@ -26,7 +26,7 @@ class Processing(BaseModel):
|
|
|
26
26
|
"""Uses to processor functions to convert json data into common python data types."""
|
|
27
27
|
|
|
28
28
|
response: Union[Response, CachedResponse, ClientResponse, AsyncCachedResponse]
|
|
29
|
-
_processors: Dict[str, Tuple[Callable, ...]] = {}
|
|
29
|
+
_processors: ClassVar[Dict[str, Tuple[Callable, ...]]] = {}
|
|
30
30
|
|
|
31
31
|
@staticmethod
|
|
32
32
|
def processor(mimetype: str):
|
|
@@ -59,11 +59,10 @@ class Processing(BaseModel):
|
|
|
59
59
|
|
|
60
60
|
def process(self):
|
|
61
61
|
"""Validates the http status code before starting to process the repsonse content"""
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
elif _async := isinstance(self.response, AsyncCachedResponse):
|
|
62
|
+
_async = isinstance(self.response, (ClientResponse, AsyncCachedResponse))
|
|
63
|
+
if _async:
|
|
65
64
|
status_code = self.response.status
|
|
66
|
-
elif
|
|
65
|
+
elif isinstance(self.response, Response):
|
|
67
66
|
status_code = self.response.status_code
|
|
68
67
|
else:
|
|
69
68
|
raise ValueError(
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
from datetime import datetime
|
|
5
|
-
from typing import Dict, Optional, Tuple
|
|
5
|
+
from typing import Dict, Optional, Tuple, Union
|
|
6
6
|
|
|
7
7
|
from .const import DATE_FMT
|
|
8
8
|
from .errors import MalformedInputError
|
|
@@ -26,8 +26,6 @@ class RawWrapper:
|
|
|
26
26
|
) -> None:
|
|
27
27
|
if global_request_kwargs is None:
|
|
28
28
|
global_request_kwargs = {}
|
|
29
|
-
if not self.api_url.endswith("/"):
|
|
30
|
-
self.api_url += "/"
|
|
31
29
|
if cache_backend is None:
|
|
32
30
|
cache_backend = "memory"
|
|
33
31
|
if cache_expire_after is None:
|
|
@@ -39,6 +37,9 @@ class RawWrapper:
|
|
|
39
37
|
self.cache_backend = cache_backend
|
|
40
38
|
self.cache_expire_after = cache_expire_after
|
|
41
39
|
|
|
40
|
+
if not api_url.endswith("/"):
|
|
41
|
+
self.api_url += "/"
|
|
42
|
+
|
|
42
43
|
def endpoint(self, path: str) -> str:
|
|
43
44
|
"""Joins the api base url with a local path to an absolute url"""
|
|
44
45
|
return os.path.join(self.api_url, path)
|
|
@@ -132,3 +133,27 @@ class RawWrapper:
|
|
|
132
133
|
else:
|
|
133
134
|
url = "history/period"
|
|
134
135
|
return params, url
|
|
136
|
+
|
|
137
|
+
@staticmethod
|
|
138
|
+
def prepare_get_logbook_entry_params(
|
|
139
|
+
filter_entity: Optional[Entity] = None,
|
|
140
|
+
start_timestamp: Optional[
|
|
141
|
+
Union[str, datetime]
|
|
142
|
+
] = None, # Defaults to 1 day before
|
|
143
|
+
end_timestamp: Optional[Union[str, datetime]] = None,
|
|
144
|
+
) -> Tuple[Dict[str, str], str]:
|
|
145
|
+
"""Prepares the query string and url path for retrieving logbook entries."""
|
|
146
|
+
params: Dict[str, str] = {}
|
|
147
|
+
if filter_entity is not None:
|
|
148
|
+
params.update(entity=filter_entity.entity_id)
|
|
149
|
+
if end_timestamp is not None:
|
|
150
|
+
if isinstance(end_timestamp, datetime):
|
|
151
|
+
end_timestamp = end_timestamp.strftime(DATE_FMT)
|
|
152
|
+
params.update(end_time=end_timestamp)
|
|
153
|
+
if start_timestamp is not None:
|
|
154
|
+
if isinstance(start_timestamp, datetime):
|
|
155
|
+
formatted_timestamp = start_timestamp.strftime(DATE_FMT)
|
|
156
|
+
url = os.path.join("logbook", formatted_timestamp)
|
|
157
|
+
else:
|
|
158
|
+
url = "logbook"
|
|
159
|
+
return params, url
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"""Module for all interaction with homeassistant."""
|
|
2
2
|
|
|
3
|
-
from datetime import datetime
|
|
4
3
|
from os.path import join
|
|
5
4
|
from typing import Any, Dict, Generator, List, Optional, Tuple, Union, cast
|
|
6
5
|
|
|
7
6
|
import requests
|
|
8
7
|
from requests_cache import CachedSession
|
|
9
8
|
|
|
10
|
-
from .const import DATE_FMT
|
|
11
9
|
from .errors import APIConfigurationError, RequestError
|
|
12
10
|
from .mixins import JsonProcessingMixin
|
|
13
|
-
from .models import Domain, Entity, Event, Group, History, State
|
|
11
|
+
from .models import Domain, Entity, Event, Group, History, LogbookEntry, State
|
|
14
12
|
from .processing import Processing
|
|
15
13
|
from .rawapi import RawWrapper
|
|
16
14
|
|
|
@@ -87,27 +85,14 @@ class RawClient(RawWrapper, JsonProcessingMixin):
|
|
|
87
85
|
|
|
88
86
|
def logbook_entries(
|
|
89
87
|
self,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
] = None, # Defaults to 1 day before
|
|
94
|
-
end_timestamp: Optional[Union[str, datetime]] = None,
|
|
95
|
-
) -> List[Dict[str, Any]]:
|
|
88
|
+
*args,
|
|
89
|
+
**kwargs,
|
|
90
|
+
) -> Generator[LogbookEntry, None, None]:
|
|
96
91
|
"""Returns a list of logbook entries from homeassistant."""
|
|
97
|
-
params
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if isinstance(end_timestamp, datetime):
|
|
102
|
-
end_timestamp = end_timestamp.strftime(DATE_FMT)
|
|
103
|
-
params.update(end_time=end_timestamp)
|
|
104
|
-
if start_timestamp is not None:
|
|
105
|
-
if isinstance(start_timestamp, datetime):
|
|
106
|
-
formatted_timestamp = start_timestamp.strftime(DATE_FMT)
|
|
107
|
-
url = join("logbook", formatted_timestamp)
|
|
108
|
-
else:
|
|
109
|
-
url = "logbook"
|
|
110
|
-
return cast(List[Dict[str, Any]], self.request(url, params=params))
|
|
92
|
+
params, url = self.prepare_get_logbook_entry_params(*args, **kwargs)
|
|
93
|
+
data = self.request(url, params=params)
|
|
94
|
+
for entry in data:
|
|
95
|
+
yield LogbookEntry.parse_obj(entry)
|
|
111
96
|
|
|
112
97
|
def get_entity_histories(self, *args, **kwargs) -> Generator[History, None, None]:
|
|
113
98
|
"""
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from setuptools import setup
|
|
3
|
+
|
|
4
|
+
packages = \
|
|
5
|
+
['homeassistant_api',
|
|
6
|
+
'homeassistant_api._async',
|
|
7
|
+
'homeassistant_api._async.models',
|
|
8
|
+
'homeassistant_api.models']
|
|
9
|
+
|
|
10
|
+
package_data = \
|
|
11
|
+
{'': ['*']}
|
|
12
|
+
|
|
13
|
+
install_requires = \
|
|
14
|
+
['aiohttp-client-cache>=0.6.1,<0.7.0',
|
|
15
|
+
'aiohttp>=3.8.1,<4.0.0',
|
|
16
|
+
'pydantic>=1.9.0,<2.0.0',
|
|
17
|
+
'requests-cache>=0.9.2,<0.10.0',
|
|
18
|
+
'requests>=2.26.0,<3.0.0',
|
|
19
|
+
'simplejson>=3.17.6,<4.0.0']
|
|
20
|
+
|
|
21
|
+
setup_kwargs = {
|
|
22
|
+
'name': 'homeassistant-api',
|
|
23
|
+
'version': '3.0.2',
|
|
24
|
+
'description': "Python Wrapper for Homeassistant's REST API",
|
|
25
|
+
'long_description': '# HomeassistantAPI\n\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\nPlease ⭐️ the repo if you find this project useful or cool!\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
|
+
'author': 'GrandMoff100',
|
|
27
|
+
'author_email': 'minecraftcrusher100@gmail.com',
|
|
28
|
+
'maintainer': None,
|
|
29
|
+
'maintainer_email': None,
|
|
30
|
+
'url': 'https://github.com/GrandMoff100/HomeAssistantAPI',
|
|
31
|
+
'packages': packages,
|
|
32
|
+
'package_data': package_data,
|
|
33
|
+
'install_requires': install_requires,
|
|
34
|
+
'python_requires': '>=3.7,<4.0',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
setup(**setup_kwargs)
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# HomeassistantAPI
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-

|
|
7
|
-

|
|
8
|
-

|
|
9
|
-
|
|
10
|
-

|
|
11
|
-
|
|
12
|
-
Python Wrapper for Homeassistant's [REST API](https://developers.home-assistant.io/docs/api/rest/)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Please ⭐️ the repo if you find this project useful or cool!
|
|
16
|
-
|
|
17
|
-
Here is a quick example.
|
|
18
|
-
```py
|
|
19
|
-
from homeassistant_api import Client
|
|
20
|
-
|
|
21
|
-
with Client(
|
|
22
|
-
'<API Server URL>',
|
|
23
|
-
'<Your Long Lived Access-Token>'
|
|
24
|
-
) as client:
|
|
25
|
-
|
|
26
|
-
light = client.get_domain("light")
|
|
27
|
-
|
|
28
|
-
light.turn_on(entity_id='light.living_room_lamp')
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Documentation
|
|
32
|
-
All documentation, API reference, Contribution guidelines and pretty much everything else you'd want to know is on our readthedocs site [here](https://homeassistantapi.readthedocs.io)
|
|
33
|
-
|
|
34
|
-
If theres something missing open an issue and let us know! Thanks!
|
|
35
|
-
|
|
36
|
-
Go make some cool stuff! Maybe come back and tell us about it in a [discussion](https://github.com/GrandMoff100/HomeAssistantAPI/discussions)? We'd love to hear about how you use our library!!
|
HomeAssistant-API-3.0.0/setup.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from setuptools import setup
|
|
3
|
-
|
|
4
|
-
packages = \
|
|
5
|
-
['homeassistant_api',
|
|
6
|
-
'homeassistant_api._async',
|
|
7
|
-
'homeassistant_api._async.models',
|
|
8
|
-
'homeassistant_api.models']
|
|
9
|
-
|
|
10
|
-
package_data = \
|
|
11
|
-
{'': ['*']}
|
|
12
|
-
|
|
13
|
-
install_requires = \
|
|
14
|
-
['aiohttp-client-cache>=0.6.1,<0.7.0',
|
|
15
|
-
'aiohttp>=3.8.1,<4.0.0',
|
|
16
|
-
'pydantic>=1.9.0,<2.0.0',
|
|
17
|
-
'requests-cache>=0.9.2,<0.10.0',
|
|
18
|
-
'requests>=2.26.0,<3.0.0',
|
|
19
|
-
'simplejson>=3.17.6,<4.0.0']
|
|
20
|
-
|
|
21
|
-
setup_kwargs = {
|
|
22
|
-
'name': 'homeassistant-api',
|
|
23
|
-
'version': '3.0.0',
|
|
24
|
-
'description': "Python Wrapper for Homeassistant's REST API",
|
|
25
|
-
'long_description': '# HomeassistantAPI\n\n\n\n\n\n\n\n\n\n\nPython Wrapper for Homeassistant\'s [REST API](https://developers.home-assistant.io/docs/api/rest/)\n\n\nPlease ⭐️ the repo if you find this project useful or cool!\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```\n\n## Documentation\nAll documentation, API reference, Contribution guidelines and pretty much everything else you\'d want to know is on our readthedocs site [here](https://homeassistantapi.readthedocs.io)\n\nIf theres 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 [discussion](https://github.com/GrandMoff100/HomeAssistantAPI/discussions)? We\'d love to hear about how you use our library!!\n',
|
|
26
|
-
'author': 'GrandMoff100',
|
|
27
|
-
'author_email': 'minecraftcrusher100@gmail.com',
|
|
28
|
-
'maintainer': None,
|
|
29
|
-
'maintainer_email': None,
|
|
30
|
-
'url': 'https://github.com/GrandMoff100/HomeAssistantAPI',
|
|
31
|
-
'packages': packages,
|
|
32
|
-
'package_data': package_data,
|
|
33
|
-
'install_requires': install_requires,
|
|
34
|
-
'python_requires': '>=3.7,<4.0',
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setup(**setup_kwargs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/models/__init__.py
RENAMED
|
File without changes
|
{HomeAssistant-API-3.0.0 → HomeAssistant-API-3.0.2}/homeassistant_api/_async/models/domains.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|