mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-12-12 16:35:02 +01:00
GitBook: [doc] 2 pages modified
This commit is contained in:
parent
7fec8823c9
commit
8112ddfdb6
2 changed files with 23 additions and 14 deletions
|
@ -22,9 +22,9 @@ cbpi start
|
|||
|
||||
## Links
|
||||
|
||||
{% embed url="https://www.facebook.com/groups/craftbeerpi" caption="" %}
|
||||
{% embed url="https://www.facebook.com/groups/craftbeerpi" %}
|
||||
|
||||
{% embed url="https://www.youtube.com/channel/UCy47sYaG8YLwJWw2iY5\_aNg" caption="" %}
|
||||
{% embed url="https://www.youtube.com/channel/UCy47sYaG8YLwJWw2iY5\_aNg" %}
|
||||
|
||||
{% embed url="http://web.craftbeerpi.com" caption="" %}
|
||||
{% embed url="http://web.craftbeerpi.com" %}
|
||||
|
||||
|
|
|
@ -19,19 +19,27 @@ python3 -m pip insatll cbpi
|
|||
|
||||
### 2. Create Folder structure
|
||||
|
||||
|
||||
|
||||
### 3. Add Custom Code
|
||||
|
||||
|
||||
|
||||
### 4. Test the Code
|
||||
|
||||
|
||||
|
||||
### 3. Build plugin
|
||||
|
||||
|
||||
|
||||
### 4. Upload the plugin
|
||||
|
||||
### Full Example
|
||||
|
||||
[https://github.com/Manuel83/cbpi4-ui-plugin](https://github.com/Manuel83/cbpi4-ui-plugin)
|
||||
|
||||
## Sensor
|
||||
## Sensor
|
||||
|
||||
```python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
@ -52,13 +60,13 @@ Make sure to extend CBPiSensor
|
|||
Property.Sensor(label="Param4"),
|
||||
Property.Actor(label="Param5")])
|
||||
class CustomSensor(CBPiSensor):
|
||||
|
||||
|
||||
def __init__(self, cbpi, id, props):
|
||||
|
||||
|
||||
super(CustomSensor, self).__init__(cbpi, id, props)
|
||||
self.value = 0
|
||||
|
||||
|
||||
|
||||
@action(key="Test", parameters=[])
|
||||
async def action1(self, **kwargs):
|
||||
'''
|
||||
|
@ -75,7 +83,7 @@ class CustomSensor(CBPiSensor):
|
|||
self.value = random.randint(0,50)
|
||||
self.push_update(self.value)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
|
||||
def get_state(self):
|
||||
# return the current state of the sensor
|
||||
return dict(value=self.value)
|
||||
|
@ -86,7 +94,7 @@ 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:
|
||||
'''
|
||||
|
@ -96,6 +104,7 @@ def setup(cbpi):
|
|||
## Actor
|
||||
|
||||
```python
|
||||
|
||||
import logging
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
@ -132,10 +141,10 @@ class CustomActor(CBPiActor):
|
|||
print("ACTION !", kwargs)
|
||||
self.my_name = kwargs.get("name")
|
||||
pass
|
||||
|
||||
|
||||
def init(self):
|
||||
print("INIT")
|
||||
|
||||
|
||||
self.state = False
|
||||
pass
|
||||
|
||||
|
@ -148,9 +157,9 @@ class CustomActor(CBPiActor):
|
|||
self.state = False
|
||||
|
||||
def get_state(self):
|
||||
|
||||
|
||||
return self.state
|
||||
|
||||
|
||||
async def run(self):
|
||||
pass
|
||||
|
||||
|
@ -159,7 +168,7 @@ 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:
|
||||
'''
|
||||
|
|
Loading…
Reference in a new issue