This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish out the first iteration of the library (#7)
- Loading branch information
Showing
15 changed files
with
1,270 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[run] | ||
source = eufy_security | ||
|
||
omit = | ||
eufy_security/__version__.py | ||
|
||
[report] | ||
exclude_lines = | ||
pragma: no cover | ||
if TYPE_CHECKING: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
tags | ||
Pipfile.lock | ||
.coverage | ||
.mypy_cache/ | ||
coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
clean: | ||
pipenv --rm | ||
coverage: | ||
pipenv run py.test -s --verbose --cov-report term-missing --cov-report xml --cov=aiowwlln tests | ||
pipenv run py.test -s --verbose --cov-report term-missing --cov-report xml --cov=eufy_security tests | ||
init: | ||
pip3 install --upgrade pip pipenv | ||
pipenv lock | ||
pipenv install --three --dev | ||
pipenv run pre-commit install | ||
lint: | ||
pipenv run flake8 aiowwlln | ||
pipenv run pydocstyle aiowwlln | ||
pipenv run pylint aiowwlln | ||
pipenv run flake8 eufy_security | ||
pipenv run pydocstyle eufy_security | ||
pipenv run pylint eufy_security | ||
publish: | ||
pipenv run python setup.py sdist bdist_wheel | ||
pipenv run twine upload dist/* | ||
rm -rf dist/ build/ .egg aiowwlln.egg-info/ | ||
rm -rf dist/ build/ .egg eufy_security.egg-info/ | ||
test: | ||
pipenv run py.test | ||
typing: | ||
pipenv run mypy --ignore-missing-imports aiowwlln | ||
pipenv run mypy --ignore-missing-imports eufy_security |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,85 @@ | ||
# python-eufy-security | ||
Python library for Eufy Security cameras | ||
|
||
Very much a work in progress. Will be used for integration into HomeAssistant. | ||
This is an experimental Python library for Eufy Security devices (cameras, doorbells, | ||
etc.). | ||
|
||
# Python Versions | ||
|
||
The library is currently supported on | ||
|
||
* Python 3.6 | ||
* Python 3.7 | ||
|
||
# Installation | ||
|
||
TBD | ||
|
||
# Usage | ||
|
||
Everything starts with an: | ||
[aiohttp](https://aiohttp.readthedocs.io/en/stable/) `ClientSession`: | ||
|
||
```python | ||
import asyncio | ||
|
||
from aiohttp import ClientSession | ||
|
||
|
||
async def main() -> None: | ||
"""Create the aiohttp session and run the example.""" | ||
async with ClientSession() as websession: | ||
# YOUR CODE HERE | ||
|
||
|
||
asyncio.get_event_loop().run_until_complete(main()) | ||
``` | ||
|
||
Login and get to work: | ||
|
||
```python | ||
import asyncio | ||
|
||
from aiohttp import ClientSession | ||
|
||
from eufy_security import async_login | ||
|
||
|
||
async def main() -> None: | ||
"""Create the aiohttp session and run the example.""" | ||
async with ClientSession() as websession: | ||
# Create an API client: | ||
api = await async_login(EUFY_EMAIL, EUFY_PASSWORD, websession) | ||
|
||
# Loop through the cameras associated with the account: | ||
for camera in api.cameras.values(): | ||
print("------------------") | ||
print("Camera Name: %s", camera.name) | ||
print("Serial Number: %s", camera.serial) | ||
print("Station Serial Number: %s", camera.station_serial) | ||
print("Last Camera Image URL: %s", camera.last_camera_image_url) | ||
|
||
print("Starting RTSP Stream") | ||
stream_url = await camera.async_start_stream() | ||
print("Stream URL: %s", stream_url) | ||
|
||
print("Stopping RTSP Stream") | ||
stream_url = await camera.async_stop_stream() | ||
|
||
|
||
asyncio.get_event_loop().run_until_complete(main()) | ||
``` | ||
|
||
Check out `example.py`, the tests, and the source files themselves for method | ||
signatures and more examples. | ||
|
||
# Contributing | ||
|
||
1. [Check for open features/bugs](https://github.com/FuzzyMistborn/python-eufy-security/issues) | ||
or [initiate a discussion on one](https://github.com/FuzzyMistborn/python-eufy-security/issues/new). | ||
2. [Fork the repository](https://github.com/FuzzyMistborn/python-eufy-security/fork). | ||
3. Install the dev environment: `make init`. | ||
4. Enter the virtual environment: `pipenv shell` | ||
5. Code your new feature or bug fix. | ||
6. Write a test that covers your new functionality. | ||
7. Run tests and ensure 100% code coverage: `make coverage` | ||
8. Submit a pull request! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"""Define the package version.""" | ||
VERSION: str = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
"""Run an example script to quickly test.""" | ||
import asyncio | ||
import logging | ||
|
||
from aiohttp import ClientSession | ||
|
||
from eufy_security import async_login | ||
from eufy_security.errors import EufySecurityError | ||
|
||
EUFY_EMAIL = "<EMAIL>" | ||
EUFY_PASSWORD = "<PASSWORD>" | ||
_LOGGER: logging.Logger = logging.getLogger() | ||
|
||
EUFY_EMAIL: str = "<EMAIL>" | ||
EUFY_PASSWORD: str = "<PASSWORD>" | ||
|
||
|
||
async def main() -> None: | ||
"""Create the aiohttp session and run the example.""" | ||
logging.basicConfig(level=logging.INFO) | ||
async with ClientSession() as websession: | ||
try: | ||
# Create an API client: | ||
api = await async_login(EUFY_EMAIL, EUFY_PASSWORD, websession) | ||
|
||
# Loop through the cameras associated with the account: | ||
for camera in api.cameras.values(): | ||
print(camera.name) | ||
_LOGGER.info("------------------") | ||
_LOGGER.info("Camera Name: %s", camera.name) | ||
_LOGGER.info("Serial Number: %s", camera.serial) | ||
_LOGGER.info("Station Serial Number: %s", camera.station_serial) | ||
_LOGGER.info("Last Camera Image URL: %s", camera.last_camera_image_url) | ||
|
||
_LOGGER.info("Starting RTSP Stream") | ||
stream_url = await camera.async_start_stream() | ||
_LOGGER.info("Stream URL: %s", stream_url) | ||
|
||
_LOGGER.info("Stopping RTSP Stream") | ||
stream_url = await camera.async_stop_stream() | ||
except EufySecurityError as err: | ||
print(f"There was an error: {err}") | ||
print(f"There was a/an {type(err)} error: {err}") | ||
|
||
|
||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Define the test suite.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""Define constants to use in tests.""" | ||
TEST_ACCESS_TOKEN = "abcde12345" | ||
TEST_EMAIL = "user@host.com" | ||
TEST_PASSWORD = "password12345" |
Oops, something went wrong.