Skip to content

Commit

Permalink
feat: readme and ci builds (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanstinator committed Apr 15, 2022
1 parent baedc6e commit d6bd168
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 4 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and Release

on:
pull_request:
types:
- opened
- reopened
- synchronize

push:
branches:
- main

release:
types: [published]

jobs:
build:
name: "Build"

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: 3.9

- name: Install Poetry
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: 1.1.13

- name: Install poetry-dynamic-versioning
run: pip install poetry-dynamic-versioning

- name: Install Dependencies
run: poetry install

- name: Build
run: poetry build

- name: Publish to PyPI
if: github.event_name != 'pull_request'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Melnor Bluetooth

![PyPI](https://img.shields.io/pypi/v/melnor-bluetooth?style=flat-square) ![Codecov branch](https://img.shields.io/codecov/c/github/vanstinator/melnor-bluetooth/main?style=flat-square) ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/vanstinator/melnor-bluetooth/Build%20and%20Release/main?style=flat-square)
![PyPI - Downloads](https://img.shields.io/pypi/dm/melnor-bluetooth?style=flat-square)

Melnor Bluetooth is a reverse engineered implementation of the Bluetooth protocol for all "smart" bluetooth-enabled watering valves under the Melnor, EcoAquastar, Eden, and other brands.

The library _should_ run on MacOS, Linux, or Windows. It's primarily developed on MacOS and other platforms likely have bugs. PRs and tests are welcome to improve quality across all platforms.


### Getting Started

#### CLI
A simple CLI has been provided for basic debugging purposes. It's not intended for any real use and isn't suitable for running a valve in the real world.

This project uses poetry for dependency management and building. Running this project locally is as simple as the following steps:

1. Clone the repository
1. `poetry install`
1. `poetry run cli.py`


The python API has been designed to be as easy to use as possible. A few examples are provided below:

#### Read battery state
```python
import asyncio

from melnor_bluetooth.constants import BATTERY_UUID
from melnor_bluetooth.device import Device

address = '00:00:00:00:00' # fill with your device mac address

async main():
device = Device(address, 4)
await device.connect()

print(device.battery_life);

await device.disconnect();

asyncio.run(main())

```

#### Turn on a zone
```python
import asyncio

from melnor_bluetooth.device import Device

address = '00:00:00:00:00' # fill with your device mac address

async main():
device = Device(address, 4)
await device.connect()

device.zone1.is_watering = True;

await device.push_state();
await device.disconnect();

asyncio.run(main())

```
Empty file removed README.rst
Empty file.
23 changes: 19 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[tool.poetry]
name = "melnor-bluetooh"
version = "0.1.0"
description = "A small python library for discovery and interacting with Melnor, Aquastar, etc bluetooth water timers."
authors = ["Justin Vanderhooft <justinvdhooft@gmail.com>"]
description = "A small python library for discovery and interacting with Melnor, Aquastar, etc bluetooth water timers."
license = "MIT"
name = "melnor-bluetooth"
readme = "README.md"
version = "0.0.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
build-backend = "poetry.core.masonry.api"

[tool.black]
Expand Down Expand Up @@ -44,5 +46,18 @@ mockito = "^1.3.0"
flake8 = "^4.0.1"
syrupy = "^1.7.4"

[tool.poetry-dynamic-versioning]
bump = false
enable = true
format-jinja = """
{%- if distance == 0 -%}
{{ serialize_pep440(base, stage, revision) }}
{%- elif revision is not none -%}
{{ serialize_pep440(base, stage, revision + 1, dev=distance) }}
{%- else -%}
{{ serialize_pep440(bump_version(base), stage, revision, dev=distance) }}
{%- endif -%}
"""

[tool.pytest.ini_options]
asyncio_mode = 'auto'

0 comments on commit d6bd168

Please sign in to comment.