From 8112ddfdb627ba38a0a554901367a4eb9021a845 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 26 Jan 2021 07:29:08 +0000 Subject: [PATCH] GitBook: [doc] 2 pages modified --- README.md | 6 +++--- development.md | 31 ++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8a7a655..66ba0b6 100644 --- a/README.md +++ b/README.md @@ -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" %} diff --git a/development.md b/development.md index a106ead..f441dc5 100644 --- a/development.md +++ b/development.md @@ -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: '''