craftbeerpi4-pione/core/extension/dummystep/__init__.py

36 lines
756 B
Python
Raw Normal View History

2018-12-03 22:16:03 +01:00
import asyncio
from core.api import Property, action
2018-12-10 22:13:28 +01:00
from core.api.step import CBPiSimpleStep
2018-12-03 22:16:03 +01:00
2018-12-10 22:13:28 +01:00
class CustomStepCBPi(CBPiSimpleStep):
2018-12-03 22:16:03 +01:00
2018-12-05 07:31:12 +01:00
name = Property.Number(label="Test")
2018-12-08 14:21:00 +01:00
2018-12-07 23:57:32 +01:00
i = 0
@action(key="name", parameters=None)
def test(self, **kwargs):
self.name="WOOHOO"
2018-12-05 07:31:12 +01:00
2018-12-07 23:57:32 +01:00
async def run_cycle(self):
2018-12-05 07:31:12 +01:00
#await asyncio.sleep(1)
2018-12-07 23:57:32 +01:00
self.i = self.i + 1
2018-12-10 22:13:28 +01:00
self.cbpi.notify(key="step", message="OH YES")
2018-12-05 07:31:12 +01:00
print("RUN STEP", self.id, self.name, self.__dict__)
2018-12-03 22:16:03 +01:00
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:
'''
2018-12-10 22:13:28 +01:00
cbpi.plugin.register("CustomStepCBPi", CustomStepCBPi)