Skip to content

Commit

Permalink
Change from bluepy to bleak + bugfixes (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaStrada authored Nov 23, 2022
1 parent eeda485 commit 9bc641e
Show file tree
Hide file tree
Showing 27 changed files with 1,914 additions and 320 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Lint

on: pull_request

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
run-linting:
name: Run linting
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install linting dependencies
run: |
pip install black flake8
- name: Run linters
uses: wearerequired/lint-action@v2
with:
black: true
flake8: true

- uses: actions/checkout@v3
- uses: isort/[email protected]

run-tests:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install project
run: poetry install --no-interaction

- name: Run tests
run: poetry run pytest

publish-package:
name: Publish package
runs-on: ubuntu-latest
needs: [run-linting, run-tests]

steps:
- name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_UPLOAD_PASSWORD }}
32 changes: 0 additions & 32 deletions .github/workflows/lint.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,6 @@ dmypy.json

# Cython debug symbols
cython_debug/

# vscode
.vscode/
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PyFreshSky
# pyfreshintellivent
Python interface for Fresh Intellivent Sky bathroom Fan using Bluetooth Low Energy.

This is a work in progress repository. Need help testing!

## Documentation
Check out the [Characteristics file](characteristics.md) file to read more about known characteristics.
# Features
* Supports Windows 10, version 16299 (Fall Creators Update) or greater
* Supports Linux distributions with BlueZ >= 5.43
* OS X/macOS support via Core Bluetooth API, from at least OS X version 10.11
16 changes: 16 additions & 0 deletions examples/find_device.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import asyncio

from pyfreshintellivent import scanner

AUTHENTICATE_UUID = "4cad343a-209a-40b7-b911-4d9b3df569b2"
SENSOR_UUID = "528b80e8-c47a-4c0a-bdf1-916a7748f412"


async def main():
print("Scanning, please wait...")
device = await scanner.scan()
print(f"Found device: {device}")


if __name__ == "__main__":
asyncio.run(main())
35 changes: 35 additions & 0 deletions examples/get_authcode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import asyncio
import sys

from bleak import BleakClient, BleakScanner

from pyfreshintellivent import FreshIntelliVent

ADDRESS = "mac-address"


async def main():
sky = FreshIntelliVent()
try:
device = await BleakScanner.find_device_by_address(
device_identifier=ADDRESS, timeout=30.0
)

if device is None:
print("no matching device found, check the BLE address.")
sys.exit(1)

client = BleakClient(device)
await client.connect()
print("Connected")

code = await sky.fetch_authentication_code(device=client)
print(f"Authentication code: {bytes(code).hex()}")
await client.disconnect()
except Exception as e:
print(e)
finally:
await sky.disconnect()


asyncio.run(main())
45 changes: 45 additions & 0 deletions examples/read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import asyncio
import platform

from pyfreshintellivent import FreshIntelliVent

ADDRESS = (
"mac-address"
if platform.system() != "Darwin"
else "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
)


async def main():
sky = FreshIntelliVent()
try:
await sky.connect(address_or_ble_device=ADDRESS)
await sky.authenticate(authentication_code="xxxxxxxx")

sensors = await sky.get_sensor_data()
print(f"Status: {sensors.as_dict()}")

boost = await sky.get_boost()
print(f"Boost: {boost}")

constant_speed = await sky.get_constant_speed()
print(f"Constant speed: {constant_speed}")

humidity = await sky.get_humidity()
print(f"Humidity: {humidity}")

light_and_voc = await sky.get_light_and_voc()
print(f"Light and VOC: {light_and_voc}")

pause = await sky.get_pause()
print(f"Pause: {pause}")

timer = await sky.get_timer()
print(f"Timer: {timer}")
except Exception as e:
print(e)
finally:
await sky.disconnect()


asyncio.run(main())
Loading

0 comments on commit 9bc641e

Please sign in to comment.