Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up and fix adapter. #1

Merged
merged 1 commit into from May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,26 @@
name: Build

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8
- name: Lint with flake8
run: |
python -m flake8 . --count --max-line-length=79 --statistics
7 changes: 7 additions & 0 deletions .gitignore
@@ -0,0 +1,7 @@
*.pyc
*.sha256sum
*.swp
*.tgz
SHA256SUMS
lib/
package/
33 changes: 1 addition & 32 deletions main.py
@@ -1,67 +1,36 @@
"""DHT22 adapter for Mozilla WebThings Gateway."""
from os import path

from os import path
import functools

import signal

import sys

import time



sys.path.append(path.join(path.dirname(path.abspath(__file__)), 'lib'))



from pkg.dht22_adapter import DHT22Adapter # noqa





_DEBUG = False

_ADAPTER = None



print = functools.partial(print, flush=True)





def cleanup(signum, frame):

"""Clean up any resources before exiting."""

if _ADAPTER is not None:

_ADAPTER.close_proxy()



sys.exit(0)





if __name__ == '__main__':

signal.signal(signal.SIGINT, cleanup)

signal.signal(signal.SIGTERM, cleanup)

_ADAPTER = DHT22Adapter(verbose=_DEBUG)



# Wait until the proxy stops running, indicating that the gateway shut us

# down.

while _ADAPTER.proxy_running():
time.sleep(2)
59 changes: 1 addition & 58 deletions manifest.json
@@ -1,117 +1,60 @@
{

"author": "Marvin Bartsch",

"description": "DHT22 adapter plugin for Mozilla WebThings Gateway",

"gateway_specific_settings": {

"webthings": {

"exec": "python3 {path}/main.py",

"primary_type": "adapter",

"strict_max_version": "*",

"strict_min_version": "0.0.0"

"strict_min_version": "0.10.0"
}

},

"homepage_url": "None",

"id": "dht22-adapter",

"license": "None",

"manifest_version": 1,

"name": "DHT22",

"options": {

"default": {

"DHT22": [

{

"name": "DHT22",

"temperature_offset": 0,

"humidity_offset": 0,

"pin": 4

}

]

},

"schema": {

"type": "object",

"properties": {

"DHT22": {

"type": "array",

"items": {

"type": "object",

"required": [

"pin"

],

"properties": {

"pin": {

"minimum": 0,

"type": "integer"

},

"name": {

"type": "string"

},
"temperature_offset": {

"type": "number"

},
"humidity_offset": {

"type": "number"

}

}

}

}

}

}

},

"short_name": "DHT22",

"version": "0.0.1"

}
2 changes: 1 addition & 1 deletion pkg/__init__.py
@@ -1 +1 @@
"""Make This Files"""
"""Make this a package."""