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

40 lines
775 B
Python
Raw Normal View History

2018-12-03 22:16:03 +01:00
import asyncio
2019-01-05 20:43:48 +01:00
from cbpi.api import *
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):
2019-01-04 09:29:09 +01:00
print("RUN", self.name)
2018-12-07 23:57:32 +01:00
self.i = self.i + 1
2019-01-21 22:33:29 +01:00
await asyncio.sleep(5)
print("WAIT")
self.next()
#if self.i == 5:
2019-01-04 09:29:09 +01:00
# print("NEXT")
2019-01-21 22:33:29 +01:00
2019-01-04 09:29:09 +01:00
#self.cbpi.notify(key="step", message="HELLO FROM STEP")
2018-12-29 00:27:19 +01:00
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)