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
|
|
|
|
|
|
|
|
2021-01-22 23:25:20 +01:00
|
|
|
@parameters([Property.Number(label="Param1", configurable=True),
|
|
|
|
Property.Text(label="Param2", configurable=True, default_value="HALLO"),
|
|
|
|
Property.Select(label="Param3", options=[1,2,4]),
|
|
|
|
Property.Sensor(label="Param4"),
|
|
|
|
Property.Actor(label="Param5")])
|
2021-01-17 22:49:18 +01:00
|
|
|
class Step2(CBPiStep):
|
|
|
|
|
2021-01-22 23:25:20 +01:00
|
|
|
@action(key="name2", parameters=[])
|
|
|
|
async def action2(self, **kwargs):
|
|
|
|
print("CALL ACTION")
|
2021-01-17 22:49:18 +01:00
|
|
|
|
|
|
|
@action(key="name", parameters=[Property.Number(label="Test", configurable=True)])
|
|
|
|
async def action(self, **kwargs):
|
2021-01-22 23:25:20 +01:00
|
|
|
print("CALL ACTION")
|
2021-01-17 22:49:18 +01:00
|
|
|
|
|
|
|
async def execute(self):
|
2021-01-22 23:25:20 +01:00
|
|
|
count = self.props.get("count", 0)
|
|
|
|
self.state_msg = "COUNT %s" % count
|
2021-01-17 22:49:18 +01:00
|
|
|
|
2021-01-22 23:25:20 +01:00
|
|
|
self.props["count"] += 1
|
2021-01-17 22:49:18 +01:00
|
|
|
await self.update(self.props)
|
2018-12-03 22:16:03 +01:00
|
|
|
|
2021-01-22 23:25:20 +01:00
|
|
|
if count >= 5:
|
|
|
|
self.next()
|
|
|
|
|
|
|
|
async def reset(self):
|
|
|
|
self.props["count"] = 0
|
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:
|
|
|
|
'''
|
2021-01-17 22:49:18 +01:00
|
|
|
cbpi.plugin.register("CustomStep2", Step2)
|
2021-01-22 23:25:20 +01:00
|
|
|
|