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

53 lines
1.1 KiB
Python
Raw Normal View History

2018-12-03 22:16:03 +01:00
import asyncio
2019-01-28 22:21:31 +01:00
import time
2018-12-03 22:16:03 +01:00
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
2019-01-28 22:21:31 +01:00
name1 = Property.Number(label="Test", configurable=True)
timer_end = Property.Number(label="Test", default_value=None)
temp = Property.Number(label="Temperature", default_value=50, configurable=True)
2019-07-27 21:08:19 +02: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
2019-07-27 21:08:19 +02:00
def get_status(self):
return "Status: %s Temp" % self.temp
2019-01-28 22:21:31 +01:00
2018-12-07 23:57:32 +01:00
async def run_cycle(self):
2019-07-27 21:08:19 +02:00
self.next()
'''
2019-01-28 22:21:31 +01:00
print("RUN", self.name1, self.managed_fields, self.timer_end)
2018-12-07 23:57:32 +01:00
self.i = self.i + 1
2019-01-28 22:21:31 +01:00
if self.timer_end is None:
self.timer_end = time.time() + 10
if self.i == 10:
self.next()
2019-07-27 21:08:19 +02:00
'''
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)