diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2466e55..fb23ca5 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,7 +2,26 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -25,7 +44,7 @@
-
+
@@ -65,10 +84,43 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -77,10 +129,42 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -88,7 +172,7 @@
-
+
@@ -97,29 +181,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -127,51 +193,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -183,14 +204,6 @@
- HALLOOOOOOO
- It's im
- cbpi
- init
- webso
- ActorTable
- ActorForm
- render_config
###
ui
httpsen
@@ -212,7 +225,15 @@
step/brewing/stopped
ADDD
Nit ACTOR
+ DELE
+ delete_a
+ notifi
+ exte
+ "Not Found"
+ toggle
+ job
print
+ automatic
@@ -236,11 +257,6 @@
@@ -313,12 +334,6 @@
-
-
-
-
-
-
@@ -330,15 +345,21 @@
-
+
-
-
+
+
+
+
+
+
+
+
@@ -351,7 +372,39 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -361,28 +414,42 @@
-
-
-
-
+
-
-
-
-
-
+
+
-
-
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -657,7 +724,8 @@
-
+
+
1541288846149
@@ -709,7 +777,7 @@
-
+
@@ -721,18 +789,18 @@
-
+
-
+
-
+
-
+
@@ -796,61 +864,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -902,16 +915,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -936,20 +939,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -960,16 +949,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -994,13 +973,6 @@
-
-
-
-
-
-
-
@@ -1025,16 +997,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1052,39 +1014,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1098,16 +1030,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1129,16 +1051,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1146,6 +1058,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1153,30 +1082,17 @@
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -1185,7 +1101,7 @@
-
+
@@ -1193,5 +1109,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cbpi/cli.py b/cbpi/cli.py
index 445d853..e1e3059 100644
--- a/cbpi/cli.py
+++ b/cbpi/cli.py
@@ -36,7 +36,7 @@ def main():
args = parser.parse_args()
- logging.basicConfig(level=logging.INFO, filename='./logs/app.log', filemode='a', format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
+ #logging.basicConfig(level=logging.INFO, filename='./logs/app.log', filemode='a', format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
if args.action == "setup":
diff --git a/cbpi/controller/actor_controller.py b/cbpi/controller/actor_controller.py
index b8170e9..fcdb2e9 100644
--- a/cbpi/controller/actor_controller.py
+++ b/cbpi/controller/actor_controller.py
@@ -1,3 +1,4 @@
+import asyncio
import logging
from asyncio import Future
from cbpi.api import *
@@ -76,7 +77,7 @@ class ActorController(CRUDController):
@on_event(topic="actor/+/toggle")
- async def toggle(self, actor_id, power=100, **kwargs) -> None:
+ async def toggle(self, actor_id, power=100, time=None, **kwargs) -> None:
"""
Method to toggle an actor on or off
Supporting Event Topic "actor/+/toggle"
@@ -86,18 +87,23 @@ class ActorController(CRUDController):
:return:
"""
+
+
self.logger.debug("TOGGLE %s" % actor_id)
actor_id = int(actor_id)
if actor_id in self.cache:
actor = self.cache[actor_id].instance
- if actor.state is True:
+ if actor.state is True:
await self.off(actor_id=actor_id)
else:
-
-
await self.on(actor_id=actor_id)
+ if time is not None:
+ async def time_toggle(cbpi, actor_id, time):
+ await asyncio.sleep(time)
+ await cbpi.bus.fire("actor/%s/off" % actor_id, actor_id = actor_id)
+ await self.cbpi.job.start_job(time_toggle(self.cbpi, actor_id, time), "actor_%s_time_toggle" % actor_id, "actor_toggle")
@on_event(topic="actor/+/off")
diff --git a/cbpi/controller/kettle_controller.py b/cbpi/controller/kettle_controller.py
index c4004d7..cbc1ac4 100644
--- a/cbpi/controller/kettle_controller.py
+++ b/cbpi/controller/kettle_controller.py
@@ -24,6 +24,9 @@ class KettleController(CRUDController):
:return:
'''
await super(KettleController, self).init()
+ for key, value in self.cache.items():
+ value.state = False
+
def get_state(self):
return dict(items=self.cache,types=self.types)
@@ -44,14 +47,17 @@ class KettleController(CRUDController):
await self.cbpi.bus.fire(topic="kettle/%s/automatic" % id, id=id)
- @on_event(topic="job/done")
+ @on_event(topic="job/+/done")
async def job_stop(self, key, **kwargs) -> None:
match = re.match("kettle_logic_(\d+)", key)
if match is not None:
kid = match.group(1)
+ await self.cbpi.bus.fire(topic="kettle/%s/logic/stop" % kid)
+
kettle = self.cache[int(kid)]
kettle.instance = None
+ kettle.state = False
@on_event(topic="kettle/+/automatic")
async def handle_automtic_event(self, id, **kwargs):
@@ -65,6 +71,7 @@ class KettleController(CRUDController):
'''
id = int(id)
+ print("K", id)
if id in self.cache:
kettle = self.cache[id]
@@ -72,7 +79,10 @@ class KettleController(CRUDController):
if hasattr(kettle, "instance") is False:
kettle.instance = None
self._is_logic_running(id)
+
+
if kettle.instance is None:
+ print("start")
if kettle.logic in self.types:
clazz = self.types.get("CustomKettleLogic")["class"]
cfg = kettle.config.copy()
@@ -80,13 +90,20 @@ class KettleController(CRUDController):
kettle.instance = clazz(**cfg)
await self.cbpi.job.start_job(kettle.instance.run(), "Kettle_logic_%s" % kettle.id, "kettle_logic%s" % id)
+ kettle.state = True
+
+ await self.cbpi.bus.fire(topic="kettle/%s/logic/start" % id)
else:
kettle.instance.running = False
kettle.instance = None
+ kettle.state = False
+ await self.cbpi.bus.fire(topic="kettle/%s/logic/stop" % id)
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
diff --git a/cbpi/controller/step_controller.py b/cbpi/controller/step_controller.py
index f51773c..dfa74bf 100644
--- a/cbpi/controller/step_controller.py
+++ b/cbpi/controller/step_controller.py
@@ -84,7 +84,7 @@ class StepController(CRUDController):
:param kwargs:
:return: None
'''
- print("REQUEST NEXT")
+
self.starttime = time.time()
if self.current_step is not None and self.is_next is False:
self.logger.info("Request Next Step to start. Stopping current step")
diff --git a/cbpi/controller/translation_controller.py b/cbpi/controller/translation_controller.py
index 79a1fb0..0cce8d5 100644
--- a/cbpi/controller/translation_controller.py
+++ b/cbpi/controller/translation_controller.py
@@ -12,7 +12,7 @@ class TranslationController(object):
async def init(self):
self._cache = await TranslationModel.get_all()
- print(self._cache)
+
def get_all(self):
diff --git a/cbpi/craftbeerpi.py b/cbpi/craftbeerpi.py
index 9e846c2..eff0ba9 100644
--- a/cbpi/craftbeerpi.py
+++ b/cbpi/craftbeerpi.py
@@ -44,7 +44,6 @@ async def error_middleware(request, handler):
return response
message = response.message
except web.HTTPException as ex:
- print(ex)
if ex.status != 404:
raise
message = ex.reason
diff --git a/cbpi/extension/comp/__init__.py b/cbpi/extension/comp/__init__.py
index 1a473af..58ccbeb 100644
--- a/cbpi/extension/comp/__init__.py
+++ b/cbpi/extension/comp/__init__.py
@@ -41,8 +41,8 @@ class MyComp(CBPiExtension, CRUDController, HttpCrudEndpoints):
@on_event(topic="kettle/+/automatic")
async def listen2(self, **kwargs):
-
- await self.cbpi.bus.fire(topic="actor/%s/toggle" % 1, id=1)
+ pass
+ #await self.cbpi.bus.fire(topic="actor/%s/toggle" % 1, id=1)
def setup(cbpi):
diff --git a/cbpi/extension/dummyactor/__init__.py b/cbpi/extension/dummyactor/__init__.py
index 6326491..bc38333 100644
--- a/cbpi/extension/dummyactor/__init__.py
+++ b/cbpi/extension/dummyactor/__init__.py
@@ -22,6 +22,12 @@ except Exception:
class CustomActor(CBPiActor):
# Custom property which can be configured by the user
+ @action("test", parameters={})
+ def action1(self):
+ print("EOOOHOOO")
+ pass
+
+
def init(self):
self.state = False
diff --git a/cbpi/extension/dummylogic/__init__.py b/cbpi/extension/dummylogic/__init__.py
index 3788526..4373a9a 100644
--- a/cbpi/extension/dummylogic/__init__.py
+++ b/cbpi/extension/dummylogic/__init__.py
@@ -42,7 +42,7 @@ class CustomLogic(CBPiKettleLogic):
async def run(self):
-
+ '''
async def my_callback(value, **kwargs):
if value == 5:
@@ -51,21 +51,21 @@ class CustomLogic(CBPiKettleLogic):
else:
pass
- result = await self.wait_for_event("sensor/1", callback=my_callback)
-
-
-
+ result = await self.wait_for_event("sensor/1/data", callback=my_callback)
'''
+
+
+
+
while self.running:
-
-
+
print("RUN", self.test)
value = await self.cbpi.sensor.get_value(1)
print(value)
if value >= 10:
break
await asyncio.sleep(1)
- '''
+
def setup(cbpi):
diff --git a/cbpi/extension/dummysensor/__init__.py b/cbpi/extension/dummysensor/__init__.py
index 2dbff6d..db4dfe1 100644
--- a/cbpi/extension/dummysensor/__init__.py
+++ b/cbpi/extension/dummysensor/__init__.py
@@ -125,7 +125,7 @@ class HTTPSensorEndpoint(CBPiExtension):
key = request.match_info['key']
value = request.match_info['value']
cache[key] = value
- print(cache)
+
return web.Response(status=204)
diff --git a/cbpi/http_endpoints/http_actor.py b/cbpi/http_endpoints/http_actor.py
index af24a8a..fe6f9cd 100644
--- a/cbpi/http_endpoints/http_actor.py
+++ b/cbpi/http_endpoints/http_actor.py
@@ -220,8 +220,11 @@ class ActorHttpEndpoints(HttpCrudEndpoints):
description: invalid HTTP Met
"""
actor_id = int(request.match_info['id'])
-
- await self.cbpi.bus.fire(topic="actor/%s/toggle" % actor_id, actor_id=actor_id)
+ if await request.text():
+ data = await request.json()
+ await self.cbpi.bus.fire(topic="actor/%s/toggle" % actor_id, time=data.get("time"), actor_id=actor_id)
+ else:
+ await self.cbpi.bus.fire(topic="actor/%s/toggle" % actor_id, actor_id=actor_id)
return web.Response(status=204)
@request_mapping(path="/{id:\d+}/action", method="POST", auth_required=auth)
diff --git a/cbpi/http_endpoints/http_config.py b/cbpi/http_endpoints/http_config.py
index b6a2156..c9a2850 100644
--- a/cbpi/http_endpoints/http_config.py
+++ b/cbpi/http_endpoints/http_config.py
@@ -12,8 +12,9 @@ class ConfigHttpEndpoints(HttpCrudEndpoints):
self.controller = cbpi.config
self.cbpi.register(self, "/config")
- @request_mapping(path="/{name}/", method="POST", auth_required=False)
+ @request_mapping(path="/{name}/", method="PUT", auth_required=False)
async def http_post(self, request) -> web.Response:
+
"""
---
description: Set config parameter
@@ -29,6 +30,7 @@ class ConfigHttpEndpoints(HttpCrudEndpoints):
"204":
description: successful operation
"""
+ print("HALLO PARA")
name = request.match_info['name']
data = await request.json()
await self.controller.set(name=name, value=data.get("value"))
diff --git a/cbpi/http_endpoints/http_curd_endpoints.py b/cbpi/http_endpoints/http_curd_endpoints.py
index 66028aa..2c31e69 100644
--- a/cbpi/http_endpoints/http_curd_endpoints.py
+++ b/cbpi/http_endpoints/http_curd_endpoints.py
@@ -42,7 +42,7 @@ class HttpCrudEndpoints():
id = int(request.match_info['id'])
data = await request.json()
obj = await self.controller.update(id, data)
- print("PRINT",await self.controller.get_one(id))
+
return web.json_response(await self.controller.get_one(id), dumps=json_dumps)
@request_mapping(path="/{id}", method="DELETE", auth_required=False)
diff --git a/cbpi/http_endpoints/http_kettle.py b/cbpi/http_endpoints/http_kettle.py
index 36d72e1..90a0fd8 100644
--- a/cbpi/http_endpoints/http_kettle.py
+++ b/cbpi/http_endpoints/http_kettle.py
@@ -153,7 +153,7 @@ class KettleHttpEndpoints(HttpCrudEndpoints):
self.controller = cbpi.kettle
self.cbpi.register(self, "/kettle")
- @request_mapping(path="/{id:\d+}/automatic", auth_required=False)
+ @request_mapping(path="/{id:\d+}/automatic", method="POST", auth_required=False)
async def http_automatic(self, request):
"""
---
diff --git a/cbpi/http_endpoints/http_step.py b/cbpi/http_endpoints/http_step.py
index e05e82f..197475e 100644
--- a/cbpi/http_endpoints/http_step.py
+++ b/cbpi/http_endpoints/http_step.py
@@ -151,6 +151,21 @@ class StepHttpEndpoints(HttpCrudEndpoints):
"""
return await super().http_delete_one(request)
+ @request_mapping(path="/", method="DELETE", auth_required=False)
+ async def http_delete_all(self, request):
+ """
+ ---
+ description: Delete all step
+ tags:
+ - Step
+ responses:
+ "204":
+ description: successful operation
+ """
+ self.cbpi.notify(key="step_delete_all", message="NOT IMPLEMENTE", type="danger")
+ return web.Response(status=204)
+
+
@request_mapping(path="/action", auth_required=False)
async def http_action(self, request):
"""
@@ -228,6 +243,5 @@ class StepHttpEndpoints(HttpCrudEndpoints):
@request_mapping(path="/sort", method="POST", auth_required=False)
async def http_sort(self, request):
data = await request.json()
- print(data)
await self.cbpi.step.sort(data)
return web.Response(status=204)
\ No newline at end of file
diff --git a/cbpi/utils/encoder.py b/cbpi/utils/encoder.py
index de6820f..8aa8a52 100644
--- a/cbpi/utils/encoder.py
+++ b/cbpi/utils/encoder.py
@@ -12,8 +12,8 @@ class ComplexEncoder(JSONEncoder):
try:
if isinstance(obj, ActorModel):
- print(obj.instance)
- print("DATA", obj.__dict__)
+
+
data = dict(**obj.__dict__)
data["state"] = obj.instance.get_state()
del data["instance"]
@@ -35,6 +35,6 @@ class ComplexEncoder(JSONEncoder):
else:
raise TypeError()
except Exception as e:
- print(e)
+
pass
return None
diff --git a/craftbeerpi.db b/craftbeerpi.db
index cbd2457..1c348ab 100644
Binary files a/craftbeerpi.db and b/craftbeerpi.db differ
diff --git a/docs_src/source/actor.rst b/docs_src/source/actor.rst
index 3e1cca8..04d9fc0 100644
--- a/docs_src/source/actor.rst
+++ b/docs_src/source/actor.rst
@@ -42,4 +42,18 @@ config.yaml
.. literalinclude:: ../../cbpi/extension/dummyactor/config.yaml
:language: yaml
- :linenos:
\ No newline at end of file
+ :linenos:
+
+.. mermaid::
+
+ sequenceDiagram
+ participant Alice
+ participant Bob
+ Alice->John: Hello John, how are you?
+ loop Healthcheck
+ John->John: Fight against hypochondria
+ end
+ Note right of John: Rational thoughts
prevail...
+ John-->Alice: Great!
+ John->Bob: How about you?
+ Bob-->John: Jolly good!
\ No newline at end of file
diff --git a/docs_src/source/conf.py b/docs_src/source/conf.py
index b8f9d1b..8c92510 100644
--- a/docs_src/source/conf.py
+++ b/docs_src/source/conf.py
@@ -40,6 +40,7 @@ release = '4.0'
# ones.
extensions = [
'sphinx.ext.autodoc',
+ 'sphinxcontrib.mermaid'
]
# Add any paths that contain templates here, relative to this directory.