Skip to content

Commit 8e44761

Browse files
authored
Merge pull request #63 from GrandMoff100/docs/3.0.0
Merge docs for new version!
2 parents c1bf30f + 3669582 commit 8e44761

34 files changed

Lines changed: 494 additions & 307 deletions

.github/workflows/codeql-analysis.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ dev ]
16+
branches: [dev]
1717
pull_request:
1818
# The branches below must be a subset of the branches above
19-
branches: [ dev ]
19+
branches: [dev]
2020
schedule:
21-
- cron: '17 7 * * 1'
21+
- cron: "17 7 * * 1"
2222

2323
jobs:
2424
analyze:
@@ -32,39 +32,39 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
language: [ 'python' ]
35+
language: ["python"]
3636
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3737
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3838

3939
steps:
40-
- name: Checkout repository
41-
uses: actions/checkout@v2
40+
- name: Checkout repository
41+
uses: actions/checkout@v2
4242

43-
# Initializes the CodeQL tools for scanning.
44-
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v1
46-
with:
47-
languages: ${{ matrix.language }}
48-
# If you wish to specify custom queries, you can do so here or in a config file.
49-
# By default, queries listed here will override any specified in a config file.
50-
# Prefix the list here with "+" to use these queries and those in the config file.
51-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v1
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5252

53-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54-
# If this step fails, then you should remove it and run the build manually (see below)
55-
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v1
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v1
5757

58-
# ℹ️ Command-line programs to run using the OS shell.
59-
# 📚 https://git.io/JvXDl
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 https://git.io/JvXDl
6060

61-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62-
# and modify them (or add more) to build your code if your project
63-
# uses a compiled language
61+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62+
# and modify them (or add more) to build your code if your project
63+
# uses a compiled language
6464

65-
#- run: |
66-
# make bootstrap
67-
# make release
65+
#- run: |
66+
# make bootstrap
67+
# make release
6868

69-
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v1
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v1

.github/workflows/python-publish.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ jobs:
2424
env:
2525
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2626
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
27-
run: poetry publish --build -username $TWINE_USERNAME --password TWINE_PASSWORD
27+
run: |
28+
poetry publish --build \
29+
--username $TWINE_USERNAME \
30+
--password TWINE_PASSWORD

CHANGELOG.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,44 @@
11
# Changelog
22

3-
**v2.0.0**
4-
- Added Data Models
5-
- Added Documentation
6-
- Added functions for all endpoints
3+
## v3.0.0
74

8-
**v2.1.0**
9-
- Added Event support
5+
- Added Rigorous CI/CD tools, i.e. `black`, `isort`, `mypy`, `pre-commit`, `pylint`, `flake8`.
6+
- Renamed `AsyncClient` methods with `async_<method>` convention.
7+
- `Client` and `AsyncClient` can be initialized without confirming the API's status.
8+
- `Client` and `AsyncClient` are now both context managers that function the exact same.
9+
- Both clients now share previously redundant model conversion methods.
10+
- Reversed CHANGELOG order (most recent first).
1011

11-
**v2.2.0**
12-
- Implemented async support with `homeassistant_api._async.AsyncClient`
12+
## v2.4.0.post2
1313

14-
**v2.3.0**
15-
- Bug fixes (see closed issues between releases)
16-
- Added global request kwargs parameter to Client objects (see [docs](https://homeassistantapi.readthedocs.io/en/latest/api.html))
14+
- Fixed wrong check in malformed_id function
15+
16+
## v2.4.0.post1
17+
18+
- Replaced `text/plain` with `application/octet-stream` in docs and processing module.
19+
- Added message content to UnrecognizedStatusCodeError to help with user debugging
20+
21+
## v2.4.0
1722

18-
**v2.4.0**
1923
- Bug fixes (see closed issues between releases)
2024
- Added a processing framework for hooking into mimetype processing
2125
- Fixed some issues with some ``AsyncClient`` methods
2226

23-
**v2.4.0.post1**
24-
- Replaced `text/plain` with `application/octet-stream` in docs and processing module.
25-
- Added message content to UnrecognizedStatusCodeError to help with user debugging
27+
## v2.3.0
2628

27-
**v2.4.0.post2**
28-
- Fixed wrong check in malformed_id function
29+
- Bug fixes (see closed issues between releases)
30+
- Added global request kwargs parameter to Client objects (see [docs](homeassistantapi.rtfd.io/en/latest/api.html#homeassistant_api.Client))
31+
32+
## v2.2.0
33+
34+
- Implemented async support with `homeassistant_api._async.AsyncClient`
35+
36+
## v2.1.0
37+
38+
- Added Event support
39+
40+
## v2.0.0
41+
42+
- Added Data Models
43+
- Added Documentation
44+
- Added functions for all endpoints

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
![GitHub release (latest by date)](https://img.shields.io/github/v/release/GrandMoff100/HomeassistantAPI?style=for-the-badge)
88
![GitHub release (latest by date)](https://img.shields.io/github/downloads/GrandMoff100/HomeassistantAPI/latest/total?style=for-the-badge)
99

10-
![Homeassistant Logo](https://github.com/GrandMoff100/HomeAssistantAPI/blob/7edb4e6298d37bda19c08b807613c6d351788491/docs/images/homeassistant-logo.png?raw=true)
10+
![Home AssistantLogo](https://github.com/GrandMoff100/HomeAssistantAPI/blob/7edb4e6298d37bda19c08b807613c6d351788491/docs/images/homeassistant-logo.png?raw=true)
1111

1212
Python Wrapper for Homeassistant's [REST API](https://developers.home-assistant.io/docs/api/rest/)
1313

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
*******************
2+
Advanced Section
3+
*******************
4+
5+
Persistent Caching
6+
********************
7+
8+
19
Response Processing
210
**********************
3-
Homeassistant API uses functions called processors.
11+
Home Assistant API uses functions called processors.
412
These functions take a Response object as a parameter and return the python data type associated with the content-type header.
513

614
How To Register Response Processors (Converters)
@@ -15,16 +23,16 @@ To register a response processor you need to import the Processing class and the
1523
from homeassistant_api.processing import process_json
1624
1725
18-
@Processing.processor("application/octet-stream", override=True)
26+
@Processing.processor("application/octet-stream")
1927
def text_processor(response):
2028
return response.text.lower()
2129
22-
@Processing.async_processor("text/csv")
30+
@Processing.processor("text/csv")
2331
async def async_text_processor(response):
2432
text = await response.text()
2533
return [line.split(",") for line in text.splitlines()]
2634
27-
@Processing.processor("application/json", override=True)
35+
@Processing.processor("application/json")
2836
def json_processor(response):
2937
print("I processed a json response!)
3038
return process_json(response)
@@ -34,14 +42,15 @@ To register a response processor you need to import the Processing class and the
3442
print(client.get_entities())
3543
3644
37-
In this example.
45+
In this example.
3846
The first processor (a function wrapped with the processor decorator) is going to be called when we receive a response that has that as its :code:`Content-Type` header.
39-
Because :code:`homeassistant_api` provides processors for :code:`application/octet-stream` and :code:`application/json` by default,
40-
we need to tell :code:`homeassistant_api` to override the default processor with :code:`override=True`.
47+
:code:`homeassistant_api` provides processors for :code:`application/octet-stream` and :code:`application/json` by default,
48+
But :code:`@Processing.processor` gives the most recently registered processor the highest precedence when choosing a processor for a response.
49+
So our processor here will be chosen over the default processors.
4150
42-
The second processor is an async processor that only gets called when AsyncClient receives a response that has :code:`text/csv` as its :code:`Content-Type` header.
43-
If you wanted to override :code:`homeassistant_api`'s default json processing using the :code:`json` module with a different way to process json data.
44-
Such as using instead, the :code:`ujson` module (which is faster but more limiting).
51+
The second processor is an async processor that only gets called when Client receives an async response that has :code:`text/csv` as its :code:`Content-Type` header.
52+
If you wanted, you could not use :code:`homeassistant_api`'s default json processing using the :code:`json` module,
53+
and use instead the :code:`ujson` module (which is faster but more restrictive).
4554
4655
The third processor function implements the default processor function for the :code:`application/json` mimetype after printing a string.
4756
If you wanted to run some intermediate processing.

docs/api.rst

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,59 @@
11
Code Reference
22
***************
33

4-
.. currentmodule:: homeassistant_api
5-
6-
74
Clients
85
--------
96

10-
.. autoclass:: Client
11-
:members:
12-
:inherited-members:
13-
14-
.. autoclass:: homeassistant_api._async.AsyncClient
7+
.. autoclass:: homeassistant_api.Client
158
:members:
169
:inherited-members:
1710

1811

1912
Data Models
2013
------------
2114

22-
.. autoclass:: Domain
23-
:members:
15+
.. automodule:: homeassistant_api.models
2416

25-
.. autoclass:: Service
26-
:members:
17+
.. autoclass:: Domain
2718

28-
.. autoclass:: Group
29-
:members:
19+
.. autoclass:: Service
3020

31-
.. autoclass:: Entity
32-
:members:
21+
.. autoclass:: Group
3322

34-
.. autoclass:: State
35-
:members:
23+
.. autoclass:: Entity
3624

37-
.. autoclass:: Event
38-
:members:
25+
.. autoclass:: History
3926

27+
.. autoclass:: State
4028

41-
.. autoclass:: homeassistant_api._async.AsyncDomain
42-
:members:
29+
.. autoclass:: Event
4330

44-
.. autoclass:: homeassistant_api._async.AsyncService
45-
:members:
4631

47-
.. autoclass:: homeassistant_api._async.AsyncGroup
48-
:members:
4932

50-
.. autoclass:: homeassistant_api._async.AsyncEntity
51-
:members:
33+
.. automodule:: homeassistant_api._async.models
5234

53-
.. autoclass:: homeassistant_api._async.AsyncEvent
54-
:members:
35+
.. autoclass:: AsyncDomain
5536

37+
.. autoclass:: AsyncService
5638

57-
Processing
58-
-----------
39+
.. autoclass:: AsyncGroup
5940

41+
.. autoclass:: AsyncEntity
6042

61-
.. autoclass:: Processing
62-
:members:
43+
.. autoclass:: AsyncEvent
6344

6445

65-
Exceptions
46+
Processing
6647
-----------
6748

68-
.. autoclass:: homeassistant_api.errors.RequestError
69-
70-
.. autoclass:: homeassistant_api.errors.MalformedDataError
7149

72-
.. autoclass:: homeassistant_api.errors.MalformedInputError
73-
74-
.. autoclass:: homeassistant_api.errors.APIConfigurationError
75-
76-
.. autoclass:: homeassistant_api.errors.ParameterMissingError
77-
78-
.. autoclass:: homeassistant_api.errors.UnexpectedStatusCodeError
50+
.. autoclass:: homeassistant_api.processing.Processing
51+
:members:
7952

80-
.. autoclass:: homeassistant_api.errors.UnauthorizedError
8153

82-
.. autoclass:: homeassistant_api.errors.EndpointNotFoundError
54+
Exceptions
55+
-----------
8356

84-
.. autoclass:: homeassistant_api.errors.MethodNotAllowedError
57+
.. automodule:: homeassistant_api.errors
58+
:members:
8559

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"issues": "https://github.com/GrandMoff100/HomeassistantAPI/issues",
5151
"discussions": "https://github.com/GrandMoff100/HomeassistantAPI/discussions",
5252
"examples": f"https://github.com/GrandMoff100/HomeassistantAPI/tree/{branch}/examples",
53+
"new_pr": "https://github.com/GrandMoff100/HomeAssistantAPI/compare",
5354
}
5455

5556
# Add any paths that contain templates here, relative to this directory.

0 commit comments

Comments
 (0)