-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 22b783f
Showing
182 changed files
with
3,629 additions
and
0 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,48 @@ | ||
name: ci | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the main branch | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
- uses: pre-commit/action@v2.0.3 | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install pylint websocket-client zeroconf click coverage pytest | ||
python3 -m pip install --upgrade build | ||
- name: unitest + coveragecoverage | ||
run: ./build.sh --test | ||
- name: Create Python Package | ||
run: ./build.sh --pip | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: beoremote-halo | ||
path: dist/*halo* | ||
|
||
verify: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: beoremote-halo | ||
- name: Verify package - Connect Demo | ||
run: | | ||
wget https://github.com/vi/websocat/releases/download/v1.9.0/websocat_linux32_nossl && chmod +x websocat_linux32_nossl | ||
python3 -m venv env && source env/bin/activate | ||
python -m pip install beoremote_halo-*-py3-none-any.whl | ||
timeout --preserve-status 5 echo '{"event":{"type":"system","state":"active"}}' | ./websocat_linux32_nossl -s 8080 --one-message --oneshot & | ||
timeout --preserve-status 5 beoremote-halo demo --hostname localhost |
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,35 @@ | ||
# 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-yaml | ||
- id: name-tests-test | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 21.9b0 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.9.3 | ||
hooks: | ||
- id: isort | ||
args: [--profile=black] | ||
|
||
- repo: https://github.com/klieret/jekyll-relative-url-check | ||
rev: v2.0.1 | ||
hooks: | ||
- id: jekyll-relative-url-check-html | ||
- id: jekyll-relative-url-check-markdown | ||
|
||
- repo: https://github.com/pycqa/pylint | ||
rev: v2.11.1 | ||
hooks: | ||
- id: pylint | ||
args: | ||
- -j0 | ||
- --disable=C0209,C0116,C0115,E0401,R0801,C0103,R0903,W1202 |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Bang & Olufsen | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
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. |
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,55 @@ | ||
|
||
[<img src="https://github.com/bang-olufsen/beoremote-halo/raw/main/docs/images/Beoremote_Halo.png" width="30%">](https://www.bang-olufsen.com/en/us/accessories/beoremote-halo) | ||
# Beoremote Halo Open API | ||
[![build](https://github.com/bang-olufsen/beoremote-halo/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/bang-olufsen/beoremote-halo/actions/workflows/ci.yaml) | ||
[![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE) | ||
[![Version](https://img.shields.io/pypi/v/beoremote-halo?color=g)](https://pypi.org/project/beoremote-halo) | ||
|
||
|
||
The [Beoremote Halo](https://www.bang-olufsen.com/en/us/accessories/beoremote-halo) Open API is an open source async API that allows you to interact with a Beoremote Halo from a home automation system. | ||
<br /> | ||
<br /> | ||
Using a WebSocket to communicate with the Beoremote Halo, it is possible to create a configuration of buttons to interact with your home automation to control your home applications. | ||
<br /> | ||
<br /> | ||
Beoremote Halo supports buttons with icons or text for most general home automation applications. | ||
You can find a list of the [supported icons](https://github.com/bang-olufsen/beoremote-halo/wiki/Icons) on our wiki pages. | ||
For further details on the Open API list of commands please refer to the [API description](https://bang-olufsen.github.io/beoremote-halo/). | ||
<br /> | ||
|
||
|
||
## Installation | ||
The Python package `beoremote-halo` requires [Python 3.9](https://www.python.org/downloads/) or higher and contains a library for communicating with Beoremote Halo and a CLI tool for discovering Beoremote Halo on the network. | ||
|
||
Install using pip: | ||
``` | ||
pip3 install beoremote-halo | ||
``` | ||
|
||
## Basic Usage | ||
In the following example a client instance connects to Beoremote Halo and listens for events. When a `SystemEvent` is received the `on_system_event` callback is executed and prints the Beoremote Halo's system state. Please refer to the [API](https://bang-olufsen.github.io/beoremote-halo) for details on each type of event. | ||
```python | ||
from beoremote import Halo | ||
from beoremote.events import SystemEvent | ||
|
||
def on_system_event(client: Halo, event: SystemEvent): | ||
print(event) | ||
|
||
|
||
remote = Halo("BeoremoteHalo-XXXXXXXX.local") | ||
remote.set_on_system_event_callback(on_system_event) | ||
remote.connect() | ||
``` | ||
|
||
## Example | ||
Use the `beoremote-halo` CLI tool to discover and then run a demo by connecting to your Beoremote Halo. | ||
|
||
<img src="https://github.com/bang-olufsen/beoremote-halo/raw/main/docs/images/beoremote-halo-demo.gif"> | ||
|
||
In the above demo the CLI is used to locate Beoremote-Halo on the network. Afterwards the CLI demo is run by passing the host name of a Beoremote-Halo. The demo configures the Beoremote Halo and reacts to events received from Halo. The callbacks each handle a specific type of [event](https://bang-olufsen.github.io/beoremote-halo/#message-event). | ||
|
||
`on_system_event` is provided but unused in this example. | ||
|
||
`on_wheel_event` changes the indicator ring on the centered/controlled button. | ||
|
||
`on_button_event` changes the active/inactive state of a button, will start/pause/resume the timer if the "Oven Timer" button is pressed. |
Oops, something went wrong.