diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a6d4dcb..432355e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,19 +2,7 @@ - - - - - - - - - - - - - + - - - - - - - - - - - - @@ -114,8 +90,8 @@ - - + + @@ -146,8 +122,18 @@ - - + + + + + + + + + + + + @@ -1200,14 +1186,13 @@ - - + @@ -1265,16 +1250,6 @@ - - - - - - - - - - @@ -1752,18 +1727,26 @@ - - + + + + + + + + + + - - + + diff --git a/docs/_sources/standards.rst.txt b/docs/_sources/standards.rst.txt index 2d64928..2134fee 100644 --- a/docs/_sources/standards.rst.txt +++ b/docs/_sources/standards.rst.txt @@ -4,7 +4,8 @@ Standard & Guidelines Python ^^^^^^ -CraftBeerPi 4.x is based on Pyhton 3.7x. as main frameworks is `aiohttp` used. +CraftBeerPi 4.x is based on Pyhton 3.7x. +As a main framework CraftBeerPi is based on `aiohttp` * aioHTTP https://aiohttp.readthedocs.io/en/stable/ @@ -36,6 +37,49 @@ Here an example how listen on an event. It's imporante to add **kwargs as parameter to the listening method. This makes sure that maybe addtional event paramenter are not causing an exception. +HTTP Endpoints +-------------- + +A new HTTP endpoints should be exposed by adding the `@request_mapping` decorator on top of an async method. +The `path` parameter defines the URL path. The `auth_required` defines whether the endpoint should be accessible public or within a user session only. +Typically you perform just some basing parameter validation and fire an event so that other components and controllers can perform some actions. + +.. code-block:: python + + @request_mapping(path="/{id:\d+}/on", auth_required=False) + async def http_on(self, request) -> web.Response: + self.cbpi.bus.fire(topic="actor/%s/switch/on" % id, id=id, power=99) + return web.Response(status=204) + +.. note:: + + The Events are process in an async way. Results will be pushed to the client via WebSocket Event. + + +WebSocket +--------- + +The WebSocket is listening on `http://:/ws` +All events are forwarded to all connected web socket clients. + +The WebSocket Event is having the following structure. + +* topic -> is the bus topic +* data -> the event data + +.. code-block:: json + + { + "topic":"notification/step", + "data":{ + "key":"step", + "message":"Hello World", + "type":"info" + } + } + + + Web User Interface ^^^^^^^^^^^^^^^^^^ The Web UI is based on ReactJS + Redux. diff --git a/docs/index.html b/docs/index.html index 80035a4..e57386e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -188,6 +188,8 @@
  • Standard & Guidelines
    • Python
    • Web User Interface
    • diff --git a/docs/searchindex.js b/docs/searchindex.js index b1dfed5..53b8dc9 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["actor","core","index","install","kettle_controller","properties","sensor","standards","step"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:55},filenames:["actor.rst","core.rst","index.rst","install.rst","kettle_controller.rst","properties.rst","sensor.rst","standards.rst","step.rst"],objects:{"core.api.actor":{CBPiActor:[0,0,1,""]},"core.api.actor.CBPiActor":{off:[0,1,1,""],on:[0,1,1,""],state:[0,1,1,""]},"core.api.kettle_logic":{CBPiKettleLogic:[4,0,1,""]},"core.api.kettle_logic.CBPiKettleLogic":{init:[4,1,1,""],run:[4,1,1,""],stop:[4,1,1,""]},"core.api.property":{Property:[5,0,1,""]},"core.api.property.Property":{Actor:[5,0,1,""],Kettle:[5,0,1,""],Number:[5,0,1,""],Select:[5,0,1,""],Sensor:[5,0,1,""],Text:[5,0,1,""]},"core.api.sensor":{CBPiSensor:[6,0,1,""]},"core.api.sensor.CBPiSensor":{run:[6,1,1,""],state:[6,1,1,""]},"core.api.step":{CBPiSimpleStep:[8,0,1,""]},"core.api.step.CBPiSimpleStep":{is_dirty:[8,1,1,""],managed_fields:[8,2,1,""],next:[8,1,1,""],reset:[8,1,1,""],reset_dirty:[8,1,1,""],run:[8,1,1,""],run_cycle:[8,1,1,""],running:[8,1,1,""],stop:[8,1,1,""]},"core.controller.actor_controller":{ActorController:[0,0,1,""]},"core.controller.actor_controller.ActorController":{init:[0,1,1,""],model:[0,2,1,""],off:[0,1,1,""],on:[0,1,1,""],register:[0,1,1,""],toggle:[0,1,1,""]},"core.controller.kettle_controller":{KettleController:[4,0,1,""]},"core.controller.kettle_controller.KettleController":{_is_logic_running:[4,1,1,""],agitator_off:[4,1,1,""],agitator_on:[4,1,1,""],get_temp:[4,1,1,""],get_traget_temp:[4,1,1,""],handle_automtic_event:[4,1,1,""],heater_off:[4,1,1,""],heater_on:[4,1,1,""],init:[4,1,1,""],job_stop:[4,1,1,""],model:[4,2,1,""],toggle_automtic:[4,1,1,""]},"core.controller.sensor_controller":{SensorController:[6,0,1,""]},"core.controller.sensor_controller.SensorController":{get_value:[6,1,1,""],init:[6,1,1,""],model:[6,2,1,""]},"core.controller.step_controller":{StepController:[8,0,1,""]},"core.controller.step_controller.StepController":{handle_action:[8,1,1,""],handle_done:[8,1,1,""],handle_next:[8,1,1,""],handle_reset:[8,1,1,""],handle_start:[8,1,1,""],handle_stop:[8,1,1,""],http_action:[8,1,1,""],http_next:[8,1,1,""],http_reset:[8,1,1,""],http_start:[8,1,1,""],init:[8,1,1,""],start:[8,1,1,""]}},objnames:{"0":["py","class","Python class"],"1":["py","method","Python method"],"2":["py","attribute","Python attribute"]},objtypes:{"0":"py:class","1":"py:method","2":"py:attribute"},terms:{"1wire":5,"abstract":[],"boolean":4,"break":4,"byte":[],"class":[0,4,5,6,8],"default":[],"function":7,"import":[0,4,5,6,8],"int":4,"new":[7,8],"return":[0,4,5,6,8],"super":[0,5,6],"switch":[0,4,7],"true":[0,4,5,6,8],"try":4,"while":[4,6],FOR:4,For:5,One:7,THE:4,That:8,The:[0,4,5,7,8],Theses:5,YES:[4,8],__delattr__:[],__dict__:8,__dir__:[],__eq__:[],__format__:[],__ge__:[],__getattribute__:[],__gt__:[],__hash__:[],__init__:[0,4,5,6,8],__init_subclass__:[],__le__:[],__lt__:[],__ne__:[],__new__:[],__reduce__:[],__reduce_ex__:[],__repr__:[],__setattr__:[],__sizeof__:[],__str__:[],__subclasscheck__:[],__subclasshook__:[],__weakref__:[],_exception_count:[],_get_manged_fields_as_arrai:[],_interv:[],_is_logic_run:4,_max_except:[],_post_add_callback:[],_post_delete_callback:[],_pre_add_callback:[],_pre_delete_callback:[],_simplestep__dirti:[],_step_don:[],abc:[],abcmeta:[],accur:[],action:[0,5,6,8],actor:[2,4,6,7],actor_control:0,actor_id:0,actorcontrol:2,actorhttp:0,actormodel:0,add:7,addtion:[7,8],after:7,agitator_off:4,agitator_on:4,aiohttp:7,algorithm:[],alia:[0,4,6],all:[0,4,5,6,7],allow:[],amaz:4,api:[0,2,4,5,6,8],app:4,applic:[],architectur:2,arg:[0,4,6,8],assigend:8,async:[4,6,8],asyncio:[4,6,8],automat:4,avail:5,avoid:7,await:[4,6,8],babel:7,babelj:7,babl:7,background:[4,8],background_task:6,base:[0,4,6,7,8],between:0,block:[],bodi:[],brew:2,build:7,bus:[4,6,7],cach:[],call:[0,4,5,6,7,8],callback:4,can:[0,5,6,7],caus:7,cbpi:[0,4,5,6,7,8],cbpiactor:[2,5,6],cbpiextens:[0,4,6],cbpikettlelog:2,cbpisensor:2,cbpisimplestep:2,ccstom:8,chanag:[],chang:7,check:8,clazz:0,clone:3,code:[0,4,5],com:3,compon:7,concept:7,config:[0,4,6,8],configur:[0,5,6,8],continu:8,control:[0,2,4,7,8],conveni:4,core:[0,2,4,5,6,7,8],coupl:7,craftbeerpi4:3,craftbeerpi:7,creat:[0,4,6],create_futur:4,crud_control:[0,4,6],crudcontrol:[0,4,6],current:[0,8],custom:2,customactor:[0,5],customkettlelog:4,customlog:4,customsensor:6,customstep:[],customstepcbpi:8,cycl:8,data:[],databas:[0,4,6],def:[0,4,5,6,7,8],default_callback:4,default_valu:5,defin:8,delattr:[],delet:[],delete_al:[],descript:5,dir:[],directli:7,dirti:8,doc:7,document:7,documentaiton:7,doe:[],done:8,dummyactor:0,dummykettlelog:4,dummysensor:6,dummystep:8,dure:[0,4,5,6,8],earli:[],easili:7,els:4,end:[],endpoint:8,event:[0,4,7,8],eventbu:2,exampel:6,exampl:[5,7,8],except:[4,7],exect:8,execut:[4,8],expos:5,extend:[7,8],extens:[0,4,5,6],fals:[0,5,8],file:7,find:7,finish:4,fire:[6,7],first:8,flag:8,force_db_upd:[],format:[],formatt:[],framework:7,from:[0,4,5,6,8],futur:4,future_obj:4,gener:7,get_al:[],get_manged_fields_as_arrai:[],get_on:[],get_temp:4,get_traget_temp:4,get_valu:[4,6],getattr:[],git:3,github:3,goe:[0,5],gpio:[0,5],guidelin:2,handl:4,handle_act:8,handle_automtic_ev:4,handle_don:8,handle_next:8,handle_reset:8,handle_start:8,handle_stop:8,handler:8,has:8,hash:[],heater:4,heater_off:4,heater_on:4,hello:[4,7],help:[],helper:[],here:[0,4,5,6,7,8],how:[5,7],http:[3,7,8],http_action:8,http_add:[],http_api:6,http_delete_on:[],http_endpoint:6,http_get_al:[],http_get_on:[],http_next:8,http_off:[],http_on:[],http_reset:8,http_start:8,http_toggl:[],http_updat:[],httpapi:6,implement:[4,8],implementaion:8,imporant:7,inform:7,inherit:8,init:[0,4,6,8],initi:[0,4,6,8],initialis:4,instal:2,instanc:[0,4,6],int64:[],integ:0,interfac:2,interg:0,intern:6,interv:[6,8],invalid:[],invok:8,ip_address:7,is_dirti:8,issubclass:[],job_stop:4,json:[],keep:4,kei:[0,4,5,6,7,8],kettl:[2,5],kettle_control:4,kettle_id:4,kettle_log:4,kettlecontrol:2,kettlemodel:4,kwarg:[0,4,7,8],kwd:[0,4,6],label:[0,4,5,6,8],last:8,latest:7,least:8,list:5,listen:7,liten:[],log:[0,5,6],logic:[2,8],loop:4,loos:7,mai:[],main:[0,4,7],make:[3,7],manag:8,managed_field:8,manuel83:3,manuel:[],mayb:7,member:8,memori:[],messag:[7,8],met:[],method:[0,4,5,6,7,8],model:[0,4,6],modifi:8,modul:5,more:7,my_callback:4,myaction:[0,5,6],name:[0,4,5,6,8],need:[0,4,5,6,8],next:8,none:[0,4,5,6,7,8],normal:[],noth:[],notif:7,notifi:8,notimpl:[],number:[0,4,5,6,8],object:8,off:[0,4,5],on_ev:[4,7],one:8,oper:[],option:5,org:7,other:4,otherwis:8,outcom:[],overrid:[],overridden:[],overwritten:[4,8],param:[0,4,5,6,8],parament:7,paramet:[0,4,5,6,7,8],pass:[0,5,6,7],path:[],persisit:8,pickl:[],pip:3,place:8,plain:[],pleas:3,plugin:[0,4,5,6,7,8],point:[],pong:[],port:7,power:[0,5,7],print:[0,4,5,6,8],process:[4,7,8],produc:[],properti:[0,2,4,6,8],propertytyp:[],provid:[0,8],put:8,pyhton:7,python:[2,3],random:6,reactj:7,readthedoc:7,redux:7,refer:[],regist:[0,4,5,6,8],repr:[],request:8,requir:3,requset:8,reset:8,reset_dirti:8,respons:[4,8],rest:2,result:4,run:[4,5,6,8],run_cycl:8,runtim:6,scan:5,schema:[],see:7,select:5,self:[0,4,5,6,7,8],sensor:[2,4,5],sensor_control:6,sensorcontrol:6,sensormodel:6,sensorontrol:[],server:[0,4,5,6,7,8],servic:[],set:5,set_result:4,setattr:[],setup:[0,4,5,6,8],should:[7,8],show:8,signatur:[],simpl:8,simplestep:[],size:[],sleep:[4,6,8],stabl:7,standard:2,start:[4,8],startup:[0,4,5,6,7,8],state:[0,5,6],step:2,step_control:8,stepcontrol:2,stepmodel:[],stop:[4,6,8],str:[],string:4,subclass:[],success:[],support:0,sure:[3,7],swagger:7,swtich:[0,5],system:5,tag:[],task:[],test:[0,4,5,6,8],text:[5,6,8],thi:[0,4,5,6,7,8],time:5,timeout:4,timeouterror:4,toggl:[0,4],toggle_automt:4,topic:[0,4,7,8],trigger:[],txt:3,type:5,type_cfg:[],typic:[4,5],under:7,undoc:8,unit:5,unregist:4,updat:[],use:5,used:7,user:[0,2,5,6],using:7,valu:[0,4,5,6,8],variabl:[5,6,8],version:[0,4,6,8],via:[],wait:4,wait_for:4,wait_for_ev:4,weak:[],web:[2,8],web_respons:[],webpack:7,when:4,which:[0,4,5,6,8],woohoo:8,world:7,yaml:[0,4,6,8],yes:8,you:[0,4,5,6,7,8],your:[0,4,5,6,8]},titles:["Actor","Core","Welcome to CraftBeerPi\u2019s documentation!","Installation","Kettle","Properties","Sensor","Standard & Guidelines","Brewing Step"],titleterms:{actor:[0,5],actorcontrol:0,api:7,architectur:0,brew:8,cbpiactor:0,cbpikettlelog:4,cbpisensor:6,cbpisimplestep:8,control:6,core:1,craftbeerpi:2,custom:[0,4,5,6,8],document:2,eventbu:7,guidelin:7,instal:3,interfac:7,kettl:4,kettlecontrol:4,logic:4,properti:5,python:7,rest:7,sensor:6,sensorcontrol:[],sensorontrol:[],simplestep:[],standard:7,step:8,stepcontrol:8,user:7,web:7,welcom:2}}) \ No newline at end of file +Search.setIndex({docnames:["actor","core","index","install","kettle_controller","properties","sensor","standards","step"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,sphinx:55},filenames:["actor.rst","core.rst","index.rst","install.rst","kettle_controller.rst","properties.rst","sensor.rst","standards.rst","step.rst"],objects:{"core.api.actor":{CBPiActor:[0,0,1,""]},"core.api.actor.CBPiActor":{off:[0,1,1,""],on:[0,1,1,""],state:[0,1,1,""]},"core.api.kettle_logic":{CBPiKettleLogic:[4,0,1,""]},"core.api.kettle_logic.CBPiKettleLogic":{init:[4,1,1,""],run:[4,1,1,""],stop:[4,1,1,""]},"core.api.property":{Property:[5,0,1,""]},"core.api.property.Property":{Actor:[5,0,1,""],Kettle:[5,0,1,""],Number:[5,0,1,""],Select:[5,0,1,""],Sensor:[5,0,1,""],Text:[5,0,1,""]},"core.api.sensor":{CBPiSensor:[6,0,1,""]},"core.api.sensor.CBPiSensor":{run:[6,1,1,""],state:[6,1,1,""]},"core.api.step":{CBPiSimpleStep:[8,0,1,""]},"core.api.step.CBPiSimpleStep":{is_dirty:[8,1,1,""],managed_fields:[8,2,1,""],next:[8,1,1,""],reset:[8,1,1,""],reset_dirty:[8,1,1,""],run:[8,1,1,""],run_cycle:[8,1,1,""],running:[8,1,1,""],stop:[8,1,1,""]},"core.controller.actor_controller":{ActorController:[0,0,1,""]},"core.controller.actor_controller.ActorController":{init:[0,1,1,""],model:[0,2,1,""],off:[0,1,1,""],on:[0,1,1,""],register:[0,1,1,""],toggle:[0,1,1,""]},"core.controller.kettle_controller":{KettleController:[4,0,1,""]},"core.controller.kettle_controller.KettleController":{_is_logic_running:[4,1,1,""],agitator_off:[4,1,1,""],agitator_on:[4,1,1,""],get_temp:[4,1,1,""],get_traget_temp:[4,1,1,""],handle_automtic_event:[4,1,1,""],heater_off:[4,1,1,""],heater_on:[4,1,1,""],init:[4,1,1,""],job_stop:[4,1,1,""],model:[4,2,1,""],toggle_automtic:[4,1,1,""]},"core.controller.sensor_controller":{SensorController:[6,0,1,""]},"core.controller.sensor_controller.SensorController":{get_value:[6,1,1,""],init:[6,1,1,""],model:[6,2,1,""]},"core.controller.step_controller":{StepController:[8,0,1,""]},"core.controller.step_controller.StepController":{handle_action:[8,1,1,""],handle_done:[8,1,1,""],handle_next:[8,1,1,""],handle_reset:[8,1,1,""],handle_start:[8,1,1,""],handle_stop:[8,1,1,""],http_action:[8,1,1,""],http_next:[8,1,1,""],http_reset:[8,1,1,""],http_start:[8,1,1,""],init:[8,1,1,""],start:[8,1,1,""]}},objnames:{"0":["py","class","Python class"],"1":["py","method","Python method"],"2":["py","attribute","Python attribute"]},objtypes:{"0":"py:class","1":"py:method","2":"py:attribute"},terms:{"1wire":5,"abstract":[],"boolean":4,"break":4,"byte":[],"class":[0,4,5,6,8],"default":[],"function":7,"import":[0,4,5,6,8],"int":4,"new":[7,8],"public":7,"return":[0,4,5,6,7,8],"super":[0,5,6],"switch":[0,4,7],"true":[0,4,5,6,8],"try":4,"while":[4,6],FOR:4,For:5,One:7,THE:4,That:8,The:[0,4,5,7,8],Theses:5,YES:[4,8],__delattr__:[],__dict__:8,__dir__:[],__eq__:[],__format__:[],__ge__:[],__getattribute__:[],__gt__:[],__hash__:[],__init__:[0,4,5,6,8],__init_subclass__:[],__le__:[],__lt__:[],__ne__:[],__new__:[],__reduce__:[],__reduce_ex__:[],__repr__:[],__setattr__:[],__sizeof__:[],__str__:[],__subclasscheck__:[],__subclasshook__:[],__weakref__:[],_exception_count:[],_get_manged_fields_as_arrai:[],_interv:[],_is_logic_run:4,_max_except:[],_post_add_callback:[],_post_delete_callback:[],_pre_add_callback:[],_pre_delete_callback:[],_simplestep__dirti:[],_step_don:[],abc:[],abcmeta:[],access:7,accur:[],action:[0,5,6,7,8],actor:[2,4,6,7],actor_control:0,actor_id:0,actorcontrol:2,actorhttp:0,actormodel:0,add:7,adding:7,addtion:[7,8],after:7,agitator_off:4,agitator_on:4,aiohttp:7,algorithm:[],alia:[0,4,6],all:[0,4,5,6,7],allow:[],amaz:4,api:[0,2,4,5,6,8],app:4,applic:[],architectur:2,arg:[0,4,6,8],assigend:8,async:[4,6,7,8],asyncio:[4,6,8],auth_requir:7,automat:4,avail:5,avoid:7,await:[4,6,8],babel:7,babelj:7,babl:7,background:[4,8],background_task:6,base:[0,4,6,7,8],between:0,block:[],bodi:[],brew:2,build:7,bus:[4,6,7],cach:[],call:[0,4,5,6,7,8],callback:4,can:[0,5,6,7],caus:7,cbpi:[0,4,5,6,7,8],cbpiactor:[2,5,6],cbpiextens:[0,4,6],cbpikettlelog:2,cbpisensor:2,cbpisimplestep:2,ccstom:8,chanag:[],chang:7,check:8,clazz:0,client:7,clone:3,code:[0,4,5],com:3,compon:7,component:[],concept:7,config:[0,4,6,8],configur:[0,5,6,8],connect:7,continu:8,control:[0,2,4,7,8],conveni:4,core:[0,2,4,5,6,7,8],coupl:7,craftbeerpi4:3,craftbeerpi:7,creat:[0,4,6],create_futur:4,crud_control:[0,4,6],crudcontrol:[0,4,6],current:[0,8],custom:2,customactor:[0,5],customkettlelog:4,customlog:4,customsensor:6,customstep:[],customstepcbpi:8,cycl:8,data:7,databas:[0,4,6],decor:7,def:[0,4,5,6,7,8],default_callback:4,default_valu:5,defin:[7,8],delattr:[],delet:[],delete_al:[],descript:5,dir:[],directli:7,dirti:8,doc:7,document:7,documentaiton:7,doe:[],done:8,dummyactor:0,dummykettlelog:4,dummysensor:6,dummystep:8,dure:[0,4,5,6,8],earli:[],easili:7,els:4,end:[],endpoint:[2,8],event:[0,4,7,8],eventbu:2,exampel:6,exampl:[5,7,8],except:[4,7],exect:8,execut:[4,8],expos:[5,7],extend:[7,8],extens:[0,4,5,6],fals:[0,5,7,8],file:7,find:7,finish:4,fire:[6,7],first:8,flag:8,follow:7,force_db_upd:[],format:[],formatt:[],forward:7,framework:7,from:[0,4,5,6,8],futur:4,future_obj:4,gener:7,get_al:[],get_manged_fields_as_arrai:[],get_on:[],get_temp:4,get_traget_temp:4,get_valu:[4,6],getattr:[],git:3,github:3,goe:[0,5],gpio:[0,5],guidelin:2,handl:4,handle_act:8,handle_automtic_ev:4,handle_don:8,handle_next:8,handle_reset:8,handle_start:8,handle_stop:8,handler:8,has:8,hash:[],have:7,heater:4,heater_off:4,heater_on:4,hello:[4,7],help:[],helper:[],here:[0,4,5,6,7,8],how:[5,7],http:[2,3,8],http_action:8,http_add:[],http_api:6,http_delete_on:[],http_endpoint:6,http_get_al:[],http_get_on:[],http_next:8,http_off:[],http_on:7,http_reset:8,http_start:8,http_toggl:[],http_updat:[],httpapi:6,implement:[4,8],implementaion:8,imporant:7,info:7,inform:7,inherit:8,init:[0,4,6,8],initi:[0,4,6,8],initialis:4,instal:2,instanc:[0,4,6],int64:[],integ:0,interfac:2,interg:0,intern:6,interv:[6,8],invalid:[],invok:8,ip_address:7,is_dirti:8,issubclass:[],job_stop:4,json:[],just:7,keep:4,kei:[0,4,5,6,7,8],kettl:[2,5],kettle_control:4,kettle_id:4,kettle_log:4,kettlecontrol:2,kettlemodel:4,kwarg:[0,4,7,8],kwd:[0,4,6],label:[0,4,5,6,8],last:8,latest:7,least:8,list:5,listen:7,liten:[],log:[0,5,6],logic:[2,8],login:[],loop:4,loos:7,mai:[],main:[0,4,7],make:[3,7],manag:8,managed_field:8,manuel83:3,manuel:[],mayb:7,member:8,memori:[],messag:[7,8],met:[],method:[0,4,5,6,7,8],model:[0,4,6],modifi:8,modul:5,more:7,my_callback:4,myaction:[0,5,6],name:[0,4,5,6,8],need:[0,4,5,6,8],next:8,none:[0,4,5,6,7,8],normal:[],noth:[],notif:7,notifi:8,notimpl:[],number:[0,4,5,6,8],object:8,off:[0,4,5],on_ev:[4,7],one:8,onli:7,oper:[],option:5,org:7,other:[4,7],otherwis:8,outcom:[],overrid:[],overridden:[],overwritten:[4,8],param:[0,4,5,6,8],parament:7,paramet:[0,4,5,6,7,8],pass:[0,5,6,7],path:7,perform:7,persisit:8,pickl:[],pip:3,place:8,plain:[],pleas:3,plugin:[0,4,5,6,7,8],point:[],pong:[],port:7,power:[0,5,7],print:[0,4,5,6,8],process:[4,7,8],produc:[],properti:[0,2,4,6,8],propertytyp:[],provid:[0,8],push:7,put:8,pyhton:7,python:[2,3],random:6,reactj:7,readthedoc:7,redux:7,refer:[],regist:[0,4,5,6,8],repr:[],request:[7,8],request_map:7,requir:3,requset:8,reset:8,reset_dirti:8,respons:[4,7,8],rest:2,result:[4,7],run:[4,5,6,8],run_cycl:8,runtim:6,scan:5,schema:[],see:7,select:5,self:[0,4,5,6,7,8],sensor:[2,4,5],sensor_control:6,sensorcontrol:6,sensormodel:6,sensorontrol:[],server:[0,4,5,6,7,8],servic:[],session:7,set:5,set_result:4,setattr:[],setup:[0,4,5,6,8],should:[7,8],show:8,signatur:[],simpl:8,simplestep:[],size:[],sleep:[4,6,8],socket:7,some:7,stabl:7,standard:2,start:[4,8],startup:[0,4,5,6,7,8],state:[0,5,6],statu:7,step:[2,7],step_control:8,stepcontrol:2,stepmodel:[],stop:[4,6,8],str:[],string:4,structur:7,subclass:[],success:[],support:0,sure:[3,7],swagger:7,swtich:[0,5],system:5,tag:[],task:[],test:[0,4,5,6,8],text:[5,6,8],thi:[0,4,5,6,7,8],time:5,timeout:4,timeouterror:4,toggl:[0,4],toggle_automt:4,top:7,topic:[0,4,7,8],trigger:[],txt:3,type:[5,7],type_cfg:[],typic:[4,5,7],under:7,undoc:8,unit:5,unregist:4,updat:[],url:7,use:5,used:7,user:[0,2,5,6],using:7,valid:7,valu:[0,4,5,6,8],variabl:[5,6,8],version:[0,4,6,8],via:7,wai:7,wait:4,wait_for:4,wait_for_ev:4,weak:[],web:[2,8],web_respons:[],webpack:7,websocket:2,when:4,whether:7,which:[0,4,5,6,8],within:7,woohoo:8,world:7,yaml:[0,4,6,8],yes:8,you:[0,4,5,6,7,8],your:[0,4,5,6,8]},titles:["Actor","Core","Welcome to CraftBeerPi\u2019s documentation!","Installation","Kettle","Properties","Sensor","Standard & Guidelines","Brewing Step"],titleterms:{actor:[0,5],actorcontrol:0,api:7,architectur:0,brew:8,cbpiactor:0,cbpikettlelog:4,cbpisensor:6,cbpisimplestep:8,control:6,core:1,craftbeerpi:2,custom:[0,4,5,6,8],document:2,endpoint:7,eventbu:7,guidelin:7,http:7,instal:3,interfac:7,kettl:4,kettlecontrol:4,logic:4,properti:5,python:7,rest:7,sensor:6,sensorcontrol:[],sensorontrol:[],simplestep:[],standard:7,step:8,stepcontrol:8,user:7,web:7,websocket:7,welcom:2}}) \ No newline at end of file diff --git a/docs/standards.html b/docs/standards.html index ebe8094..12d93f3 100644 --- a/docs/standards.html +++ b/docs/standards.html @@ -88,6 +88,8 @@
    • Standard & Guidelines
      • Python
      • Web User Interface
      • @@ -162,7 +164,8 @@

        Standard & Guidelines

        Python

        -

        CraftBeerPi 4.x is based on Pyhton 3.7x. as main frameworks is aiohttp used.

        +

        CraftBeerPi 4.x is based on Pyhton 3.7x. +As a main framework CraftBeerPi is based on aiohttp

        @@ -186,6 +189,42 @@ This makes sure that all components are loosely coupled. New plugins can listen

        It’s imporante to add **kwargs as parameter to the listening method. This makes sure that maybe addtional event paramenter are not causing an exception.

        +
        +

        HTTP Endpoints

        +

        A new HTTP endpoints should be exposed by adding the @request_mapping decorator on top of an async method. +The path parameter defines the URL path. The auth_required defines whether the endpoint should be accessible public or within a user session only. +Typically you perform just some basing parameter validation and fire an event so that other components and controllers can perform some actions.

        +
        @request_mapping(path="/{id:\d+}/on", auth_required=False)
        +async def http_on(self, request) -> web.Response:
        +    self.cbpi.bus.fire(topic="actor/%s/switch/on" % id, id=id, power=99)
        +    return web.Response(status=204)
        +
        +
        +
        +

        Note

        +

        The Events are process in an async way. Results will be pushed to the client via WebSocket Event.

        +
        +
        +
        +

        WebSocket

        +

        The WebSocket is listening on http://<IP_ADDRESS>:<PORT>/ws +All events are forwarded to all connected web socket clients.

        +

        The WebSocket Event is having the following structure.

        +
          +
        • topic -> is the bus topic
        • +
        • data -> the event data
        • +
        +
        {
        +   "topic":"notification/step",
        +   "data":{
        +      "key":"step",
        +      "message":"Hello World",
        +      "type":"info"
        +      }
        +}
        +
        +
        +

        Web User Interface

        diff --git a/docs_src/source/standards.rst b/docs_src/source/standards.rst index 2d64928..2134fee 100644 --- a/docs_src/source/standards.rst +++ b/docs_src/source/standards.rst @@ -4,7 +4,8 @@ Standard & Guidelines Python ^^^^^^ -CraftBeerPi 4.x is based on Pyhton 3.7x. as main frameworks is `aiohttp` used. +CraftBeerPi 4.x is based on Pyhton 3.7x. +As a main framework CraftBeerPi is based on `aiohttp` * aioHTTP https://aiohttp.readthedocs.io/en/stable/ @@ -36,6 +37,49 @@ Here an example how listen on an event. It's imporante to add **kwargs as parameter to the listening method. This makes sure that maybe addtional event paramenter are not causing an exception. +HTTP Endpoints +-------------- + +A new HTTP endpoints should be exposed by adding the `@request_mapping` decorator on top of an async method. +The `path` parameter defines the URL path. The `auth_required` defines whether the endpoint should be accessible public or within a user session only. +Typically you perform just some basing parameter validation and fire an event so that other components and controllers can perform some actions. + +.. code-block:: python + + @request_mapping(path="/{id:\d+}/on", auth_required=False) + async def http_on(self, request) -> web.Response: + self.cbpi.bus.fire(topic="actor/%s/switch/on" % id, id=id, power=99) + return web.Response(status=204) + +.. note:: + + The Events are process in an async way. Results will be pushed to the client via WebSocket Event. + + +WebSocket +--------- + +The WebSocket is listening on `http://:/ws` +All events are forwarded to all connected web socket clients. + +The WebSocket Event is having the following structure. + +* topic -> is the bus topic +* data -> the event data + +.. code-block:: json + + { + "topic":"notification/step", + "data":{ + "key":"step", + "message":"Hello World", + "type":"info" + } + } + + + Web User Interface ^^^^^^^^^^^^^^^^^^ The Web UI is based on ReactJS + Redux.