Actor API¶
-Test¶
-HELLO WORLD
--
+
-
class
core.controller.actor_controller.
ActorController
(cbpi)¶ The main actor controller
@@ -85,6 +88,137 @@- Documentation overview
- Previous: Welcome to CraftBeerPi’s documentation! -
- Next: Sensor API +
- Next: Sensor
Actor¶
+Architecture¶
+ +ActorController¶
+Custom Actor¶
+1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 | import logging
+
+from core.api import CBPiActor, Property, action, background_task
+
+
+
+class CustomActor(CBPiActor):
+
+ name = Property.Number(label="Test")
+ name1 = Property.Text(label="Test")
+ name2 = Property.Kettle(label="Test")
+
+ @background_task("s1", interval=2)
+ async def bg_job(self):
+ print("WOOH BG")
+
+ @action(key="name", parameters={})
+ def myAction(self):
+ pass
+
+ def state(self):
+ super().state()
+
+ def off(self):
+ print("OFF")
+ self.state = False
+
+ def on(self, power=100):
+
+ print("ON")
+ self.state = True
+
+
+ def __init__(self, cbpi=None):
+
+ if cbpi is None:
+ return
+
+ print("INIT MY ACTOR111111")
+ self.cfg = self.load_config()
+
+ self.logger = logging.getLogger(__file__)
+ logging.basicConfig(level=logging.INFO)
+
+ self.logger.info("########WOOHOO MY ACTOR")
+ self.cbpi = cbpi
+
+
+def setup(cbpi):
+
+ '''
+ This method is called by the server during startup
+ Here you need to register your plugins at the server
+
+ :param cbpi: the cbpi core
+ :return:
+ '''
+
+ cbpi.plugin.register("CustomActor", CustomActor)
+ |
config.yaml
+1 +2 | name: Manuel
+version: 4
+ |
Navigation
@@ -116,7 +250,7 @@A
@@ -58,14 +56,10 @@N
-- | - |
O
S-Navigationdiff --git a/docs/index.html b/docs/index.html index 3a27426..c102bc5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -16,7 +16,7 @@ - + @@ -35,163 +35,13 @@Welcome to CraftBeerPi’s documentation!¶-
-
-Documentation¶-
-
-
Example Component¶-from core.api.decorator import on_event
-from core.api.extension import CBPiExtension
-
-class MyComp(CBPiExtension):
-
- def __init__(self, cbpi):
- '''
- Initializer
-
- :param cbpi:
- '''
- self.cbpi = cbpi
- # register for bus events
- self.cbpi.register_events(self)
-
- @on_event(topic="actor/#")
- def listen(self, **kwargs):
- print("Test", kwargs)
-
-def setup(cbpi):
- '''
- Setup method is invoked during startup
-
- :param cbpi: the cbpi core object
- :return:
- '''
- # regsiter the component to the core
- cbpi.plugin.register("MyComp", MyComp)
- Navigation@@ -221,7 +71,7 @@ which will be launched during start up of the serverRelated Topicsdiff --git a/docs/objects.inv b/docs/objects.inv index 5faf36e..ba3e795 100644 Binary files a/docs/objects.inv and b/docs/objects.inv differ diff --git a/docs/py-modindex.html b/docs/py-modindex.html index 0156df7..119a099 100644 --- a/docs/py-modindex.html +++ b/docs/py-modindex.html @@ -60,12 +60,7 @@
|
- | core.controller.notification_controller
- |
- |
- | core.craftbeerpi
+ | core.controller.sensor_controller
| |
Navigation
diff --git a/docs/search.html b/docs/search.html index da9e3b6..c268af4 100644 --- a/docs/search.html +++ b/docs/search.html @@ -82,8 +82,8 @@Navigation
diff --git a/docs/searchindex.js b/docs/searchindex.js index 474b9c9..0974c32 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["actor","index","sensor","step"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":1,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:55},filenames:["actor.rst","index.rst","sensor.rst","step.rst"],objects:{"core.controller":{actor_controller:[0,0,0,"-"],notification_controller:[1,0,0,"-"]},"core.controller.actor_controller":{ActorController:[0,1,1,""]},"core.controller.actor_controller.ActorController":{init:[0,2,1,""],off:[0,2,1,""],register:[0,2,1,""]},"core.controller.notification_controller":{NotificationController:[1,1,1,""]},"core.craftbeerpi":{CraftBeerPi:[1,1,1,""]},"core.craftbeerpi.CraftBeerPi":{notify:[1,2,1,""],register:[1,2,1,""],register_background_task:[1,2,1,""],register_http_endpoints:[1,2,1,""],setup:[1,2,1,""]},core:{craftbeerpi:[1,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method"},terms:{"class":[0,1],"import":1,"new":0,"return":[0,1],The:0,__init__:1,actor:1,actor_control:0,actorcontrol:0,all:[0,1],analyz:1,api:1,background:1,background_task:1,bus:1,cbpi:[0,1],cbpiextens:1,clazz:0,client:1,control:[0,1],convini:1,core:[0,1],creat:0,danger:1,decor:1,def:1,docstr:1,dure:[0,1],endpoint:1,event:1,extens:1,from:1,hello:[0,1],http:1,info:1,init:0,initi:[0,1],instanc:0,invok:1,job:1,kei:1,kwarg:[0,1],launch:1,listen:1,main:0,manuel:1,messag:1,method:[0,1],mycomp:1,name:[0,1],none:[0,1],notif:1,notifi:1,notification_control:1,notificationcontrol:1,obj:1,object:1,off:0,on_ev:1,param:[0,1],paramet:[0,1],pars:1,plugin:1,prefix:1,print:1,provid:1,regist:[0,1],register_background_task:1,register_ev:1,register_http_endpoint:1,registr:1,regsit:1,request_map:1,self:1,send:1,sensor:1,server:1,setup:1,start:1,startup:[0,1],step:1,successs:1,test:1,thi:[0,1],topic:1,type:[0,1],url_prefix:1,used:1,version:1,warn:1,which:1,wich:1,world:0},titles:["Actor API","Welcome to CraftBeerPi\u2019s documentation!","Sensor API","Step API"],titleterms:{actor:0,api:[0,2,3],compon:1,config:1,craftbeerpi:1,document:1,exampl:1,sensor:2,step:3,test:0,welcom:1,yaml:1}}) \ No newline at end of file +Search.setIndex({docnames:["actor","index","sensor","step"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":1,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:55},filenames:["actor.rst","index.rst","sensor.rst","step.rst"],objects:{"core.controller":{actor_controller:[0,0,0,"-"],sensor_controller:[2,0,0,"-"]},"core.controller.actor_controller":{ActorController:[0,1,1,""]},"core.controller.actor_controller.ActorController":{init:[0,2,1,""],off:[0,2,1,""],register:[0,2,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method"},terms:{"class":0,"import":0,"new":0,"return":0,"super":0,"true":0,The:0,__file__:0,__init__:0,action:0,actor111111:0,actor:1,actor_control:0,all:0,api:[0,1],async:0,background_task:0,basicconfig:0,bg_job:0,call:0,cbpi:0,cbpiactor:0,cfg:0,clazz:0,config:0,control:0,core:0,creat:0,customactor:0,def:0,dure:0,fals:0,from:0,getlogg:0,here:0,info:0,init:0,initi:0,instanc:0,interv:0,kei:0,kettl:0,kwarg:0,label:0,level:0,load_config:0,log:0,logger:0,main:0,manuel:0,method:0,myaction:0,name1:0,name2:0,name:0,need:0,none:0,number:0,off:0,param:0,paramet:0,pass:0,plugin:0,power:0,print:0,properti:0,regist:0,self:0,sensor:1,server:0,setup:0,startup:0,state:0,step:1,test:0,text:0,thi:0,type:0,version:0,wooh:0,woohoo:0,yaml:0,you:0,your:0},titles:["Actor","Welcome to CraftBeerPi\u2019s documentation!","Sensor","Step API"],titleterms:{actor:0,actorcontrol:0,api:3,architectur:[0,2],craftbeerpi:1,custom:[0,2],document:1,sensor:2,sensorcontrol:2,step:3,welcom:1}}) \ No newline at end of file diff --git a/docs/sensor.html b/docs/sensor.html index 1adeb17..a3a5e79 100644 --- a/docs/sensor.html +++ b/docs/sensor.html @@ -6,7 +6,7 @@ -Sensor API¶
+ @@ -56,8 +65,8 @@Navigation
@@ -65,7 +74,7 @@Related Topics
diff --git a/docs/step.html b/docs/step.html index 344e183..ef4578c 100644 --- a/docs/step.html +++ b/docs/step.html @@ -16,7 +16,7 @@ - + @@ -55,8 +55,8 @@Navigation
@@ -64,7 +64,7 @@Related Topics
- Documentation overview
-
-
- Previous: Sensor API +
- Previous: Sensor