-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Code linting and optimization - Better integration of mqtt (not only publishing but receiving states) - mqtt discovery to send of/off commands over mqtt - Overall interface review and adjustment
- Loading branch information
Dennis Muth
committed
Mar 16, 2019
1 parent
dab4eee
commit 557252b
Showing
31 changed files
with
1,414 additions
and
310 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
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,5 +1,6 @@ | ||
bumpversion | ||
pip-tools | ||
pylint | ||
pytest | ||
pytest-cov | ||
pytest-mock | ||
|
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""Initializes the flask app.""" | ||
# pylint: skip-file | ||
|
||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
|
||
from .flaskutil.routing import OnOffConverter | ||
app.url_map.converters['on_off'] = OnOffConverter | ||
|
||
from . import api | ||
api.init_app(app) |
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,17 +1,23 @@ | ||
"""Provides some additional field validation and serialization for flask.""" | ||
|
||
from flask_restplus import fields | ||
|
||
|
||
class Dict(fields.Raw): | ||
"""Dictionary serializer.""" | ||
def format(self, value): | ||
"""Formats the given value according to the fields strategy.""" | ||
if isinstance(value, dict): | ||
return value | ||
|
||
raise fields.MarshallingError("Can not marshal dictionary") | ||
|
||
|
||
class OnOff(fields.Boolean): | ||
"""On/Off serializer for boolean.""" | ||
__schema_type__ = 'string' | ||
|
||
def format(self, value): | ||
b = super().format(value) | ||
return "on" if b else "off" | ||
"""Formats the given value according to the fields strategy.""" | ||
boolean = super().format(value) | ||
return "on" if boolean else "off" |
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,20 +1,24 @@ | ||
"""Provides endpoints to send bare codes to devices via 433 mhz hardware.""" | ||
|
||
from flask_restplus import Resource, Namespace, fields | ||
|
||
from .flaskutil.auth import requires_auth | ||
|
||
api = Namespace('send', description='Remote control related operations') | ||
api = Namespace('send', description='Remote control related operations') # pylint: disable=invalid-name | ||
|
||
|
||
code = api.model('Code', { | ||
CODE = api.model('Code', { | ||
'code': fields.Integer, | ||
'result': fields.Boolean | ||
}) | ||
|
||
|
||
@api.route('/<int:code>') | ||
class SendCode(Resource): | ||
"""Endpoint to send bare 433mhz codes to devices in range.""" | ||
@requires_auth | ||
@api.marshal_with(code) | ||
def get(self, code): | ||
@api.marshal_with(CODE) | ||
def get(self, code): # pylint: disable=no-self-use | ||
"""Implements get operation.""" | ||
from . import device_db | ||
return {'code': code, 'result': device_db.rc433.send_code(code)} |
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,10 +1,14 @@ | ||
"""Provides version related endpoints.""" | ||
|
||
from flask_restplus import Resource, Namespace | ||
|
||
api = Namespace('version', description='Version') | ||
api = Namespace('version', description='Version') # pylint: disable=invalid-name | ||
|
||
|
||
@api.route('/') | ||
class Version(Resource): | ||
def get(self): | ||
"""Endpoint that provides the current version of the api.""" | ||
def get(self): # pylint: disable=no-self-use | ||
"""Implements get operation.""" | ||
from ..config import VERSION | ||
return {'version': VERSION} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.