From b800fed933b435ba4d38b30b69cb8f74952aa2fb Mon Sep 17 00:00:00 2001 From: manuel83 Date: Wed, 2 Jan 2019 00:48:36 +0100 Subject: [PATCH] refactoring job controller --- .idea/dataSources.local.xml | 6 + .idea/dataSources.xml | 17 + .../3f79e533-e857-4e39-8e2e-d7f62530cc84.xml | 352 ++++++ .../storage_v2/_src_/schema/main.uQUzAA.meta | 2 + .idea/workspace.xml | 1124 ++++++++++------- config/config.yaml | 4 +- .../create_database.sql | 0 core/controller/actor_controller.py | 212 +++- core/controller/config_controller.py | 48 +- core/controller/crud_controller.py | 4 +- core/controller/job_controller.py | 3 + core/controller/kettle_controller.py | 121 +- core/controller/sensor_controller.py | 192 ++- core/controller/step_controller.py | 346 +++-- core/craftbeerpi.py | 41 +- core/database/orm_framework.py | 2 +- core/eventbus.py | 12 +- core/extension/dummyactor/__init__.py | 4 +- core/extension/dummysensor/__init__.py | 6 +- core/http_endpoints/http_api.py | 103 +- core/http_endpoints/http_login.py | 3 - .../swagger/example_swagger_partial.yaml | 39 + core/{cbpiwebsocket.py => websocket.py} | 0 craftbeerpi.db | Bin 53248 -> 53248 bytes logs/first_logfile2.log | 42 - logs/first_logfile2.log.2018-11-04_01-02 | 90 -- logs/first_logfile2.log.2018-11-04_01-08 | 18 - logs/first_logfile2.log.2018-11-04_01-10 | 13 - logs/first_logfile2.log.2018-11-04_12-43 | 32 - logs/first_logfile2.log.2018-11-04_12-44 | 16 - logs/sensors/sensor_1.log | 49 + logs/sensors/sensor_1.log.1 | 86 ++ logs/sensors/sensor_1.log.10 | 86 ++ logs/sensors/sensor_1.log.2 | 86 ++ logs/sensors/sensor_1.log.3 | 86 ++ logs/sensors/sensor_1.log.4 | 86 ++ logs/sensors/sensor_1.log.5 | 86 ++ logs/sensors/sensor_1.log.6 | 86 ++ logs/sensors/sensor_1.log.7 | 86 ++ logs/sensors/sensor_1.log.8 | 86 ++ logs/sensors/sensor_1.log.9 | 86 ++ logs/sensors/sensor_2.log | 16 + main.py | 191 --- main2.py | 7 - tests/{test_app.py => test_actor.py} | 33 +- tests/test_config.py | 2 +- tests/test_kettle.py | 34 +- tests/test_sensor.py | 47 + 48 files changed, 2890 insertions(+), 1201 deletions(-) create mode 100644 .idea/dataSources/3f79e533-e857-4e39-8e2e-d7f62530cc84.xml create mode 100644 .idea/dataSources/3f79e533-e857-4e39-8e2e-d7f62530cc84/storage_v2/_src_/schema/main.uQUzAA.meta rename core/sql/create_table_user.sql => config/create_database.sql (100%) create mode 100644 core/http_endpoints/swagger/example_swagger_partial.yaml rename core/{cbpiwebsocket.py => websocket.py} (100%) delete mode 100644 logs/first_logfile2.log delete mode 100644 logs/first_logfile2.log.2018-11-04_01-02 delete mode 100644 logs/first_logfile2.log.2018-11-04_01-08 delete mode 100644 logs/first_logfile2.log.2018-11-04_01-10 delete mode 100644 logs/first_logfile2.log.2018-11-04_12-43 delete mode 100644 logs/first_logfile2.log.2018-11-04_12-44 create mode 100644 logs/sensors/sensor_1.log create mode 100644 logs/sensors/sensor_1.log.1 create mode 100644 logs/sensors/sensor_1.log.10 create mode 100644 logs/sensors/sensor_1.log.2 create mode 100644 logs/sensors/sensor_1.log.3 create mode 100644 logs/sensors/sensor_1.log.4 create mode 100644 logs/sensors/sensor_1.log.5 create mode 100644 logs/sensors/sensor_1.log.6 create mode 100644 logs/sensors/sensor_1.log.7 create mode 100644 logs/sensors/sensor_1.log.8 create mode 100644 logs/sensors/sensor_1.log.9 create mode 100644 logs/sensors/sensor_2.log delete mode 100644 main.py delete mode 100644 main2.py rename tests/{test_app.py => test_actor.py} (55%) create mode 100644 tests/test_sensor.py diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index 0946b0f..2488295 100644 --- a/.idea/dataSources.local.xml +++ b/.idea/dataSources.local.xml @@ -8,5 +8,11 @@ false *:main + + + + false + *:@ + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index 52b9b2d..a24bede 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -10,5 +10,22 @@ + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/tests/craftbeerpi.db + + + + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/xerial-sqlite-license.txt + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/sqlite-jdbc-3.16.1.jar + + + \ No newline at end of file diff --git a/.idea/dataSources/3f79e533-e857-4e39-8e2e-d7f62530cc84.xml b/.idea/dataSources/3f79e533-e857-4e39-8e2e-d7f62530cc84.xml new file mode 100644 index 0000000..d0c830d --- /dev/null +++ b/.idea/dataSources/3f79e533-e857-4e39-8e2e-d7f62530cc84.xml @@ -0,0 +1,352 @@ + + + + + 3.16.1 + + + 1 + 1 + + + + + +
+
+
+
+
+
+
+ 1 +
+ +
+
+ + 1 + INTEGER|0s + 1 + + + 2 + VARCHAR(80)|0s + + + 3 + VARCHAR(80)|0s + + + 4 + VARCHAR(3000)|0s + + + id + 1 + + + 1 + VARCHAR(50)|0s + 1 + + + 2 + VARCHAR(255)|0s + + + 3 + VARCHAR(50)|0s + + + 4 + VARCHAR(255)|0s + + + 5 + VARCHAR(255)|0s + + + 1 + name + + 1 + + + name + 1 + sqlite_autoindex_config_1 + + + 1 + INTEGER|0s + 1 + + + 2 + VARCHAR(80)|0s + + + id + 1 + + + 1 + INTEGER|0s + 1 + + + 2 + INTEGER(80)|0s + + + 3 + INTEGER|0s + + + 4 + VARCHAR(80)|0s + + + 5 + INTEGER(5)|0s + + + 6 + INTEGER(5)|0s + + + 7 + VARCHAR(3000)|0s + + + id + 1 + + + 1 + INTEGER|0s + 1 + + + 2 + VARCHAR(80)|0s + + + id + 1 + + + 1 + INTEGER|0s + 1 + + + 2 + VARCHAR(80)|0s + + + 3 + VARCHAR(80)|0s + + + 4 + VARCHAR(10)|0s + + + 5 + VARCHAR(255)|0s + + + 6 + VARCHAR(50)|0s + + + 7 + VARCHAR(1000)|0s + + + 8 + VARCHAR(10)|0s + + + 9 + INTEGER|0s + + + 10 + INTEGER|0s + + + 11 + INTEGER|0s + + + id + 1 + + + 1 + INTEGER|0s + 1 + + + 2 + VARCHAR(80)|0s + + + 3 + VARCHAR(80)|0s + + + 4 + VARCHAR(3000)|0s + + + id + 1 + + + 1 + text|0s + + + 2 + text|0s + + + 3 + text|0s + + + 4 + integer|0s + + + 5 + text|0s + + + 1 + INTEGER|0s + 1 + + + 2 + INTEGER|0s + + + 3 + VARCHAR(80)|0s + + + 4 + VARCHAR(100)|0s + + + 5 + VARCHAR(255)|0s + + + 6 + VARCHAR(1)|0s + + + 7 + INTEGER|0s + + + 8 + INTEGER|0s + + + 9 + VARCHAR(255)|0s + + + 10 + INTEGER|0s + + + id + 1 + + + 1 + INTEGER|0s + 1 + + + 2 + VARCHAR(80)|0s + + + 3 + VARCHAR(80)|0s + + + 4 + VARCHAR(80)|0s + + + 5 + VARCHAR(80)|0s + + + 6 + VARCHAR(80)|0s + + + 7 + VARCHAR(10)|0s + + + 8 + VARCHAR(50)|0s + + + 9 + VARCHAR(1000)|0s + + + 10 + VARCHAR(10)|0s + + + 11 + INTEGER|0s + + + id + 1 + + + 1 + VARCHAR(3)|0s + 1 + + + 2 + VARCHAR(80)|0s + 1 + + + 3 + VARCHAR(100)|0s + 1 + + + 1 + language_code +key + + 1 + + + language_code +key + 1 + sqlite_autoindex_translation_1 + + + \ No newline at end of file diff --git a/.idea/dataSources/3f79e533-e857-4e39-8e2e-d7f62530cc84/storage_v2/_src_/schema/main.uQUzAA.meta b/.idea/dataSources/3f79e533-e857-4e39-8e2e-d7f62530cc84/storage_v2/_src_/schema/main.uQUzAA.meta new file mode 100644 index 0000000..8dab49c --- /dev/null +++ b/.idea/dataSources/3f79e533-e857-4e39-8e2e-d7f62530cc84/storage_v2/_src_/schema/main.uQUzAA.meta @@ -0,0 +1,2 @@ +#n:main +! [0, 0, null, null, -2147483648, -2147483648] diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5790b97..ae76140 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,31 +2,37 @@ + + + + + + + + + + + - - + - - - - - - - - - - - - - + + + + + + + + + @@ -40,14 +46,15 @@ - + - - + + - + + - - - - - - - + + - + + + + + + @@ -401,28 +607,6 @@ - - - - + + + + @@ -607,7 +807,7 @@ - + 1541288846149 @@ -627,39 +827,39 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - @@ -678,10 +878,10 @@ - + - + @@ -717,10 +917,6 @@ file:///usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py 25 - - file://$PROJECT_DIR$/core/controller/kettle_controller.py - file://$PROJECT_DIR$/core/eventbus.py - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + - + - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + - - + + - + - - + + + + + + + + + - + @@ -941,88 +1050,33 @@ - + - - + + + + + + + + + - + - - - - - - - - - - - + - - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1030,41 +1084,105 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + @@ -1073,80 +1191,134 @@ - - + + - + + + + - - + - + - - + + + + + + + + + - - + + + + + + - + - + - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + + + + - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/config.yaml b/config/config.yaml index bbb0861..f05f964 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -2,12 +2,10 @@ name: CraftBeerPi version: 4.1 +#index_url: /myext port: 8080 username: cbpi password: 123 -test: - name: Manuel - name2: Manuel \ No newline at end of file diff --git a/core/sql/create_table_user.sql b/config/create_database.sql similarity index 100% rename from core/sql/create_table_user.sql rename to config/create_database.sql diff --git a/core/controller/actor_controller.py b/core/controller/actor_controller.py index 581fed7..384f894 100644 --- a/core/controller/actor_controller.py +++ b/core/controller/actor_controller.py @@ -9,40 +9,223 @@ from core.database.model import ActorModel from core.http_endpoints.http_api import HttpAPI from utils.encoder import ComplexEncoder -auth = True +auth = False class ActorHttp(HttpAPI): - @request_mapping(path="/{id:\d+}/on", auth_required=auth) + @request_mapping(path="/types", auth_required=False) + async def get_types(self, request): + """ + --- + description: Get all actor types + tags: + - Actor + responses: + "200": + description: successful operation + """ + return await super().get_types(request) + + @request_mapping(path="/", auth_required=False) + async def http_get_all(self, request): + """ + + --- + description: Switch actor on + tags: + - Actor + parameters: + - name: "id" + in: "path" + description: "Actor ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + "405": + description: invalid HTTP Met + """ + return await super().http_get_all(request) + + @request_mapping(path="/{id:\d+}", auth_required=False) + async def http_get_one(self, request): + """ + --- + description: Get one Actor + tags: + - Actor + parameters: + - name: "id" + in: "path" + description: "Actor ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + "405": + description: invalid HTTP Met + """ + return await super().http_get_one(request) + + @request_mapping(path="/", method="POST", auth_required=False) + async def http_add(self, request): + """ + --- + description: Get one Actor + tags: + - Actor + parameters: + - in: body + name: body + description: Created an actor + required: false + schema: + type: object + properties: + name: + type: string + type: + type: string + config: + type: object + responses: + "204": + description: successful operation + """ + return await super().http_add(request) + + @request_mapping(path="/{id}", method="PUT", auth_required=False) + async def http_update(self, request): + """ + --- + description: Update an actor + tags: + - Actor + parameters: + - name: "id" + in: "path" + description: "Actor ID" + required: true + type: "integer" + format: "int64" + - in: body + name: body + description: Update an actor + required: false + schema: + type: object + properties: + name: + type: string + type: + type: string + config: + type: object + responses: + "200": + description: successful operation + """ + return await super().http_update(request) + + @request_mapping(path="/{id}", method="DELETE", auth_required=False) + async def http_delete_one(self, request): + """ + --- + description: Delete an actor + tags: + - Actor + parameters: + - name: "id" + in: "path" + description: "Actor ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + """ + return await super().http_delete_one(request) + + @request_mapping(path="/{id:\d+}/on", method="POST", auth_required=auth) async def http_on(self, request) -> web.Response: """ - :param request: - :return: + + --- + description: Switch actor on + tags: + - Actor + + parameters: + - name: "id" + in: "path" + description: "Actor ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + "405": + description: invalid HTTP Met """ id = int(request.match_info['id']) result = await self.cbpi.bus.fire(topic="actor/%s/switch/on" % id, id=id, power=99) - - for key, value in result.results.items(): pass return web.Response(status=204) - @request_mapping(path="/{id:\d+}/off", auth_required=auth) + @request_mapping(path="/{id:\d+}/off", method="POST", auth_required=auth) async def http_off(self, request) -> web.Response: """ - :param request: - :return: + + --- + description: Switch actor off + tags: + - Actor + + parameters: + - name: "id" + in: "path" + description: "Actor ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + "405": + description: invalid HTTP Met """ id = int(request.match_info['id']) await self.cbpi.bus.fire(topic="actor/%s/off" % id, id=id) return web.Response(status=204) - @request_mapping(path="/{id:\d+}/toggle", auth_required=auth) + @request_mapping(path="/{id:\d+}/toggle", method="POST", auth_required=auth) async def http_toggle(self, request) -> web.Response: """ - :param request: - :return: + + --- + description: Toogle an actor on or off + tags: + - Actor + parameters: + - name: "id" + in: "path" + description: "Actor ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + "405": + description: invalid HTTP Met """ id = int(request.match_info['id']) @@ -79,13 +262,12 @@ class ActorController(ActorHttp, CRUDController): await super(ActorController, self).init() for id, value in self.cache.items(): - await self._init_actor(value) async def _init_actor(self, actor): - print("INIT ACXTOR") + if actor.type in self.types: - print("INIT ONE ACTOT") + cfg = actor.config.copy() cfg.update(dict(cbpi=self.cbpi, id=id, name=actor.name)) clazz = self.types[actor.type]["class"]; diff --git a/core/controller/config_controller.py b/core/controller/config_controller.py index 5551978..f61d256 100644 --- a/core/controller/config_controller.py +++ b/core/controller/config_controller.py @@ -3,6 +3,7 @@ import os from aiohttp import web from cbpi_api import request_mapping +from cbpi_api.exceptions import CBPiException from core.controller.crud_controller import CRUDController from core.database.model import ConfigModel @@ -13,8 +14,19 @@ class ConfigHTTPController(): @request_mapping(path="/{name}/", method="POST", auth_required=False) async def http_post(self, request) -> web.Response: """ - :param request: - :return: + --- + description: Set config parameter + tags: + - Config + parameters: + - name: "name" + in: "path" + description: "Parameter name" + required: true + type: "string" + responses: + "204": + description: successful operation """ name = request.match_info['name'] data = await request.json() @@ -25,11 +37,39 @@ class ConfigHTTPController(): @request_mapping(path="/", auth_required=False) async def http_get_all(self, request) -> web.Response: """ - :param request: - :return: + --- + description: Get all config parameters + tags: + - Config + responses: + "200": + description: successful operation """ return web.json_response(self.cache, dumps=json_dumps) + @request_mapping(path="/{name}/", auth_required=False) + async def http_paramter(self, request) -> web.Response: + """ + --- + description: Get all config parameters + tags: + - Config + parameters: + - name: "name" + in: "path" + description: "Parameter name" + required: true + type: "string" + responses: + "200": + description: successful operation + """ + name = request.match_info['name'] + if name not in self.cache: + raise CBPiException("Parameter %s not found" % name) + + return web.json_response(self.cache.get(name), dumps=json_dumps) + class ConfigController(ConfigHTTPController): ''' diff --git a/core/controller/crud_controller.py b/core/controller/crud_controller.py index 29efbcf..64effb9 100644 --- a/core/controller/crud_controller.py +++ b/core/controller/crud_controller.py @@ -138,12 +138,10 @@ class CRUDController(metaclass=ABCMeta): await self._post_delete_callback(id) try: if self.caching is True: - del self.cache[int(id)] except Exception as e: - pass - pprint.pprint(self.cache) + await self.cbpi.bus.fire(topic="actor/%s/deleted" % id, id=id) async def delete_all(self): diff --git a/core/controller/job_controller.py b/core/controller/job_controller.py index e6e0e5f..1a242bb 100644 --- a/core/controller/job_controller.py +++ b/core/controller/job_controller.py @@ -1,6 +1,9 @@ import asyncio import logging +from aiohttp import web +from cbpi_api import request_mapping + from job.aiohttp import setup, get_scheduler_from_app logger = logging.getLogger(__name__) diff --git a/core/controller/kettle_controller.py b/core/controller/kettle_controller.py index 284d0fe..c009ed9 100644 --- a/core/controller/kettle_controller.py +++ b/core/controller/kettle_controller.py @@ -1,39 +1,54 @@ import re from aiohttp import web - - from cbpi_api import * +from cbpi_api.exceptions import KettleException, ActorException, SensorException + from core.controller.crud_controller import CRUDController from core.database.model import KettleModel from core.http_endpoints.http_api import HttpAPI from core.job.aiohttp import get_scheduler_from_app -from core.utils import json_dumps class KettleHttp(HttpAPI): - @request_mapping(path="/types", auth_required=False) - async def get_types(self, request): - web.json_response(data=self.cbpi.kettle.types, dumps=json_dumps) - @request_mapping(path="/{id:\d+}/automatic", auth_required=False) - async def start2(self, request): - id = int(request.match_info['id']) - result = await self.cbpi.kettle.toggle_automtic(id) - if result[0] is True: - return web.Response(text="OK") - else: - return web.Response(status=404, text=result[1]) + async def http_automatic(self, request): + await self.cbpi.kettle.toggle_automtic(int(request.match_info['id'])) + return web.Response(status=204) + + @request_mapping(path="/{id:\d+}/heater/on", auth_required=False) + async def http_heater_on(self, request): + await self.cbpi.kettle.heater_on(int(request.match_info['id'])) + return web.Response(status=204) + + @request_mapping(path="/{id:\d+}/heater/off", auth_required=False) + async def http_heater_off(self, request): + await self.cbpi.kettle.heater_off(int(request.match_info['id'])) + return web.Response(status=204) + + @request_mapping(path="/{id:\d+}/agitator/on", auth_required=False) + async def http_agitator_on(self, request): + await self.cbpi.kettle.agitator_on(int(request.match_info['id'])) + return web.Response(status=204) + + @request_mapping(path="/{id:\d+}/agitator/off", auth_required=False) + async def http_agitator_off(self, request): + await self.cbpi.kettle.agitator_off(int(request.match_info['id'])) + return web.Response(status=204) + + @request_mapping(path="/{id:\d+}/targettemp", auth_required=False) + async def http_taget_temp(self, request): + kettle_id = int(request.match_info['id']) + temp = await self.cbpi.kettle.get_traget_temp(kettle_id) + return web.json_response(data=dict(target_temp=temp, kettle_id=kettle_id)) + + @request_mapping(path="/{id:\d+}/temp", auth_required=False) + async def http_temp(self, request): + kettle_id = int(request.match_info['id']) + temp = await self.cbpi.kettle.get_temp(kettle_id) + return web.json_response(data=dict(temp=temp, kettle_id=kettle_id)) - @request_mapping(path="/{id:\d+}/heater", auth_required=False) - async def start(self, request): - id = int(request.match_info['id']) - result = await self.cbpi.kettle.heater_on(id) - if result[0] is True: - return web.Response(text="OK") - else: - return web.Response(status=404, text=result[1]) class KettleController(CRUDController, KettleHttp): ''' @@ -47,9 +62,6 @@ class KettleController(CRUDController, KettleHttp): self.types = {} self.cbpi.register(self, "/kettle") - - - async def init(self): ''' This method initializes all actors during startup. It creates actor instances @@ -68,12 +80,11 @@ class KettleController(CRUDController, KettleHttp): ''' kettle = await self.get_one(id) if kettle is None: - return (False, "Kettle Not Found") + raise KettleException("Kettle not found") if kettle.logic is None: - return (False, "No Logic defined") - id = kettle.heater + raise CBPiExtension("Logic not found for kettle id: %s" % id) + await self.cbpi.bus.fire(topic="kettle/%s/automatic" % id, id=id) - return (True, "Logic switched on switched") @on_event(topic="job/done") async def job_stop(self, key, **kwargs) -> None: @@ -84,8 +95,6 @@ class KettleController(CRUDController, KettleHttp): kettle = self.cache[int(kid)] kettle.instance = None - - @on_event(topic="kettle/+/automatic") async def handle_automtic_event(self, id, **kwargs): @@ -112,16 +121,14 @@ class KettleController(CRUDController, KettleHttp): cfg.update(dict(cbpi=self.cbpi)) kettle.instance = clazz(**cfg) - await self.cbpi.job.start_job(kettle.instance.run(), "Kettle_logic_%s" % kettle.id, "kettle_logic%s"%id) + await self.cbpi.job.start_job(kettle.instance.run(), "Kettle_logic_%s" % kettle.id, "kettle_logic%s" % id) else: kettle.instance.running = False kettle.instance = None - def _is_logic_running(self, kettle_id): scheduler = get_scheduler_from_app(self.cbpi.app) - async def heater_on(self, id): ''' Convenience Method to switch the heater of a kettle on @@ -132,12 +139,11 @@ class KettleController(CRUDController, KettleHttp): ''' kettle = await self.get_one(id) if kettle is None: - return (False, "Kettle Not Found") - if kettle.heater is None: - return (False, "No Heater defined") + raise KettleException("Kettle not found") + if kettle.sensor is None: + raise ActorException("Actor not defined for kettle id %s" % id) id = kettle.heater - await self.cbpi.bus.fire(topic="actor/%s/on" % id, id=id, power=99) - return (True,"Heater switched on") + await self.cbpi.bus.fire(topic="actor/%s/switch/on" % id, id=id, power=99) async def heater_off(self, id): ''' @@ -149,23 +155,44 @@ class KettleController(CRUDController, KettleHttp): ''' kettle = await self.get_one(id) if kettle is None: - return (False, "Kettle Not Found") - if kettle.heater is None: - return (False, "No Heater defined") + raise KettleException("Kettle not found") + if kettle.sensor is None: + raise ActorException("Actor not defined for kettle id %s" % id) id = kettle.heater - await self.cbpi.bus.fire(topic="actor/%s/off" % id, id=id, power=99) - return (True, "Heater switched off") + await self.cbpi.bus.fire(topic="actor/%s/switch/off" % id, id=id, power=99) async def agitator_on(self, id): - pass + kettle = await self.get_one(id) + if kettle is None: + raise KettleException("Kettle not found") + if kettle.sensor is None: + raise ActorException("Actor not defined for kettle id %s" % id) + agitator_id = kettle.agitator + await self.cbpi.bus.fire(topic="actor/%s/switch/on" % agitator_id, id=agitator_id, power=99) async def agitator_off(self, id): - pass + kettle = await self.get_one(id) + if kettle is None: + raise KettleException("Kettle not found") + if kettle.sensor is None: + raise ActorException("Actor not defined for kettle id %s" % id) + agitator_id = kettle.agitator + await self.cbpi.bus.fire(topic="actor/%s/switch/off" % agitator_id, id=agitator_id, power=99) async def get_traget_temp(self, id): kettle = await self.get_one(id) + if kettle is None: + raise KettleException("Kettle Not Found") return kettle.target_temp async def get_temp(self, id): - pass \ No newline at end of file + kettle = await self.get_one(id) + if kettle is None: + raise KettleException("Kettle Not Found") + if kettle.sensor is None: + raise SensorException("Sensor not defined for kettle id %s" % id) + + sensor_id = kettle.sensor + + return await self.cbpi.sensor.get_value(sensor_id) diff --git a/core/controller/sensor_controller.py b/core/controller/sensor_controller.py index e87f309..4134b0d 100644 --- a/core/controller/sensor_controller.py +++ b/core/controller/sensor_controller.py @@ -1,6 +1,8 @@ import json import logging +from cbpi_api import request_mapping + from core.controller.crud_controller import CRUDController from core.database.model import SensorModel from core.http_endpoints.http_api import HttpAPI @@ -21,9 +23,137 @@ class SensorController(CRUDController, HttpAPI): self.sensors = {} def info(self): - return json.dumps(dict(name="SensorController", types=self.types), cls=ComplexEncoder) + @request_mapping(path="/types", auth_required=False) + async def get_types(self, request): + """ + --- + description: Get all sensor types + tags: + - Sensor + responses: + "200": + description: successful operation + """ + return await super().get_types(request) + + @request_mapping(path="/", auth_required=False) + async def http_get_all(self, request): + """ + + --- + description: Get all sensor + tags: + - Sensor + responses: + "204": + description: successful operation + """ + return await super().http_get_all(request) + + @request_mapping(path="/{id:\d+}", auth_required=False) + async def http_get_one(self, request): + """ + --- + description: Get an sensor + tags: + - Sensor + parameters: + - name: "id" + in: "path" + description: "Sensor ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + "405": + description: invalid HTTP Met + """ + return await super().http_get_one(request) + + @request_mapping(path="/", method="POST", auth_required=False) + async def http_add(self, request): + """ + --- + description: Get one sensor + tags: + - Sensor + parameters: + - in: body + name: body + description: Created an sensor + required: false + schema: + type: object + properties: + name: + type: string + type: + type: string + config: + type: object + responses: + "204": + description: successful operation + """ + return await super().http_add(request) + + @request_mapping(path="/{id}", method="PUT", auth_required=False) + async def http_update(self, request): + """ + --- + description: Update an sensor + tags: + - Sensor + parameters: + - name: "id" + in: "path" + description: "Sensor ID" + required: true + type: "integer" + format: "int64" + - in: body + name: body + description: Update an sensor + required: false + schema: + type: object + properties: + name: + type: string + type: + type: string + config: + type: object + responses: + "200": + description: successful operation + """ + return await super().http_update(request) + + @request_mapping(path="/{id}", method="DELETE", auth_required=False) + async def http_delete_one(self, request): + """ + --- + description: Delete an sensor + tags: + - Sensor + parameters: + - name: "id" + in: "path" + description: "Sensor ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + """ + return await super().http_delete_one(request) + async def init(self): ''' This method initializes all actors during startup. It creates actor instances @@ -31,19 +161,51 @@ class SensorController(CRUDController, HttpAPI): :return: ''' await super(SensorController, self).init() - - - for id, value in self.cache.items(): - if value.type in self.types: - cfg = value.config.copy() - cfg.update(dict(cbpi=self.cbpi, id=id, name=value.name)) - clazz = self.types[value.type]["class"]; - self.cache[id].instance = clazz(**cfg) - scheduler = get_scheduler_from_app(self.cbpi.app) - self.cache[id].instance.job = await scheduler.spawn(self.cache[id].instance.run(self.cbpi), value.name, "sensor") - else: - self.logger.error("Sensor type '%s' not found (Available Sensor Types: %s)" % (value.type, ', '.join(self.types.keys()))) + await self.init_sensor(value) - async def get_value(self, id): - return self.cache[id].instance.value \ No newline at end of file + async def init_sensor(self, sensor): + if sensor.type in self.types: + cfg = sensor.config.copy() + cfg.update(dict(cbpi=self.cbpi, id=sensor.id, name=sensor.name)) + clazz = self.types[sensor.type]["class"]; + self.cache[sensor.id].instance = clazz(**cfg) + self.cache[sensor.id].instance.init() + scheduler = get_scheduler_from_app(self.cbpi.app) + self.cache[sensor.id].instance.job = await scheduler.spawn(self.cache[sensor.id].instance.run(self.cbpi), sensor.name, "sensor") + else: + self.logger.error("Sensor type '%s' not found (Available Sensor Types: %s)" % (sensor.type, ', '.join(self.types.keys()))) + + async def stop_sensor(self, sensor): + print("STOP", sensor.id) + sensor.instance.stop() + await self.cbpi.bus.fire(topic="sensor/%s/stopped" % sensor.id, id=sensor.id) + + + async def get_value(self, sensor_id): + sensor_id = int(sensor_id) + return self.cache[sensor_id].instance.value + + async def _post_add_callback(self, m): + ''' + + :param m: + :return: + ''' + await self.init_sensor(m) + pass + + async def _pre_delete_callback(self, sensor_id): + if int(sensor_id) not in self.cache: + return + + if self.cache[int(sensor_id)].instance is not None: + await self.stop_sensor(self.cache[int(sensor_id)]) + + async def _pre_update_callback(self, sensor): + + if sensor.instance is not None: + await self.stop_sensor(sensor) + + async def _post_update_callback(self, sensor): + self.init_sensor(sensor) \ No newline at end of file diff --git a/core/controller/step_controller.py b/core/controller/step_controller.py index f4c09e0..f444c3f 100644 --- a/core/controller/step_controller.py +++ b/core/controller/step_controller.py @@ -1,21 +1,238 @@ import asyncio - import time + from aiohttp import web from cbpi_api import * +from cbpi_api.exceptions import CBPiException + from core.controller.crud_controller import CRUDController from core.database.model import StepModel from core.http_endpoints.http_api import HttpAPI -from core.job.aiohttp import get_scheduler_from_app -class StepController(HttpAPI, CRUDController): +class StepHttpAPI(HttpAPI): + @request_mapping(path="/types", auth_required=False) + async def get_types(self, request): + """ + --- + description: Get all step types + tags: + - Step + responses: + "200": + description: successful operation + """ + return await super().get_types(request) + + @request_mapping(path="/", auth_required=False) + async def http_get_all(self, request): + """ + + --- + description: Switch step on + tags: + - Step + parameters: + - name: "id" + in: "path" + description: "step ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + "405": + description: invalid HTTP Met + """ + return await super().http_get_all(request) + + @request_mapping(path="/{id:\d+}", auth_required=False) + async def http_get_one(self, request): + """ + --- + description: Get one step + tags: + - Step + parameters: + - name: "id" + in: "path" + description: "step ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + "405": + description: invalid HTTP Met + """ + return await super().http_get_one(request) + + @request_mapping(path="/", method="POST", auth_required=False) + async def http_add(self, request): + """ + --- + description: Get one step + tags: + - Step + parameters: + - in: body + name: body + description: Created an step + required: false + schema: + type: object + properties: + name: + type: string + type: + type: string + config: + type: object + responses: + "204": + description: successful operation + """ + return await super().http_add(request) + + @request_mapping(path="/{id}", method="PUT", auth_required=False) + async def http_update(self, request): + """ + --- + description: Update an step + tags: + - Step + parameters: + - name: "id" + in: "path" + description: "step ID" + required: true + type: "integer" + format: "int64" + - in: body + name: body + description: Update an step + required: false + schema: + type: object + properties: + name: + type: string + type: + type: string + config: + type: object + responses: + "200": + description: successful operation + """ + return await super().http_update(request) + + @request_mapping(path="/{id}", method="DELETE", auth_required=False) + async def http_delete_one(self, request): + """ + --- + description: Delete a step + tags: + - Step + parameters: + - name: "id" + in: "path" + description: "Step ID" + required: true + type: "integer" + format: "int64" + responses: + "204": + description: successful operation + """ + return await super().http_delete_one(request) + + + @request_mapping(path="/action", auth_required=False) + async def http_action(self, request): + """ + --- + description: Call step action + tags: + - Step + responses: + "204": + description: successful operation + """ + await self.cbpi.bus.fire("step/action", action="test") + return web.Response(text="OK") + + @request_mapping(path="/start", auth_required=False) + async def http_start(self, request): + """ + --- + description: Start Brewing Process + tags: + - Step + responses: + "204": + description: successful operation + """ + if self.is_running(): + raise CBPiException("Brewing Process Already Running") + result = await self.cbpi.bus.fire("step/start") + r = result.get("core.controller.step_controller.handle_start") + if r[0] is True: + return web.Response(status=204) + else: + raise CBPiException("Failed to start brewing process") + + + @request_mapping(path="/reset", auth_required=False) + async def http_reset(self, request): + """ + --- + description: Reset Brewing Process + tags: + - Step + responses: + "204": + description: successful operation + """ + await self.cbpi.bus.fire("step/reset") + return web.Response(text="OK") + + @request_mapping(path="/next", auth_required=False) + async def http_next(self, request): + """ + --- + description: Start next step + tags: + - Step + responses: + "204": + description: successful operation + """ + await self.cbpi.bus.fire("step/next") + return web.Response(text="OK") + + @request_mapping(path="/stop", auth_required=False) + async def http_stop(self, request): + """ + --- + description: Stop next step + tags: + - Step + responses: + "204": + description: successful operation + """ + await self.cbpi.bus.fire("step/stop") + return web.Response(text="OK") + +class StepController(StepHttpAPI, CRUDController): ''' The Step Controller. This controller is responsible to start and stop the brewing steps. ''' - model = StepModel def __init__(self, cbpi): @@ -24,12 +241,11 @@ class StepController(HttpAPI, CRUDController): self.cbpi = cbpi self.current_task = None self.types = {} - self.current_step = None + self.current_job = None self.cbpi.register(self, "/step") - async def init(self): ''' Initializer of the the Step Controller. @@ -37,22 +253,15 @@ class StepController(HttpAPI, CRUDController): ''' await super(StepController, self).init() - await self.init_after_startup() - - async def init_after_startup(self): step = await self.model.get_by_state('A') # We have an active step - - if step is not None: # get the type - step_type = self.types.get(step.type) if step_type is None: # step type not found. cant restart step - return if step.stepstate is not None: @@ -64,54 +273,7 @@ class StepController(HttpAPI, CRUDController): self.current_step = step_type["class"](**cfg) self.current_job = await self.cbpi.job.start_job(self.current_step.run(), step.name, "step") - @request_mapping(path="/action", auth_required=False) - async def http_action(self, request): - ''' - HTTP Endpoint to call an action on the current step. - - :param request: web requset - :return: web.Response(text="OK" - ''' - await self.cbpi.bus.fire("step/action", action="test") - return web.Response(text="OK") - - - @request_mapping(path="/start", auth_required=False) - async def http_start(self, request): - - ''' - HTTP Endpoint to start the brewing process. - - :param request: - :return: - ''' - - await self.cbpi.bus.fire("step/start") - return web.Response(text="OK") - - @request_mapping(path="/reset", auth_required=False) - async def http_reset(self, request): - ''' - HTTP Endpoint to call reset on the current step. - - :param request: - :return: - ''' - await self.cbpi.bus.fire("step/reset") - return web.Response(text="OK") - - @request_mapping(path="/next", auth_required=False) - async def http_next(self, request): - - ''' - HTTP Endpoint to start the next step. The current step will be stopped - - :param request: - :return: - ''' - await self.cbpi.bus.fire("step/next") - return web.Response(text="OK") @on_event("step/action") async def handle_action(self, action, **kwargs): @@ -139,54 +301,23 @@ class StepController(HttpAPI, CRUDController): :return: None ''' if self.current_step is not None: - self.current_step.next() pass - - - @on_event("step/start") - async def handle_start(self, **kwargs): - ''' - Event Handler for "step/start". - It starts the brewing process - - :param kwargs: - :return: None - ''' - await self.start() - @on_event("step/reset") async def handle_reset(self, **kwargs): ''' Event Handler for "step/reset". Resets the current step - :param kwargs: - :return: None - ''' - await self.model.reset_all_steps() - - - - @on_event("step/stop") - async def handle_stop(self, **kwargs): - ''' - Event Handler for "step/stop". - Stops the current step - - :param kwargs: :return: None ''' if self.current_step is not None: - self.current_step.stop() - - for key, step in self.cache.items(): - step.state = None - - self.current_step = None + await self.stop() + self.is_stopping = True + await self.model.reset_all_steps() @on_event("job/step/done") @@ -201,7 +332,6 @@ class StepController(HttpAPI, CRUDController): :return: ''' - if self.cbpi.shutdown: return @@ -209,9 +339,10 @@ class StepController(HttpAPI, CRUDController): step_id = self.current_step.id self.current_step = None - await self.start() - + if self.is_stopping is not True: + await self.start() + self.is_stopping = False def _get_manged_fields_as_array(self, type_cfg): @@ -221,7 +352,14 @@ class StepController(HttpAPI, CRUDController): return result - async def start(self): + def is_running(self): + if self.current_step is not None: + return True + else: + return False + + @on_event("step/start") + async def start(self, future, **kwargs): ''' Start the first step @@ -236,8 +374,6 @@ class StepController(HttpAPI, CRUDController): inactive = await self.model.get_by_state("I") active = await self.model.get_by_state("A") - - if active is not None: active.state = 'D' active.end = int(time.time()) @@ -259,5 +395,11 @@ class StepController(HttpAPI, CRUDController): else: await self.cbpi.bus.fire("step/berwing/finished") - async def stop(self): - pass + future.set_result(True) + + @on_event("step/stop") + async def stop(self, **kwargs): + if self.current_job is not None: + self.is_stopping = True + await self.current_job.close() + await self.model.reset_all_steps() diff --git a/core/craftbeerpi.py b/core/craftbeerpi.py index d3995f9..de37091 100644 --- a/core/craftbeerpi.py +++ b/core/craftbeerpi.py @@ -7,9 +7,10 @@ from aiohttp_auth import auth from aiohttp_session import session_middleware from aiohttp_session.cookie_storage import EncryptedCookieStorage from aiohttp_swagger import setup_swagger +from cbpi_api.exceptions import CBPiException from controller.job_controller import JobController -from core.cbpiwebsocket import CBPiWebSocket +from core.websocket import CBPiWebSocket from core.controller.actor_controller import ActorController from core.controller.config_controller import ConfigController from core.controller.kettle_controller import KettleController @@ -26,19 +27,36 @@ from core.utils import * logger = logging.getLogger(__name__) logging.basicConfig(level=logging.INFO) + + +@web.middleware +async def error_middleware(request, handler): + try: + response = await handler(request) + if response.status != 404: + return response + message = response.message + except web.HTTPException as ex: + if ex.status != 404: + raise + message = ex.reason + except CBPiException as ex: + message = str(ex) + return web.json_response(status=500, data={'error': message}) + return web.json_response({'error': message}) + class CraftBeerPi(): def __init__(self): self.static_config = load_config(os.path.join(os.path.dirname(__file__), '../config/config.yaml')) - + self.database_file = "./craftbeerpi.db" logger.info("Init CraftBeerPI") policy = auth.SessionTktAuthentication(urandom(32), 60, include_ip=True) - middlewares = [web.normalize_path_middleware(), session_middleware(EncryptedCookieStorage(urandom(32))), auth.auth_middleware(policy)] + middlewares = [web.normalize_path_middleware(), session_middleware(EncryptedCookieStorage(urandom(32))), auth.auth_middleware(policy), error_middleware] self.app = web.Application(middlewares=middlewares) - self._setup_shutdownhook() self.initializer = [] self.bus = CBPiEventBus(self.app.loop, self) @@ -97,7 +115,7 @@ class CraftBeerPi(): routes.append(web.post(method.__getattribute__("path"), method)) def add_get(): - routes.append(web.get(method.__getattribute__("path"), method)) + routes.append(web.get(method.__getattribute__("path"), method, allow_head=False)) def add_delete(): routes.append(web.delete(path, method)) @@ -161,6 +179,17 @@ class CraftBeerPi(): f = Figlet(font='big') logger.info("\n%s" % f.renderText("%s %s" % (self.static_config.get("name"), self.static_config.get("version")))) + + def _setup_http_index(self): + async def http_index(request): + url = self.config.static.get("index_url") + if url is not None: + raise web.HTTPFound(url) + else: + return web.Response(text="Hello, world") + + self.app.add_routes([web.get('/', http_index)]) + async def init_serivces(self): self._print_logo() @@ -168,6 +197,8 @@ class CraftBeerPi(): await self.job.init() await DBModel.setup() await self.config.init() + + self._setup_http_index() self.plugin.load_plugins() self.plugin.load_plugins_from_evn() await self.sensor.init() diff --git a/core/database/orm_framework.py b/core/database/orm_framework.py index ed85dd6..e7065ec 100644 --- a/core/database/orm_framework.py +++ b/core/database/orm_framework.py @@ -34,7 +34,7 @@ class DBModel(object): async with aiosqlite.connect(DATABASE_FILE) as db: assert isinstance(db, aiosqlite.Connection) this_directory = os.path.dirname(__file__) - qry = open(os.path.join(this_directory, '../sql/create_table_user.sql'), 'r').read() + qry = open(os.path.join(this_directory, '../../config/create_database.sql'), 'r').read() cursor = await db.executescript(qry) @classmethod diff --git a/core/eventbus.py b/core/eventbus.py index 6d86c58..4d8aab1 100644 --- a/core/eventbus.py +++ b/core/eventbus.py @@ -2,6 +2,8 @@ import asyncio import inspect import logging +from cbpi_api.exceptions import CBPiException + class CBPiEventBus(object): class Node(object): @@ -37,12 +39,15 @@ class CBPiEventBus(object): else: self.results[key] = CBPiEventBus.Result(None, False) + def get(self, key): + r = self.results.get(key) + if r is None: + raise CBPiException("Event Key %s not found." % key) + return (r.result, r.timeout) def register(self, topic, method, once=False): - - if method in self.registry: raise RuntimeError("Method %s already registerd. Please unregister first!" % method.__name__) self.logger.info("Topic %s", topic) @@ -151,7 +156,8 @@ class CBPiEventBus(object): result = [] if node._content is not None: for c in node._content: - result.append(dict(topic=c.topic, method=c.method.__name__, path=c.method.__module__, once=c.once)) + + result.append(dict(topic=c.topic, supports_future=c.supports_future, method=c.method.__name__, path=c.method.__module__, once=c.once)) if node._children is not None: for c in node._children: diff --git a/core/extension/dummyactor/__init__.py b/core/extension/dummyactor/__init__.py index 3174333..358d704 100644 --- a/core/extension/dummyactor/__init__.py +++ b/core/extension/dummyactor/__init__.py @@ -24,14 +24,14 @@ class CustomActor(CBPiActor): def off(self): - + print("OFF") # Code to swtich the actor off goes here self.state = False def on(self, power=100): - + print("ON") # Code to swtich the actor on goes here self.state = True diff --git a/core/extension/dummysensor/__init__.py b/core/extension/dummysensor/__init__.py index 4c54e79..61b5755 100644 --- a/core/extension/dummysensor/__init__.py +++ b/core/extension/dummysensor/__init__.py @@ -23,6 +23,10 @@ class CustomSensor(CBPiSensor): ''' pass + def init(self): + super().init() + + def state(self): super().state() @@ -33,7 +37,7 @@ class CustomSensor(CBPiSensor): self.value = 0 while True: await asyncio.sleep(self.interval) - + self.log_data(10) self.value = self.value + 1 await cbpi.bus.fire("sensor/%s" % self.id, value=self.value) diff --git a/core/http_endpoints/http_api.py b/core/http_endpoints/http_api.py index 653f683..42e2ed2 100644 --- a/core/http_endpoints/http_api.py +++ b/core/http_endpoints/http_api.py @@ -1,5 +1,6 @@ import logging from aiohttp import web +from aiohttp_swagger import swagger_path from cbpi_api import * from core.utils.utils import json_dumps @@ -8,103 +9,30 @@ class HttpAPI(): self.logger = logging.getLogger(__name__) self.cbpi = cbpi + @request_mapping(path="/types", auth_required=False) + async def get_types(self, request): + if self.types is not None: + return web.json_response(data=self.types, dumps=json_dumps) + else: + return web.Response(status=404, text="Types not supported by endpoint") + @request_mapping(path="/", auth_required=False) async def http_get_all(self, request): - """ - - --- - - description: This end-point allow to test that service is up. - tags: - - REST API - produces: - - application/json - parameters: - - name: "id" - in: "path" - description: "ID of object to return" - required: true - type: "integer" - format: "int64" - responses: - "200": - description: successful operation. Return "pong" text - "405": - description: invalid HTTP Met - """ - return web.json_response(await self.get_all(force_db_update=True), dumps=json_dumps) @request_mapping(path="/{id:\d+}", auth_required=False) async def http_get_one(self, request): - """ - --- - description: This end-point allow to test that service is up. - tags: - - REST API - produces: - - application/json - parameters: - - name: "id" - in: "path" - description: "ID of object to return" - required: true - type: "integer" - format: "int64" - responses: - "200": - description: successful operation. Return "pong" text - "405": - description: invalid HTTP Method - """ id = int(request.match_info['id']) return web.json_response(await self.get_one(id), dumps=json_dumps) @request_mapping(path="/", method="POST", auth_required=False) async def http_add(self, request): - """ - --- - description: This end-point allow to test that service is up. - tags: - - REST API - produces: - - application/json - responses: - "200": - description: successful operation. Return "pong" text - "405": - description: invalid HTTP Method - """ data = await request.json() obj = await self.add(**data) return web.json_response(obj, dumps=json_dumps) @request_mapping(path="/{id}", method="PUT", auth_required=False) async def http_update(self, request): - """ - --- - description: This end-point allow to test that service is up. - tags: - - REST API - produces: - - application/json - parameters: - - in: body - name: body - description: Created user object - required: false - schema: - type: object - properties: - id: - type: integer - format: int64 - responses: - "200": - description: successful operation. Return "pong" text - "405": - description: invalid HTTP Method - """ id = request.match_info['id'] data = await request.json() obj = await self.update(id, data) @@ -112,19 +40,6 @@ class HttpAPI(): @request_mapping(path="/{id}", method="DELETE", auth_required=False) async def http_delete_one(self, request): - """ - --- - description: This end-point allow to test that service is up. - tags: - - REST API - produces: - - text/plain - responses: - "200": - description: successful operation. Return "pong" text - "405": - description: invalid HTTP Method - """ id = request.match_info['id'] - await self.delete(id) + await self.delete(int(id)) return web.Response(status=204) diff --git a/core/http_endpoints/http_login.py b/core/http_endpoints/http_login.py index 7135b88..cd6be78 100644 --- a/core/http_endpoints/http_login.py +++ b/core/http_endpoints/http_login.py @@ -10,7 +10,6 @@ class Login(): self.cbpi = cbpi self.cbpi.register(self) - self.db = {cbpi.static_config.get("username", "cbpi"): cbpi.static_config.get("password", "cbpi")} @request_mapping(path="/logout", name="Logout", method="GET", auth_required=True) @@ -21,10 +20,8 @@ class Login(): @request_mapping(path="/login",name="Login", method="POST", auth_required=False) async def login_view(self, request): - print("TRY LOGIN") params = await request.post() - user = params.get('username', None) password = params.get('password', None) print("UUSEr", user, password, str(self.db[user])) diff --git a/core/http_endpoints/swagger/example_swagger_partial.yaml b/core/http_endpoints/swagger/example_swagger_partial.yaml new file mode 100644 index 0000000..c4a5ab1 --- /dev/null +++ b/core/http_endpoints/swagger/example_swagger_partial.yaml @@ -0,0 +1,39 @@ +tags: +- user +summary: Create user111 +description: This can only be done by the logged in user. +operationId: examples.api.api.createUser +produces: +- application/json +parameters: +- in: body + name: body + description: Created user object + required: false + schema: + type: object + properties: + id: + type: integer + format: int64 + username: + type: + - "string" + - "null" + firstName: + type: string + lastName: + type: string + email: + type: string + password: + type: string + phone: + type: string + userStatus: + type: integer + format: int32 + description: User Status +responses: + "201": + description: successful operation \ No newline at end of file diff --git a/core/cbpiwebsocket.py b/core/websocket.py similarity index 100% rename from core/cbpiwebsocket.py rename to core/websocket.py diff --git a/craftbeerpi.db b/craftbeerpi.db index 521ee46cac114707f45f9aa6140261b0bff5e73d..7cf6f16c8a6d3490f38940f39911a7ccb367dbcd 100644 GIT binary patch delta 950 zcmZozz}&Ead4d!ZYxqPNCpOk_20e}JjVbf=xo$Hs@gHR1f5v}sGmpU}eijA>hM>s@ zjO6kdB$!wkB$WjnlS}f8jGRl0OY(EU?CM&e8g5BR!QzslObJGWB105Kyg*fq{FfQ{ zFY_+V5}cY>oL>|lT9A@hl4>|vz+Zw(!L(LKh?PNAReSO+ ze-#jyfr05i5?4n6U3M|DEFZe8JF+Yfnk?gMWLYk_tQ^>0#(qLBNye+K^T z{3ZPU{I`K-PUX|!4`oPa5ZAQiX93BDL7Ac;hnAQ?(-?mkgY)E-eTtw&-!?h2-$X$B zy?2cE`}n-loE(0jpwr|z{gN!o%-jr<_4*aFm6^C1fCd3Q%>Xe7nk|A$QVW1i&-4W8 n18S4AVFW4^1z8SN2(_>zRS6=4Faj=vFhQAxn_=_)enkfWBx(Eu delta 551 zcmZozz}&Ead4d!Zi`_&SCpH#420d2CjVbf=xehQe^3P-7pU0uMna5xfKa&FEWCIHY z76t|ehsh20ipFxH(qfFP45Iw1A*sbBhSf^x1)2FuRtiQ&wY)$@jQp1w_%HK4Lx!6L z1e4D%S(X-p9UxZy7=t5Oh&B+ISRd`HmdHHuTh;mP3;BTGG6`%ohO$s-YvFPN5F(#YOMDJwg zGGgRm5M|(J(AS;J7_B6u6z=cu;jaX8p^zw$&lM>jt7@7H3@iX$9 z@OJ=>`^cwi$i${>C@CuH>=fV`AL1Gu5^rQ^YGP(=Vqsxosb^+xYHVg^Iaw_~NPrbh z;pUF~Dgiz%1{S`h416#6XYhyeEd`o6m5;@dg_~jW**?X|!u`TB68D8;B<`!{mFDC) zFmf|6h-zB$v#^MQoi(XnjbCg>PmI`(r676!+YH*1gZmY^_<_#$U~psx8uO{oL`>q| q2cQwcASI4WKqJJ#Mog~n7oE)4F99@RX$(*aNE)b5b@TmxMF#--`HG|f diff --git a/logs/first_logfile2.log b/logs/first_logfile2.log deleted file mode 100644 index 51dbdfb..0000000 --- a/logs/first_logfile2.log +++ /dev/null @@ -1,42 +0,0 @@ -2018-11-04 12:52:49,171,1,WOOHO -2018-11-04 12:53:45,824,1,WOOHO -2018-11-04 12:53:46,827,1,WOOHO -2018-11-04 12:53:47,831,1,WOOHO -2018-11-04 12:54:14,070,1,WOOHO -2018-11-04 12:54:15,075,1,WOOHO -2018-11-04 12:54:16,079,1,WOOHO -2018-11-04 12:54:17,084,1,WOOHO -2018-11-04 12:54:18,087,1,WOOHO -2018-11-04 12:54:19,091,1,WOOHO -2018-11-04 12:54:20,094,1,WOOHO -2018-11-04 12:54:21,100,1,WOOHO -2018-11-04 12:54:22,105,1,WOOHO -2018-11-04 12:54:23,109,1,WOOHO -2018-11-04 12:54:24,111,1,WOOHO -2018-11-04 12:54:25,113,1,WOOHO -2018-11-04 12:54:26,117,1,WOOHO -2018-11-04 12:54:27,119,1,WOOHO -2018-11-04 12:54:28,124,1,WOOHO -2018-11-04 12:54:29,125,1,WOOHO -2018-11-04 12:54:30,131,1,WOOHO -2018-11-04 12:54:31,136,1,WOOHO -2018-11-04 12:54:32,140,1,WOOHO -2018-11-04 12:54:33,142,1,WOOHO -2018-11-04 12:54:34,144,1,WOOHO -2018-11-04 12:54:35,149,1,WOOHO -2018-11-04 12:54:36,153,1,WOOHO -2018-11-04 12:54:37,159,1,WOOHO -2018-11-04 12:54:38,164,1,WOOHO -2018-11-04 12:54:39,168,1,WOOHO -2018-11-04 12:54:40,172,1,WOOHO -2018-11-04 12:54:41,177,1,WOOHO -2018-11-04 12:54:42,182,1,WOOHO -2018-11-04 12:54:43,188,1,WOOHO -2018-11-04 12:54:44,194,1,WOOHO -2018-11-04 12:54:45,198,1,WOOHO -2018-11-04 12:55:12,657,1,WOOHO -2018-11-04 12:55:13,659,1,WOOHO -2018-11-04 12:55:14,662,1,WOOHO -2018-11-04 12:55:15,668,1,WOOHO -2018-11-04 12:55:16,672,1,WOOHO -2018-11-04 12:55:17,678,1,WOOHO diff --git a/logs/first_logfile2.log.2018-11-04_01-02 b/logs/first_logfile2.log.2018-11-04_01-02 deleted file mode 100644 index 6f96ab1..0000000 --- a/logs/first_logfile2.log.2018-11-04_01-02 +++ /dev/null @@ -1,90 +0,0 @@ -2018-11-04 01:01:28,031,1,WOOHO -2018-11-04 01:01:29,034,1,WOOHO -2018-11-04 01:01:30,038,1,WOOHO -2018-11-04 01:01:31,043,1,WOOHO -2018-11-04 01:01:32,050,1,WOOHO -2018-11-04 01:01:33,054,1,WOOHO -2018-11-04 01:01:34,057,1,WOOHO -2018-11-04 01:01:35,062,1,WOOHO -2018-11-04 01:01:36,065,1,WOOHO -2018-11-04 01:01:37,068,1,WOOHO -2018-11-04 01:01:38,071,1,WOOHO -2018-11-04 01:01:39,075,1,WOOHO -2018-11-04 01:01:40,080,1,WOOHO -2018-11-04 01:01:41,082,1,WOOHO -2018-11-04 01:01:42,086,1,WOOHO -2018-11-04 01:01:43,091,1,WOOHO -2018-11-04 01:01:44,095,1,WOOHO -2018-11-04 01:01:45,097,1,WOOHO -2018-11-04 01:01:46,101,1,WOOHO -2018-11-04 01:01:47,106,1,WOOHO -2018-11-04 01:01:48,112,1,WOOHO -2018-11-04 01:01:49,114,1,WOOHO -2018-11-04 01:01:50,119,1,WOOHO -2018-11-04 01:01:51,124,1,WOOHO -2018-11-04 01:01:52,132,1,WOOHO -2018-11-04 01:01:53,136,1,WOOHO -2018-11-04 01:01:54,139,1,WOOHO -2018-11-04 01:01:55,143,1,WOOHO -2018-11-04 01:01:56,146,1,WOOHO -2018-11-04 01:01:57,152,1,WOOHO -2018-11-04 01:01:58,156,1,WOOHO -2018-11-04 01:01:59,161,1,WOOHO -2018-11-04 01:02:00,165,1,WOOHO -2018-11-04 01:02:01,171,1,WOOHO -2018-11-04 01:02:02,172,1,WOOHO -2018-11-04 01:02:03,176,1,WOOHO -2018-11-04 01:02:04,182,1,WOOHO -2018-11-04 01:02:05,188,1,WOOHO -2018-11-04 01:02:06,189,1,WOOHO -2018-11-04 01:02:07,190,1,WOOHO -2018-11-04 01:02:08,196,1,WOOHO -2018-11-04 01:02:09,204,1,WOOHO -2018-11-04 01:02:10,207,1,WOOHO -2018-11-04 01:02:11,211,1,WOOHO -2018-11-04 01:02:12,214,1,WOOHO -2018-11-04 01:02:13,220,1,WOOHO -2018-11-04 01:02:14,225,1,WOOHO -2018-11-04 01:02:15,232,1,WOOHO -2018-11-04 01:02:16,236,1,WOOHO -2018-11-04 01:02:17,242,1,WOOHO -2018-11-04 01:02:18,246,1,WOOHO -2018-11-04 01:02:19,250,1,WOOHO -2018-11-04 01:02:20,256,1,WOOHO -2018-11-04 01:02:21,260,1,WOOHO -2018-11-04 01:02:24,816,1,WOOHO -2018-11-04 01:02:25,821,1,WOOHO -2018-11-04 01:02:26,827,1,WOOHO -2018-11-04 01:02:27,830,1,WOOHO -2018-11-04 01:02:28,833,1,WOOHO -2018-11-04 01:02:29,838,1,WOOHO -2018-11-04 01:02:30,842,1,WOOHO -2018-11-04 01:02:31,845,1,WOOHO -2018-11-04 01:02:32,851,1,WOOHO -2018-11-04 01:02:33,855,1,WOOHO -2018-11-04 01:02:34,859,1,WOOHO -2018-11-04 01:02:35,862,1,WOOHO -2018-11-04 01:02:36,865,1,WOOHO -2018-11-04 01:02:37,871,1,WOOHO -2018-11-04 01:02:38,878,1,WOOHO -2018-11-04 01:02:39,878,1,WOOHO -2018-11-04 01:02:40,881,1,WOOHO -2018-11-04 01:02:41,883,1,WOOHO -2018-11-04 01:02:42,888,1,WOOHO -2018-11-04 01:02:43,892,1,WOOHO -2018-11-04 01:02:44,896,1,WOOHO -2018-11-04 01:02:45,900,1,WOOHO -2018-11-04 01:02:46,906,1,WOOHO -2018-11-04 01:02:47,912,1,WOOHO -2018-11-04 01:02:48,915,1,WOOHO -2018-11-04 01:02:49,920,1,WOOHO -2018-11-04 01:02:50,924,1,WOOHO -2018-11-04 01:02:51,931,1,WOOHO -2018-11-04 01:02:52,936,1,WOOHO -2018-11-04 01:02:53,941,1,WOOHO -2018-11-04 01:02:54,946,1,WOOHO -2018-11-04 01:02:55,950,1,WOOHO -2018-11-04 01:02:56,956,1,WOOHO -2018-11-04 01:02:57,960,1,WOOHO -2018-11-04 01:02:58,964,1,WOOHO -2018-11-04 01:02:59,966,1,WOOHO diff --git a/logs/first_logfile2.log.2018-11-04_01-08 b/logs/first_logfile2.log.2018-11-04_01-08 deleted file mode 100644 index 1d12553..0000000 --- a/logs/first_logfile2.log.2018-11-04_01-08 +++ /dev/null @@ -1,18 +0,0 @@ -2018-11-04 01:08:19,659,1,WOOHO -2018-11-04 01:08:20,668,1,WOOHO -2018-11-04 01:08:21,673,1,WOOHO -2018-11-04 01:08:22,681,1,WOOHO -2018-11-04 01:08:23,684,1,WOOHO -2018-11-04 01:08:24,689,1,WOOHO -2018-11-04 01:08:25,693,1,WOOHO -2018-11-04 01:08:26,694,1,WOOHO -2018-11-04 01:08:27,699,1,WOOHO -2018-11-04 01:08:28,704,1,WOOHO -2018-11-04 01:08:29,708,1,WOOHO -2018-11-04 01:08:30,712,1,WOOHO -2018-11-04 01:08:31,718,1,WOOHO -2018-11-04 01:08:32,723,1,WOOHO -2018-11-04 01:08:36,712,1,WOOHO -2018-11-04 01:08:37,716,1,WOOHO -2018-11-04 01:08:38,721,1,WOOHO -2018-11-04 01:08:39,726,1,WOOHO diff --git a/logs/first_logfile2.log.2018-11-04_01-10 b/logs/first_logfile2.log.2018-11-04_01-10 deleted file mode 100644 index 248fe56..0000000 --- a/logs/first_logfile2.log.2018-11-04_01-10 +++ /dev/null @@ -1,13 +0,0 @@ -2018-11-04 01:10:29,274,1,WOOHO -2018-11-04 01:10:30,280,1,WOOHO -2018-11-04 01:10:31,282,1,WOOHO -2018-11-04 01:10:32,286,1,WOOHO -2018-11-04 01:10:33,288,1,WOOHO -2018-11-04 01:10:34,294,1,WOOHO -2018-11-04 01:10:35,299,1,WOOHO -2018-11-04 01:10:36,301,1,WOOHO -2018-11-04 01:10:37,306,1,WOOHO -2018-11-04 01:10:38,311,1,WOOHO -2018-11-04 01:10:39,316,1,WOOHO -2018-11-04 01:10:40,317,1,WOOHO -2018-11-04 01:10:41,319,1,WOOHO diff --git a/logs/first_logfile2.log.2018-11-04_12-43 b/logs/first_logfile2.log.2018-11-04_12-43 deleted file mode 100644 index 51a8ab6..0000000 --- a/logs/first_logfile2.log.2018-11-04_12-43 +++ /dev/null @@ -1,32 +0,0 @@ -2018-11-04 12:42:23,466,1,WOOHO -2018-11-04 12:42:24,473,1,WOOHO -2018-11-04 12:42:25,478,1,WOOHO -2018-11-04 12:42:58,803,1,WOOHO -2018-11-04 12:42:59,807,1,WOOHO -2018-11-04 12:43:00,811,1,WOOHO -2018-11-04 12:43:34,009,1,WOOHO -2018-11-04 12:43:35,013,1,WOOHO -2018-11-04 12:43:36,015,1,WOOHO -2018-11-04 12:43:37,018,1,WOOHO -2018-11-04 12:43:38,023,1,WOOHO -2018-11-04 12:43:39,024,1,WOOHO -2018-11-04 12:43:40,029,1,WOOHO -2018-11-04 12:43:41,035,1,WOOHO -2018-11-04 12:43:42,041,1,WOOHO -2018-11-04 12:43:43,046,1,WOOHO -2018-11-04 12:43:44,052,1,WOOHO -2018-11-04 12:43:45,058,1,WOOHO -2018-11-04 12:43:46,062,1,WOOHO -2018-11-04 12:43:47,065,1,WOOHO -2018-11-04 12:43:48,067,1,WOOHO -2018-11-04 12:43:49,073,1,WOOHO -2018-11-04 12:43:50,077,1,WOOHO -2018-11-04 12:43:51,080,1,WOOHO -2018-11-04 12:43:52,089,1,WOOHO -2018-11-04 12:43:53,093,1,WOOHO -2018-11-04 12:43:54,099,1,WOOHO -2018-11-04 12:43:55,103,1,WOOHO -2018-11-04 12:43:56,108,1,WOOHO -2018-11-04 12:43:57,113,1,WOOHO -2018-11-04 12:43:58,116,1,WOOHO -2018-11-04 12:43:59,120,1,WOOHO diff --git a/logs/first_logfile2.log.2018-11-04_12-44 b/logs/first_logfile2.log.2018-11-04_12-44 deleted file mode 100644 index 9bc22e4..0000000 --- a/logs/first_logfile2.log.2018-11-04_12-44 +++ /dev/null @@ -1,16 +0,0 @@ -2018-11-04 12:44:00,127,1,WOOHO -2018-11-04 12:44:01,137,1,WOOHO -2018-11-04 12:44:02,142,1,WOOHO -2018-11-04 12:44:03,144,1,WOOHO -2018-11-04 12:44:04,145,1,WOOHO -2018-11-04 12:44:05,151,1,WOOHO -2018-11-04 12:44:06,156,1,WOOHO -2018-11-04 12:44:07,161,1,WOOHO -2018-11-04 12:44:08,165,1,WOOHO -2018-11-04 12:44:12,379,1,WOOHO -2018-11-04 12:44:13,384,1,WOOHO -2018-11-04 12:44:14,390,1,WOOHO -2018-11-04 12:44:15,395,1,WOOHO -2018-11-04 12:44:43,461,1,WOOHO -2018-11-04 12:44:44,465,1,WOOHO -2018-11-04 12:44:45,467,1,WOOHO diff --git a/logs/sensors/sensor_1.log b/logs/sensors/sensor_1.log new file mode 100644 index 0000000..b22ca2f --- /dev/null +++ b/logs/sensors/sensor_1.log @@ -0,0 +1,49 @@ +2019-01-02 00:44:06,10 +2019-01-02 00:44:11,10 +2019-01-02 00:44:16,10 +2019-01-02 00:44:21,10 +2019-01-02 00:44:26,10 +2019-01-02 00:44:31,10 +2019-01-02 00:44:36,10 +2019-01-02 00:44:41,10 +2019-01-02 00:44:46,10 +2019-01-02 00:44:51,10 +2019-01-02 00:44:56,10 +2019-01-02 00:45:01,10 +2019-01-02 00:45:06,10 +2019-01-02 00:45:11,10 +2019-01-02 00:45:16,10 +2019-01-02 00:45:21,10 +2019-01-02 00:45:26,10 +2019-01-02 00:45:31,10 +2019-01-02 00:45:36,10 +2019-01-02 00:45:41,10 +2019-01-02 00:45:46,10 +2019-01-02 00:45:51,10 +2019-01-02 00:45:56,10 +2019-01-02 00:46:01,10 +2019-01-02 00:46:06,10 +2019-01-02 00:46:11,10 +2019-01-02 00:46:16,10 +2019-01-02 00:46:21,10 +2019-01-02 00:46:26,10 +2019-01-02 00:46:31,10 +2019-01-02 00:46:36,10 +2019-01-02 00:46:41,10 +2019-01-02 00:46:46,10 +2019-01-02 00:46:51,10 +2019-01-02 00:46:56,10 +2019-01-02 00:47:01,10 +2019-01-02 00:47:06,10 +2019-01-02 00:47:11,10 +2019-01-02 00:47:16,10 +2019-01-02 00:47:21,10 +2019-01-02 00:47:26,10 +2019-01-02 00:47:31,10 +2019-01-02 00:47:36,10 +2019-01-02 00:47:41,10 +2019-01-02 00:47:46,10 +2019-01-02 00:47:51,10 +2019-01-02 00:47:56,10 +2019-01-02 00:48:01,10 +2019-01-02 00:48:06,10 diff --git a/logs/sensors/sensor_1.log.1 b/logs/sensors/sensor_1.log.1 new file mode 100644 index 0000000..707af1a --- /dev/null +++ b/logs/sensors/sensor_1.log.1 @@ -0,0 +1,86 @@ +2019-01-02 00:36:56,10 +2019-01-02 00:37:01,10 +2019-01-02 00:37:06,10 +2019-01-02 00:37:11,10 +2019-01-02 00:37:16,10 +2019-01-02 00:37:21,10 +2019-01-02 00:37:26,10 +2019-01-02 00:37:31,10 +2019-01-02 00:37:36,10 +2019-01-02 00:37:41,10 +2019-01-02 00:37:46,10 +2019-01-02 00:37:51,10 +2019-01-02 00:37:56,10 +2019-01-02 00:38:01,10 +2019-01-02 00:38:06,10 +2019-01-02 00:38:11,10 +2019-01-02 00:38:16,10 +2019-01-02 00:38:21,10 +2019-01-02 00:38:26,10 +2019-01-02 00:38:31,10 +2019-01-02 00:38:36,10 +2019-01-02 00:38:41,10 +2019-01-02 00:38:46,10 +2019-01-02 00:38:51,10 +2019-01-02 00:38:56,10 +2019-01-02 00:39:01,10 +2019-01-02 00:39:06,10 +2019-01-02 00:39:11,10 +2019-01-02 00:39:16,10 +2019-01-02 00:39:21,10 +2019-01-02 00:39:26,10 +2019-01-02 00:39:31,10 +2019-01-02 00:39:36,10 +2019-01-02 00:39:41,10 +2019-01-02 00:39:46,10 +2019-01-02 00:39:51,10 +2019-01-02 00:39:56,10 +2019-01-02 00:40:01,10 +2019-01-02 00:40:06,10 +2019-01-02 00:40:11,10 +2019-01-02 00:40:16,10 +2019-01-02 00:40:21,10 +2019-01-02 00:40:26,10 +2019-01-02 00:40:31,10 +2019-01-02 00:40:36,10 +2019-01-02 00:40:41,10 +2019-01-02 00:40:46,10 +2019-01-02 00:40:51,10 +2019-01-02 00:40:56,10 +2019-01-02 00:41:01,10 +2019-01-02 00:41:06,10 +2019-01-02 00:41:11,10 +2019-01-02 00:41:16,10 +2019-01-02 00:41:21,10 +2019-01-02 00:41:26,10 +2019-01-02 00:41:31,10 +2019-01-02 00:41:36,10 +2019-01-02 00:41:41,10 +2019-01-02 00:41:46,10 +2019-01-02 00:41:51,10 +2019-01-02 00:41:56,10 +2019-01-02 00:42:01,10 +2019-01-02 00:42:06,10 +2019-01-02 00:42:11,10 +2019-01-02 00:42:16,10 +2019-01-02 00:42:21,10 +2019-01-02 00:42:26,10 +2019-01-02 00:42:31,10 +2019-01-02 00:42:36,10 +2019-01-02 00:42:41,10 +2019-01-02 00:42:46,10 +2019-01-02 00:42:51,10 +2019-01-02 00:42:56,10 +2019-01-02 00:43:01,10 +2019-01-02 00:43:06,10 +2019-01-02 00:43:11,10 +2019-01-02 00:43:16,10 +2019-01-02 00:43:21,10 +2019-01-02 00:43:26,10 +2019-01-02 00:43:31,10 +2019-01-02 00:43:36,10 +2019-01-02 00:43:41,10 +2019-01-02 00:43:46,10 +2019-01-02 00:43:51,10 +2019-01-02 00:43:56,10 +2019-01-02 00:44:01,10 diff --git a/logs/sensors/sensor_1.log.10 b/logs/sensors/sensor_1.log.10 new file mode 100644 index 0000000..13151a8 --- /dev/null +++ b/logs/sensors/sensor_1.log.10 @@ -0,0 +1,86 @@ +2019-01-01 23:05:37,10 +2019-01-01 23:19:02,10 +2019-01-01 23:19:07,10 +2019-01-01 23:19:12,10 +2019-01-01 23:19:17,10 +2019-01-01 23:19:22,10 +2019-01-01 23:19:27,10 +2019-01-01 23:19:32,10 +2019-01-01 23:19:37,10 +2019-01-01 23:19:42,10 +2019-01-01 23:19:47,10 +2019-01-01 23:19:52,10 +2019-01-01 23:19:57,10 +2019-01-01 23:20:02,10 +2019-01-01 23:20:07,10 +2019-01-01 23:20:12,10 +2019-01-01 23:21:07,10 +2019-01-01 23:21:12,10 +2019-01-01 23:21:17,10 +2019-01-01 23:21:22,10 +2019-01-01 23:21:27,10 +2019-01-01 23:21:32,10 +2019-01-01 23:21:37,10 +2019-01-01 23:21:42,10 +2019-01-01 23:21:47,10 +2019-01-01 23:21:52,10 +2019-01-01 23:21:57,10 +2019-01-01 23:22:02,10 +2019-01-01 23:22:07,10 +2019-01-01 23:22:12,10 +2019-01-01 23:22:17,10 +2019-01-01 23:22:22,10 +2019-01-01 23:22:27,10 +2019-01-01 23:22:32,10 +2019-01-01 23:22:37,10 +2019-01-01 23:22:42,10 +2019-01-01 23:22:47,10 +2019-01-01 23:22:52,10 +2019-01-01 23:22:57,10 +2019-01-01 23:23:02,10 +2019-01-01 23:23:10,10 +2019-01-01 23:23:15,10 +2019-01-01 23:23:20,10 +2019-01-01 23:23:25,10 +2019-01-01 23:23:30,10 +2019-01-01 23:23:35,10 +2019-01-01 23:23:40,10 +2019-01-01 23:23:45,10 +2019-01-01 23:23:50,10 +2019-01-01 23:23:55,10 +2019-01-01 23:24:00,10 +2019-01-01 23:24:05,10 +2019-01-01 23:24:10,10 +2019-01-01 23:24:15,10 +2019-01-01 23:24:20,10 +2019-01-01 23:24:25,10 +2019-01-01 23:24:30,10 +2019-01-01 23:24:35,10 +2019-01-01 23:24:40,10 +2019-01-01 23:24:45,10 +2019-01-01 23:24:50,10 +2019-01-01 23:24:55,10 +2019-01-01 23:25:00,10 +2019-01-01 23:25:05,10 +2019-01-01 23:25:10,10 +2019-01-01 23:25:15,10 +2019-01-01 23:25:20,10 +2019-01-01 23:25:25,10 +2019-01-01 23:25:30,10 +2019-01-01 23:25:42,10 +2019-01-01 23:25:47,10 +2019-01-01 23:25:52,10 +2019-01-01 23:25:57,10 +2019-01-01 23:26:02,10 +2019-01-01 23:26:07,10 +2019-01-01 23:26:12,10 +2019-01-01 23:26:17,10 +2019-01-01 23:26:22,10 +2019-01-01 23:26:27,10 +2019-01-01 23:26:32,10 +2019-01-01 23:26:37,10 +2019-01-01 23:26:42,10 +2019-01-01 23:26:47,10 +2019-01-01 23:26:52,10 +2019-01-01 23:26:57,10 +2019-01-01 23:27:02,10 diff --git a/logs/sensors/sensor_1.log.2 b/logs/sensors/sensor_1.log.2 new file mode 100644 index 0000000..82bcd50 --- /dev/null +++ b/logs/sensors/sensor_1.log.2 @@ -0,0 +1,86 @@ +2019-01-02 00:29:45,10 +2019-01-02 00:29:50,10 +2019-01-02 00:29:55,10 +2019-01-02 00:30:00,10 +2019-01-02 00:30:05,10 +2019-01-02 00:30:10,10 +2019-01-02 00:30:15,10 +2019-01-02 00:30:20,10 +2019-01-02 00:30:25,10 +2019-01-02 00:30:30,10 +2019-01-02 00:30:35,10 +2019-01-02 00:30:40,10 +2019-01-02 00:30:45,10 +2019-01-02 00:30:50,10 +2019-01-02 00:30:55,10 +2019-01-02 00:31:00,10 +2019-01-02 00:31:05,10 +2019-01-02 00:31:10,10 +2019-01-02 00:31:15,10 +2019-01-02 00:31:20,10 +2019-01-02 00:31:25,10 +2019-01-02 00:31:30,10 +2019-01-02 00:31:35,10 +2019-01-02 00:31:40,10 +2019-01-02 00:31:45,10 +2019-01-02 00:31:50,10 +2019-01-02 00:31:55,10 +2019-01-02 00:32:00,10 +2019-01-02 00:32:05,10 +2019-01-02 00:32:10,10 +2019-01-02 00:32:15,10 +2019-01-02 00:32:20,10 +2019-01-02 00:32:25,10 +2019-01-02 00:32:30,10 +2019-01-02 00:32:35,10 +2019-01-02 00:32:40,10 +2019-01-02 00:32:45,10 +2019-01-02 00:32:51,10 +2019-01-02 00:32:56,10 +2019-01-02 00:33:01,10 +2019-01-02 00:33:06,10 +2019-01-02 00:33:11,10 +2019-01-02 00:33:16,10 +2019-01-02 00:33:21,10 +2019-01-02 00:33:26,10 +2019-01-02 00:33:31,10 +2019-01-02 00:33:36,10 +2019-01-02 00:33:41,10 +2019-01-02 00:33:46,10 +2019-01-02 00:33:51,10 +2019-01-02 00:33:56,10 +2019-01-02 00:34:01,10 +2019-01-02 00:34:06,10 +2019-01-02 00:34:11,10 +2019-01-02 00:34:16,10 +2019-01-02 00:34:21,10 +2019-01-02 00:34:26,10 +2019-01-02 00:34:31,10 +2019-01-02 00:34:36,10 +2019-01-02 00:34:41,10 +2019-01-02 00:34:46,10 +2019-01-02 00:34:51,10 +2019-01-02 00:34:56,10 +2019-01-02 00:35:01,10 +2019-01-02 00:35:06,10 +2019-01-02 00:35:11,10 +2019-01-02 00:35:16,10 +2019-01-02 00:35:21,10 +2019-01-02 00:35:26,10 +2019-01-02 00:35:31,10 +2019-01-02 00:35:36,10 +2019-01-02 00:35:41,10 +2019-01-02 00:35:46,10 +2019-01-02 00:35:51,10 +2019-01-02 00:35:56,10 +2019-01-02 00:36:01,10 +2019-01-02 00:36:06,10 +2019-01-02 00:36:11,10 +2019-01-02 00:36:16,10 +2019-01-02 00:36:21,10 +2019-01-02 00:36:26,10 +2019-01-02 00:36:31,10 +2019-01-02 00:36:36,10 +2019-01-02 00:36:41,10 +2019-01-02 00:36:46,10 +2019-01-02 00:36:51,10 diff --git a/logs/sensors/sensor_1.log.3 b/logs/sensors/sensor_1.log.3 new file mode 100644 index 0000000..5650f2a --- /dev/null +++ b/logs/sensors/sensor_1.log.3 @@ -0,0 +1,86 @@ +2019-01-02 00:22:01,10 +2019-01-02 00:22:06,10 +2019-01-02 00:22:11,10 +2019-01-02 00:22:16,10 +2019-01-02 00:22:21,10 +2019-01-02 00:22:26,10 +2019-01-02 00:22:31,10 +2019-01-02 00:22:36,10 +2019-01-02 00:22:41,10 +2019-01-02 00:22:46,10 +2019-01-02 00:22:51,10 +2019-01-02 00:23:30,10 +2019-01-02 00:23:35,10 +2019-01-02 00:23:40,10 +2019-01-02 00:23:45,10 +2019-01-02 00:23:50,10 +2019-01-02 00:23:55,10 +2019-01-02 00:24:00,10 +2019-01-02 00:24:05,10 +2019-01-02 00:24:10,10 +2019-01-02 00:24:15,10 +2019-01-02 00:24:20,10 +2019-01-02 00:24:25,10 +2019-01-02 00:24:30,10 +2019-01-02 00:24:35,10 +2019-01-02 00:24:40,10 +2019-01-02 00:24:45,10 +2019-01-02 00:24:50,10 +2019-01-02 00:24:55,10 +2019-01-02 00:25:00,10 +2019-01-02 00:25:05,10 +2019-01-02 00:25:10,10 +2019-01-02 00:25:15,10 +2019-01-02 00:25:20,10 +2019-01-02 00:25:25,10 +2019-01-02 00:25:30,10 +2019-01-02 00:25:35,10 +2019-01-02 00:25:40,10 +2019-01-02 00:25:45,10 +2019-01-02 00:25:50,10 +2019-01-02 00:25:55,10 +2019-01-02 00:26:00,10 +2019-01-02 00:26:05,10 +2019-01-02 00:26:10,10 +2019-01-02 00:26:15,10 +2019-01-02 00:26:20,10 +2019-01-02 00:26:25,10 +2019-01-02 00:26:30,10 +2019-01-02 00:26:35,10 +2019-01-02 00:26:40,10 +2019-01-02 00:26:45,10 +2019-01-02 00:26:50,10 +2019-01-02 00:26:55,10 +2019-01-02 00:27:00,10 +2019-01-02 00:27:05,10 +2019-01-02 00:27:10,10 +2019-01-02 00:27:15,10 +2019-01-02 00:27:20,10 +2019-01-02 00:27:25,10 +2019-01-02 00:27:30,10 +2019-01-02 00:27:35,10 +2019-01-02 00:27:40,10 +2019-01-02 00:27:45,10 +2019-01-02 00:27:50,10 +2019-01-02 00:27:55,10 +2019-01-02 00:28:00,10 +2019-01-02 00:28:05,10 +2019-01-02 00:28:10,10 +2019-01-02 00:28:15,10 +2019-01-02 00:28:20,10 +2019-01-02 00:28:25,10 +2019-01-02 00:28:30,10 +2019-01-02 00:28:35,10 +2019-01-02 00:28:40,10 +2019-01-02 00:28:45,10 +2019-01-02 00:28:50,10 +2019-01-02 00:28:55,10 +2019-01-02 00:29:00,10 +2019-01-02 00:29:05,10 +2019-01-02 00:29:10,10 +2019-01-02 00:29:15,10 +2019-01-02 00:29:20,10 +2019-01-02 00:29:25,10 +2019-01-02 00:29:30,10 +2019-01-02 00:29:35,10 +2019-01-02 00:29:40,10 diff --git a/logs/sensors/sensor_1.log.4 b/logs/sensors/sensor_1.log.4 new file mode 100644 index 0000000..fd9d830 --- /dev/null +++ b/logs/sensors/sensor_1.log.4 @@ -0,0 +1,86 @@ +2019-01-02 00:14:36,10 +2019-01-02 00:14:41,10 +2019-01-02 00:14:46,10 +2019-01-02 00:14:51,10 +2019-01-02 00:14:56,10 +2019-01-02 00:15:01,10 +2019-01-02 00:15:06,10 +2019-01-02 00:15:11,10 +2019-01-02 00:15:16,10 +2019-01-02 00:15:21,10 +2019-01-02 00:15:26,10 +2019-01-02 00:15:31,10 +2019-01-02 00:15:36,10 +2019-01-02 00:15:41,10 +2019-01-02 00:15:46,10 +2019-01-02 00:15:51,10 +2019-01-02 00:15:56,10 +2019-01-02 00:16:01,10 +2019-01-02 00:16:06,10 +2019-01-02 00:16:11,10 +2019-01-02 00:16:16,10 +2019-01-02 00:16:21,10 +2019-01-02 00:16:26,10 +2019-01-02 00:16:31,10 +2019-01-02 00:16:36,10 +2019-01-02 00:16:41,10 +2019-01-02 00:16:46,10 +2019-01-02 00:16:51,10 +2019-01-02 00:16:56,10 +2019-01-02 00:17:04,10 +2019-01-02 00:17:09,10 +2019-01-02 00:17:14,10 +2019-01-02 00:17:19,10 +2019-01-02 00:17:24,10 +2019-01-02 00:17:29,10 +2019-01-02 00:17:34,10 +2019-01-02 00:17:45,10 +2019-01-02 00:17:50,10 +2019-01-02 00:17:55,10 +2019-01-02 00:18:00,10 +2019-01-02 00:18:05,10 +2019-01-02 00:18:10,10 +2019-01-02 00:18:15,10 +2019-01-02 00:18:20,10 +2019-01-02 00:18:25,10 +2019-01-02 00:18:30,10 +2019-01-02 00:18:35,10 +2019-01-02 00:18:40,10 +2019-01-02 00:18:45,10 +2019-01-02 00:18:50,10 +2019-01-02 00:18:55,10 +2019-01-02 00:19:00,10 +2019-01-02 00:19:05,10 +2019-01-02 00:19:10,10 +2019-01-02 00:19:15,10 +2019-01-02 00:19:20,10 +2019-01-02 00:19:25,10 +2019-01-02 00:19:30,10 +2019-01-02 00:19:35,10 +2019-01-02 00:19:40,10 +2019-01-02 00:19:51,10 +2019-01-02 00:19:56,10 +2019-01-02 00:20:01,10 +2019-01-02 00:20:06,10 +2019-01-02 00:20:11,10 +2019-01-02 00:20:16,10 +2019-01-02 00:20:21,10 +2019-01-02 00:20:26,10 +2019-01-02 00:20:31,10 +2019-01-02 00:20:36,10 +2019-01-02 00:20:41,10 +2019-01-02 00:20:46,10 +2019-01-02 00:20:51,10 +2019-01-02 00:20:56,10 +2019-01-02 00:21:01,10 +2019-01-02 00:21:06,10 +2019-01-02 00:21:11,10 +2019-01-02 00:21:16,10 +2019-01-02 00:21:21,10 +2019-01-02 00:21:26,10 +2019-01-02 00:21:31,10 +2019-01-02 00:21:36,10 +2019-01-02 00:21:41,10 +2019-01-02 00:21:46,10 +2019-01-02 00:21:51,10 +2019-01-02 00:21:56,10 diff --git a/logs/sensors/sensor_1.log.5 b/logs/sensors/sensor_1.log.5 new file mode 100644 index 0000000..3a61e86 --- /dev/null +++ b/logs/sensors/sensor_1.log.5 @@ -0,0 +1,86 @@ +2019-01-02 00:07:03,10 +2019-01-02 00:07:08,10 +2019-01-02 00:07:13,10 +2019-01-02 00:07:18,10 +2019-01-02 00:07:23,10 +2019-01-02 00:07:28,10 +2019-01-02 00:07:33,10 +2019-01-02 00:07:38,10 +2019-01-02 00:07:43,10 +2019-01-02 00:07:48,10 +2019-01-02 00:07:53,10 +2019-01-02 00:07:58,10 +2019-01-02 00:08:03,10 +2019-01-02 00:08:08,10 +2019-01-02 00:08:13,10 +2019-01-02 00:08:18,10 +2019-01-02 00:08:23,10 +2019-01-02 00:08:28,10 +2019-01-02 00:08:33,10 +2019-01-02 00:08:38,10 +2019-01-02 00:08:43,10 +2019-01-02 00:08:48,10 +2019-01-02 00:08:53,10 +2019-01-02 00:08:58,10 +2019-01-02 00:09:03,10 +2019-01-02 00:09:08,10 +2019-01-02 00:09:13,10 +2019-01-02 00:09:18,10 +2019-01-02 00:09:23,10 +2019-01-02 00:09:28,10 +2019-01-02 00:09:33,10 +2019-01-02 00:09:38,10 +2019-01-02 00:09:43,10 +2019-01-02 00:09:48,10 +2019-01-02 00:09:53,10 +2019-01-02 00:09:58,10 +2019-01-02 00:10:03,10 +2019-01-02 00:10:08,10 +2019-01-02 00:10:13,10 +2019-01-02 00:10:18,10 +2019-01-02 00:10:23,10 +2019-01-02 00:10:28,10 +2019-01-02 00:10:33,10 +2019-01-02 00:10:38,10 +2019-01-02 00:10:43,10 +2019-01-02 00:10:48,10 +2019-01-02 00:10:53,10 +2019-01-02 00:10:58,10 +2019-01-02 00:11:03,10 +2019-01-02 00:11:08,10 +2019-01-02 00:11:13,10 +2019-01-02 00:11:18,10 +2019-01-02 00:11:23,10 +2019-01-02 00:11:28,10 +2019-01-02 00:11:33,10 +2019-01-02 00:11:38,10 +2019-01-02 00:11:43,10 +2019-01-02 00:11:48,10 +2019-01-02 00:11:53,10 +2019-01-02 00:11:58,10 +2019-01-02 00:12:03,10 +2019-01-02 00:12:08,10 +2019-01-02 00:12:13,10 +2019-01-02 00:12:18,10 +2019-01-02 00:12:23,10 +2019-01-02 00:12:28,10 +2019-01-02 00:12:33,10 +2019-01-02 00:12:38,10 +2019-01-02 00:12:43,10 +2019-01-02 00:12:48,10 +2019-01-02 00:12:53,10 +2019-01-02 00:12:58,10 +2019-01-02 00:13:03,10 +2019-01-02 00:13:08,10 +2019-01-02 00:13:13,10 +2019-01-02 00:13:18,10 +2019-01-02 00:13:23,10 +2019-01-02 00:13:28,10 +2019-01-02 00:13:33,10 +2019-01-02 00:13:38,10 +2019-01-02 00:13:43,10 +2019-01-02 00:13:48,10 +2019-01-02 00:13:53,10 +2019-01-02 00:14:19,10 +2019-01-02 00:14:24,10 +2019-01-02 00:14:31,10 diff --git a/logs/sensors/sensor_1.log.6 b/logs/sensors/sensor_1.log.6 new file mode 100644 index 0000000..eaf0f6f --- /dev/null +++ b/logs/sensors/sensor_1.log.6 @@ -0,0 +1,86 @@ +2019-01-01 23:59:47,10 +2019-01-01 23:59:52,10 +2019-01-01 23:59:57,10 +2019-01-02 00:00:02,10 +2019-01-02 00:00:07,10 +2019-01-02 00:00:12,10 +2019-01-02 00:00:17,10 +2019-01-02 00:00:22,10 +2019-01-02 00:00:27,10 +2019-01-02 00:00:32,10 +2019-01-02 00:00:37,10 +2019-01-02 00:00:42,10 +2019-01-02 00:00:47,10 +2019-01-02 00:00:52,10 +2019-01-02 00:00:57,10 +2019-01-02 00:01:02,10 +2019-01-02 00:01:07,10 +2019-01-02 00:01:12,10 +2019-01-02 00:01:17,10 +2019-01-02 00:01:28,10 +2019-01-02 00:01:33,10 +2019-01-02 00:01:38,10 +2019-01-02 00:01:43,10 +2019-01-02 00:01:48,10 +2019-01-02 00:01:53,10 +2019-01-02 00:01:58,10 +2019-01-02 00:02:03,10 +2019-01-02 00:02:08,10 +2019-01-02 00:02:13,10 +2019-01-02 00:02:18,10 +2019-01-02 00:02:23,10 +2019-01-02 00:02:28,10 +2019-01-02 00:02:33,10 +2019-01-02 00:02:38,10 +2019-01-02 00:02:43,10 +2019-01-02 00:02:48,10 +2019-01-02 00:02:53,10 +2019-01-02 00:02:58,10 +2019-01-02 00:03:03,10 +2019-01-02 00:03:08,10 +2019-01-02 00:03:13,10 +2019-01-02 00:03:18,10 +2019-01-02 00:03:23,10 +2019-01-02 00:03:28,10 +2019-01-02 00:03:33,10 +2019-01-02 00:03:38,10 +2019-01-02 00:03:43,10 +2019-01-02 00:03:48,10 +2019-01-02 00:03:53,10 +2019-01-02 00:03:58,10 +2019-01-02 00:04:03,10 +2019-01-02 00:04:08,10 +2019-01-02 00:04:13,10 +2019-01-02 00:04:18,10 +2019-01-02 00:04:23,10 +2019-01-02 00:04:28,10 +2019-01-02 00:04:33,10 +2019-01-02 00:04:38,10 +2019-01-02 00:04:43,10 +2019-01-02 00:04:48,10 +2019-01-02 00:04:53,10 +2019-01-02 00:04:58,10 +2019-01-02 00:05:03,10 +2019-01-02 00:05:08,10 +2019-01-02 00:05:13,10 +2019-01-02 00:05:18,10 +2019-01-02 00:05:23,10 +2019-01-02 00:05:28,10 +2019-01-02 00:05:33,10 +2019-01-02 00:05:38,10 +2019-01-02 00:05:43,10 +2019-01-02 00:05:48,10 +2019-01-02 00:05:53,10 +2019-01-02 00:05:58,10 +2019-01-02 00:06:03,10 +2019-01-02 00:06:08,10 +2019-01-02 00:06:13,10 +2019-01-02 00:06:18,10 +2019-01-02 00:06:23,10 +2019-01-02 00:06:28,10 +2019-01-02 00:06:33,10 +2019-01-02 00:06:38,10 +2019-01-02 00:06:43,10 +2019-01-02 00:06:48,10 +2019-01-02 00:06:53,10 +2019-01-02 00:06:58,10 diff --git a/logs/sensors/sensor_1.log.7 b/logs/sensors/sensor_1.log.7 new file mode 100644 index 0000000..bc7d68c --- /dev/null +++ b/logs/sensors/sensor_1.log.7 @@ -0,0 +1,86 @@ +2019-01-01 23:50:48,10 +2019-01-01 23:50:53,10 +2019-01-01 23:51:03,10 +2019-01-01 23:51:08,10 +2019-01-01 23:51:13,10 +2019-01-01 23:51:18,10 +2019-01-01 23:51:23,10 +2019-01-01 23:51:28,10 +2019-01-01 23:51:33,10 +2019-01-01 23:51:38,10 +2019-01-01 23:51:49,10 +2019-01-01 23:51:54,10 +2019-01-01 23:51:59,10 +2019-01-01 23:52:04,10 +2019-01-01 23:52:09,10 +2019-01-01 23:52:14,10 +2019-01-01 23:52:19,10 +2019-01-01 23:52:24,10 +2019-01-01 23:52:29,10 +2019-01-01 23:52:34,10 +2019-01-01 23:52:39,10 +2019-01-01 23:52:44,10 +2019-01-01 23:52:49,10 +2019-01-01 23:52:54,10 +2019-01-01 23:52:59,10 +2019-01-01 23:53:04,10 +2019-01-01 23:53:09,10 +2019-01-01 23:53:14,10 +2019-01-01 23:53:19,10 +2019-01-01 23:53:24,10 +2019-01-01 23:53:29,10 +2019-01-01 23:53:34,10 +2019-01-01 23:53:39,10 +2019-01-01 23:53:44,10 +2019-01-01 23:53:49,10 +2019-01-01 23:53:54,10 +2019-01-01 23:53:59,10 +2019-01-01 23:54:04,10 +2019-01-01 23:54:09,10 +2019-01-01 23:54:14,10 +2019-01-01 23:54:19,10 +2019-01-01 23:54:24,10 +2019-01-01 23:54:34,10 +2019-01-01 23:54:39,10 +2019-01-01 23:54:44,10 +2019-01-01 23:54:49,10 +2019-01-01 23:54:54,10 +2019-01-01 23:54:59,10 +2019-01-01 23:56:32,10 +2019-01-01 23:56:37,10 +2019-01-01 23:56:42,10 +2019-01-01 23:56:47,10 +2019-01-01 23:56:52,10 +2019-01-01 23:56:57,10 +2019-01-01 23:57:02,10 +2019-01-01 23:57:07,10 +2019-01-01 23:57:12,10 +2019-01-01 23:57:17,10 +2019-01-01 23:57:22,10 +2019-01-01 23:57:27,10 +2019-01-01 23:57:32,10 +2019-01-01 23:57:37,10 +2019-01-01 23:57:42,10 +2019-01-01 23:57:47,10 +2019-01-01 23:57:53,10 +2019-01-01 23:57:58,10 +2019-01-01 23:58:03,10 +2019-01-01 23:58:12,10 +2019-01-01 23:58:17,10 +2019-01-01 23:58:22,10 +2019-01-01 23:58:27,10 +2019-01-01 23:58:32,10 +2019-01-01 23:58:37,10 +2019-01-01 23:58:42,10 +2019-01-01 23:58:47,10 +2019-01-01 23:58:52,10 +2019-01-01 23:58:57,10 +2019-01-01 23:59:02,10 +2019-01-01 23:59:07,10 +2019-01-01 23:59:12,10 +2019-01-01 23:59:17,10 +2019-01-01 23:59:22,10 +2019-01-01 23:59:27,10 +2019-01-01 23:59:32,10 +2019-01-01 23:59:37,10 +2019-01-01 23:59:42,10 diff --git a/logs/sensors/sensor_1.log.8 b/logs/sensors/sensor_1.log.8 new file mode 100644 index 0000000..f273da5 --- /dev/null +++ b/logs/sensors/sensor_1.log.8 @@ -0,0 +1,86 @@ +2019-01-01 23:43:05,10 +2019-01-01 23:43:10,10 +2019-01-01 23:43:15,10 +2019-01-01 23:43:20,10 +2019-01-01 23:43:25,10 +2019-01-01 23:43:30,10 +2019-01-01 23:43:35,10 +2019-01-01 23:43:40,10 +2019-01-01 23:43:45,10 +2019-01-01 23:43:50,10 +2019-01-01 23:43:55,10 +2019-01-01 23:44:02,10 +2019-01-01 23:44:07,10 +2019-01-01 23:44:12,10 +2019-01-01 23:44:17,10 +2019-01-01 23:44:22,10 +2019-01-01 23:44:27,10 +2019-01-01 23:44:32,10 +2019-01-01 23:44:37,10 +2019-01-01 23:44:42,10 +2019-01-01 23:44:47,10 +2019-01-01 23:44:52,10 +2019-01-01 23:44:57,10 +2019-01-01 23:45:02,10 +2019-01-01 23:45:11,10 +2019-01-01 23:45:16,10 +2019-01-01 23:45:21,10 +2019-01-01 23:45:26,10 +2019-01-01 23:45:31,10 +2019-01-01 23:45:36,10 +2019-01-01 23:45:41,10 +2019-01-01 23:45:46,10 +2019-01-01 23:45:51,10 +2019-01-01 23:45:56,10 +2019-01-01 23:46:01,10 +2019-01-01 23:46:06,10 +2019-01-01 23:46:11,10 +2019-01-01 23:46:16,10 +2019-01-01 23:46:21,10 +2019-01-01 23:46:26,10 +2019-01-01 23:46:31,10 +2019-01-01 23:46:36,10 +2019-01-01 23:46:41,10 +2019-01-01 23:46:46,10 +2019-01-01 23:46:51,10 +2019-01-01 23:46:56,10 +2019-01-01 23:47:01,10 +2019-01-01 23:47:06,10 +2019-01-01 23:47:11,10 +2019-01-01 23:47:16,10 +2019-01-01 23:47:21,10 +2019-01-01 23:47:26,10 +2019-01-01 23:47:31,10 +2019-01-01 23:47:36,10 +2019-01-01 23:47:41,10 +2019-01-01 23:47:46,10 +2019-01-01 23:47:51,10 +2019-01-01 23:47:56,10 +2019-01-01 23:48:01,10 +2019-01-01 23:48:06,10 +2019-01-01 23:48:11,10 +2019-01-01 23:48:16,10 +2019-01-01 23:48:21,10 +2019-01-01 23:48:26,10 +2019-01-01 23:48:31,10 +2019-01-01 23:48:36,10 +2019-01-01 23:48:41,10 +2019-01-01 23:48:46,10 +2019-01-01 23:48:51,10 +2019-01-01 23:48:56,10 +2019-01-01 23:49:01,10 +2019-01-01 23:49:21,10 +2019-01-01 23:49:26,10 +2019-01-01 23:49:31,10 +2019-01-01 23:49:36,10 +2019-01-01 23:49:41,10 +2019-01-01 23:49:46,10 +2019-01-01 23:49:51,10 +2019-01-01 23:49:56,10 +2019-01-01 23:50:01,10 +2019-01-01 23:50:06,10 +2019-01-01 23:50:11,10 +2019-01-01 23:50:16,10 +2019-01-01 23:50:21,10 +2019-01-01 23:50:26,10 +2019-01-01 23:50:43,10 diff --git a/logs/sensors/sensor_1.log.9 b/logs/sensors/sensor_1.log.9 new file mode 100644 index 0000000..e06001d --- /dev/null +++ b/logs/sensors/sensor_1.log.9 @@ -0,0 +1,86 @@ +2019-01-01 23:27:07,10 +2019-01-01 23:27:12,10 +2019-01-01 23:27:17,10 +2019-01-01 23:27:22,10 +2019-01-01 23:27:27,10 +2019-01-01 23:27:32,10 +2019-01-01 23:27:37,10 +2019-01-01 23:27:42,10 +2019-01-01 23:27:47,10 +2019-01-01 23:27:52,10 +2019-01-01 23:27:57,10 +2019-01-01 23:28:02,10 +2019-01-01 23:28:07,10 +2019-01-01 23:28:12,10 +2019-01-01 23:28:17,10 +2019-01-01 23:28:22,10 +2019-01-01 23:28:27,10 +2019-01-01 23:28:32,10 +2019-01-01 23:28:37,10 +2019-01-01 23:28:42,10 +2019-01-01 23:28:47,10 +2019-01-01 23:28:52,10 +2019-01-01 23:28:57,10 +2019-01-01 23:29:02,10 +2019-01-01 23:29:07,10 +2019-01-01 23:29:12,10 +2019-01-01 23:29:17,10 +2019-01-01 23:29:22,10 +2019-01-01 23:29:27,10 +2019-01-01 23:29:32,10 +2019-01-01 23:29:37,10 +2019-01-01 23:29:42,10 +2019-01-01 23:29:47,10 +2019-01-01 23:29:52,10 +2019-01-01 23:29:57,10 +2019-01-01 23:30:02,10 +2019-01-01 23:35:55,10 +2019-01-01 23:36:00,10 +2019-01-01 23:36:05,10 +2019-01-01 23:36:10,10 +2019-01-01 23:36:15,10 +2019-01-01 23:36:20,10 +2019-01-01 23:36:25,10 +2019-01-01 23:36:30,10 +2019-01-01 23:36:35,10 +2019-01-01 23:36:40,10 +2019-01-01 23:36:45,10 +2019-01-01 23:36:50,10 +2019-01-01 23:36:55,10 +2019-01-01 23:37:02,10 +2019-01-01 23:37:07,10 +2019-01-01 23:37:12,10 +2019-01-01 23:37:17,10 +2019-01-01 23:37:22,10 +2019-01-01 23:39:27,10 +2019-01-01 23:39:32,10 +2019-01-01 23:39:37,10 +2019-01-01 23:39:42,10 +2019-01-01 23:39:47,10 +2019-01-01 23:40:44,10 +2019-01-01 23:40:49,10 +2019-01-01 23:40:54,10 +2019-01-01 23:40:59,10 +2019-01-01 23:41:04,10 +2019-01-01 23:41:09,10 +2019-01-01 23:41:14,10 +2019-01-01 23:41:19,10 +2019-01-01 23:41:24,10 +2019-01-01 23:41:29,10 +2019-01-01 23:41:34,10 +2019-01-01 23:41:39,10 +2019-01-01 23:41:44,10 +2019-01-01 23:41:49,10 +2019-01-01 23:41:54,10 +2019-01-01 23:41:59,10 +2019-01-01 23:42:04,10 +2019-01-01 23:42:09,10 +2019-01-01 23:42:14,10 +2019-01-01 23:42:19,10 +2019-01-01 23:42:24,10 +2019-01-01 23:42:29,10 +2019-01-01 23:42:34,10 +2019-01-01 23:42:39,10 +2019-01-01 23:42:44,10 +2019-01-01 23:42:49,10 +2019-01-01 23:42:54,10 diff --git a/logs/sensors/sensor_2.log b/logs/sensors/sensor_2.log new file mode 100644 index 0000000..107d13f --- /dev/null +++ b/logs/sensors/sensor_2.log @@ -0,0 +1,16 @@ +2019-01-01 16:29:39,10 +2019-01-01 16:29:40,10 +2019-01-01 16:29:41,10 +2019-01-01 16:29:42,10 +2019-01-01 16:31:21,10 +2019-01-01 16:31:22,10 +2019-01-01 16:31:23,10 +2019-01-01 16:31:24,10 +2019-01-01 16:49:40,10 +2019-01-01 16:49:41,10 +2019-01-01 16:49:42,10 +2019-01-01 16:49:43,10 +2019-01-01 16:51:23,10 +2019-01-01 16:51:24,10 +2019-01-01 16:51:25,10 +2019-01-01 16:51:26,10 diff --git a/main.py b/main.py deleted file mode 100644 index 7a95a24..0000000 --- a/main.py +++ /dev/null @@ -1,191 +0,0 @@ -import aiosqlite -from aiohttp import web -from aiohttp_swagger import * -from aiojobs.aiohttp import setup, spawn, get_scheduler_from_app -from core.matcher import MQTTMatcher -from hbmqtt.broker import Broker -from hbmqtt.client import MQTTClient -from hbmqtt.mqtt.constants import QOS_1 - -from core.cbpiwebsocket import websocket_handler - -TEST_DB = "test.db" -c = MQTTClient() -import asyncio - -matcher = MQTTMatcher() - -config = { - 'listeners': { - 'default': { - 'type': 'tcp', - 'bind': '0.0.0.0:1885', - }, - 'my-ws-1': { - 'bind': '0.0.0.0:8888', - 'type': 'ws' - } - }, - - 'sys_interval': 10, - 'auth': { - 'allow-anonymous': True, - } -} - -broker = Broker(config, plugin_namespace="hbmqtt.test.plugins") - - -async def test2(name): - while True: - print(name) - await asyncio.sleep(1) - - - - - -async def handle(request): - name = request.match_info.get('name', "Anonymous") - text = "Hello, " + name - - return web.Response(text=text) - - -async def test_connection(): - async with aiosqlite.connect(TEST_DB) as db: - - assert isinstance(db, aiosqlite.Connection) - - -app = web.Application() - - -async def listen_to_redis(app): - while True: - await asyncio.sleep(1) - - #for w in _ws: - # pass - # await w.send_str("HALLO") - - # print(w) - - -async def myjob(app): - while True: - await asyncio.sleep(1) - - - -def ok_msg(msg): - pass - - -def ok_msg1(msg): - pass - - -def ok_msg2(msg): - pass - - -mqtt_methods = {"test": ok_msg, "test/+/ab": ok_msg1, "test/+": ok_msg2} - - -async def on_message(): - while True: - message = await c.deliver_message() - matched = False - packet = message.publish_packet - print(message.topic) - print(message.topic.split('/')) - data = packet.payload.data.decode("utf-8") - - for callback in matcher.iter_match(message.topic): - - callback(data) - matched = True - - if matched == False: - print("NO HANDLER", data) - - #for w in _ws: - # await w.send_str(data) - - -async def start_background_tasks(app): - app['redis_listener'] = app.loop.create_task(listen_to_redis(app)) - - -async def start_broker(app): - - await broker.start() - - await c.connect('mqtt://localhost:1885') - - for k, v in mqtt_methods.items(): - print(k, v) - await c.subscribe([(k, QOS_1)]) - - matcher[k] = v - # await c.subscribe([('/test', QOS_1),('/hallo', QOS_1)]) - - - await get_scheduler_from_app(app).spawn(on_message()) - - -job = None - - -async def start_task(request): - global job - job = await spawn(request, myjob(app)) - await test_connection() - return web.Response(text="OK") - - -async def stop_task(request): - await job.close() - return web.Response(text="OK") - - -async def stats(request): - s = get_scheduler_from_app(app) - - return web.Response(text="%s" % s.active_count) - - - - - -setup(app) - - -def start_bg(app, name, method): - print("HALLO111") - - async def start(app): - app[name] = app.loop.create_task(method(name)) - - app.on_startup.append(start) - - -# start_bg(app, "test", test2) -# start_bg(app, "test2", test2) - -#app.on_startup.append(start_background_tasks) -app.on_startup.append(start_broker) - -app.add_routes([web.get('/', handle), - web.get('/stop', stop_task), - web.get('/start', start_task), - web.get('/stats', stats), - web.get('/ws', websocket_handler), - web.get('/{name}', handle) - - ]) - -setup_swagger(app) - -web.run_app(app) diff --git a/main2.py b/main2.py deleted file mode 100644 index 2330f3f..0000000 --- a/main2.py +++ /dev/null @@ -1,7 +0,0 @@ - - -with open('./config/plugin_list.txt') as f: - required = f.read().splitlines() - - print(required) - diff --git a/tests/test_app.py b/tests/test_actor.py similarity index 55% rename from tests/test_app.py rename to tests/test_actor.py index 159b82b..7a285fd 100644 --- a/tests/test_app.py +++ b/tests/test_actor.py @@ -4,7 +4,7 @@ from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop from core.craftbeerpi import CraftBeerPi -class MyAppTestCase(AioHTTPTestCase): +class ActorTestCase(AioHTTPTestCase): @@ -16,7 +16,7 @@ class MyAppTestCase(AioHTTPTestCase): @unittest_run_loop - async def test_example(self): + async def test_actor_switch(self): resp = await self.client.post(path="/login", data={"username": "cbpi", "password": "123"}) assert resp.status == 200 @@ -42,5 +42,34 @@ class MyAppTestCase(AioHTTPTestCase): i = await self.cbpi.actor.get_one(1) assert i.instance.state is False + @unittest_run_loop + async def test_crud(self): + data = { + "name": "CustomActor", + "type": "CustomActor", + "config": { + "interval": 5 + } + } + # Add new sensor + resp = await self.client.post(path="/actor/", json=data) + assert resp.status == 200 + m = await resp.json() + sensor_id = m["id"] + + # Get sensor + resp = await self.client.get(path="/actor/%s" % sensor_id) + assert resp.status == 200 + + m2 = await resp.json() + sensor_id = m2["id"] + + # Update Sensor + resp = await self.client.put(path="/actor/%s" % sensor_id, json=m) + assert resp.status == 200 + + # # Delete Sensor + resp = await self.client.delete(path="/actor/%s" % sensor_id) + assert resp.status == 204 diff --git a/tests/test_config.py b/tests/test_config.py index 833f0a7..a934eac 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -54,4 +54,4 @@ class ConfigTestCase(AioHTTPTestCase): async def test_http_get(self): resp = await self.client.request("GET", "/config/") assert resp.status == 200 - #print(await eresp.json()) + diff --git a/tests/test_kettle.py b/tests/test_kettle.py index 67855ee..934e7d8 100644 --- a/tests/test_kettle.py +++ b/tests/test_kettle.py @@ -19,7 +19,7 @@ class KettleTestCase(AioHTTPTestCase): print(await resp.json()) @unittest_run_loop - async def test_add(self): + async def test_crud(self): data = { "name": "Test", "sensor": None, @@ -33,22 +33,26 @@ class KettleTestCase(AioHTTPTestCase): "target_temp": None } + # Add new sensor resp = await self.client.post(path="/kettle/", json=data) assert resp.status == 200 - ''' - result = await self.cbpi.kettle.toggle_automtic(1) - print("#### RESULT", result) - assert result[0] is True - print("FIRE") + m = await resp.json() + sensor_id = m["id"] + + # Get sensor + resp = await self.client.get(path="/kettle/%s" % sensor_id) + assert resp.status == 200 + + m2 = await resp.json() + sensor_id = m2["id"] + + # Update Sensor + resp = await self.client.put(path="/kettle/%s" % sensor_id, json=m) + assert resp.status == 200 + + # # Delete Sensor + resp = await self.client.delete(path="/kettle/%s" % sensor_id) + assert resp.status == 204 - await asyncio.sleep(1) - - self.cbpi.bus.fire("actor/1/on", id=1) - - - await asyncio.sleep(5) - #assert await self.cbpi.kettle.toggle_automtic(1) is True - #assert await self.cbpi.kettle.toggle_automtic(99) is False - ''' \ No newline at end of file diff --git a/tests/test_sensor.py b/tests/test_sensor.py new file mode 100644 index 0000000..f8755a5 --- /dev/null +++ b/tests/test_sensor.py @@ -0,0 +1,47 @@ +import asyncio +from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop +from core.craftbeerpi import CraftBeerPi + + +class SensorTestCase(AioHTTPTestCase): + + async def get_application(self): + self.cbpi = CraftBeerPi() + await self.cbpi.init_serivces() + return self.cbpi.app + + @unittest_run_loop + async def test_crud(self): + + data = { + "name": "CustomSensor", + "type": "CustomSensor", + "config": { + "interval": 1 + } + } + + + # Add new sensor + resp = await self.client.post(path="/sensor/", json=data) + assert resp.status == 200 + + m = await resp.json() + sensor_id = m["id"] + + # Get sensor + resp = await self.client.get(path="/sensor/%s"% sensor_id) + assert resp.status == 200 + + m2 = await resp.json() + sensor_id = m2["id"] + + # Update Sensor + resp = await self.client.put(path="/sensor/%s" % sensor_id, json=m) + assert resp.status == 200 + + # # Delete Sensor + resp = await self.client.delete(path="/sensor/%s" % sensor_id) + assert resp.status == 204 + + await asyncio.sleep(5) \ No newline at end of file