mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-21 16:37:41 +01:00
Add basic pre-commit to handle eol space (#592)
This commit is contained in:
parent
713dae18f1
commit
741308c93f
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -24,12 +24,12 @@ jobs:
|
||||
- "3.9"
|
||||
- "3.10"
|
||||
- "3.11"
|
||||
- "3.12"
|
||||
- "3.12"
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- ubuntu-latest
|
||||
extension:
|
||||
- "skip_cython"
|
||||
- "use_cython"
|
||||
- "use_cython"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python
|
||||
@ -90,7 +90,7 @@ jobs:
|
||||
name: Run tests with pytest
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
- run: |
|
||||
- run: |
|
||||
docker run \
|
||||
-v "$PWD":/aioesphomeapi \
|
||||
ghcr.io/esphome/aioesphomeapi-proto-builder:latest
|
||||
|
3
.github/workflows/matchers/pytest.json
vendored
3
.github/workflows/matchers/pytest.json
vendored
@ -14,7 +14,6 @@
|
||||
"message": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -58,4 +58,4 @@ jobs:
|
||||
|
||||
- uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
password: ${{ secrets.PYPI_TOKEN }}
|
||||
password: ${{ secrets.PYPI_TOKEN }}
|
||||
|
9
.pre-commit-config.yaml
Normal file
9
.pre-commit-config.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.2.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-added-large-files
|
2
LICENSE
2
LICENSE
@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
|
@ -13,4 +13,3 @@ Before creating a release: Check the latest commit passes continuous integration
|
||||
When the release button on the draft is clicked, GitHub Actions will publish the release to PyPi.
|
||||
|
||||
After any push to the main branch, the "protoc-update" workflow is run which updates the generated python protobuf files. This is to ensure that if a contributor has a newer protoc version installed than the protobuf python package, we won't run into any issues.
|
||||
|
||||
|
20
README.rst
20
README.rst
@ -43,25 +43,25 @@ The sample code below will connect to the device and retrieve details.
|
||||
|
||||
import aioesphomeapi
|
||||
import asyncio
|
||||
|
||||
|
||||
async def main():
|
||||
"""Connect to an ESPHome device and get details."""
|
||||
|
||||
# Establish connection
|
||||
# Establish connection
|
||||
api = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword")
|
||||
await api.connect(login=True)
|
||||
|
||||
|
||||
# Get API version of the device's firmware
|
||||
print(api.api_version)
|
||||
|
||||
|
||||
# Show device details
|
||||
device_info = await api.device_info()
|
||||
print(device_info)
|
||||
|
||||
|
||||
# List all entities of the device
|
||||
entities = await api.list_entities_services()
|
||||
print(entities)
|
||||
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
|
||||
@ -71,20 +71,20 @@ Subscribe to state changes of an ESPHome device.
|
||||
|
||||
import aioesphomeapi
|
||||
import asyncio
|
||||
|
||||
|
||||
async def main():
|
||||
"""Connect to an ESPHome device and wait for state changes."""
|
||||
cli = aioesphomeapi.APIClient("api_test.local", 6053, "MyPassword")
|
||||
|
||||
|
||||
await cli.connect(login=True)
|
||||
|
||||
def change_callback(state):
|
||||
"""Print the state changes of the device.."""
|
||||
print(state)
|
||||
|
||||
|
||||
# Subscribe to the state changes
|
||||
await cli.subscribe_states(change_callback)
|
||||
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
try:
|
||||
asyncio.ensure_future(main())
|
||||
|
@ -25,4 +25,4 @@ cdef class APIFrameHelper:
|
||||
cdef _add_to_buffer(self, bytes data)
|
||||
|
||||
@cython.locals(end_of_frame_pos=cython.uint)
|
||||
cdef _remove_from_buffer(self)
|
||||
cdef _remove_from_buffer(self)
|
||||
|
@ -19,10 +19,10 @@ cdef class APINoiseFrameHelper(APIFrameHelper):
|
||||
|
||||
@cython.locals(
|
||||
header=bytes,
|
||||
preamble=cython.uint,
|
||||
msg_size_high=cython.uint,
|
||||
preamble=cython.uint,
|
||||
msg_size_high=cython.uint,
|
||||
msg_size_low=cython.uint,
|
||||
)
|
||||
)
|
||||
cpdef data_received(self, bytes data)
|
||||
|
||||
@cython.locals(
|
||||
|
@ -21,8 +21,8 @@ cdef class APIPlaintextFrameHelper(APIFrameHelper):
|
||||
add_length=bytes,
|
||||
end_of_frame_pos=cython.uint,
|
||||
length_int=cython.uint,
|
||||
preamble=cython.uint,
|
||||
length_high=cython.uint,
|
||||
preamble=cython.uint,
|
||||
length_high=cython.uint,
|
||||
maybe_msg_type=cython.uint
|
||||
)
|
||||
cpdef data_received(self, bytes data)
|
||||
|
@ -88,4 +88,4 @@ cdef class APIConnection:
|
||||
cpdef add_message_callback(self, object on_message, tuple msg_types)
|
||||
|
||||
@cython.locals(handlers=set)
|
||||
cpdef _remove_message_callback(self, object on_message, tuple msg_types)
|
||||
cpdef _remove_message_callback(self, object on_message, tuple msg_types)
|
||||
|
@ -32,4 +32,3 @@ disable = [
|
||||
|
||||
[build-system]
|
||||
requires = ['setuptools>=65.4.1', 'wheel', 'Cython>=3.0.2']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user