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

38 lines
743 B
Python
Raw Normal View History

2018-11-18 15:40:10 +01:00
import asyncio
from core.api import Property
from core.api.kettle_logic import CBPiKettleLogic
class CustomLogic(CBPiKettleLogic):
2018-11-18 23:09:17 +01:00
test = Property.Number(label="Test")
2018-11-18 15:40:10 +01:00
running = True
async def run(self):
while self.running:
2018-11-18 23:09:17 +01:00
print("RUN", self.test)
value = await self.cbpi.sensor.get_value(1)
print(value)
if value >= 10:
break
2018-11-18 15:40:10 +01:00
await asyncio.sleep(1)
2018-11-18 23:09:17 +01:00
print("STOP LOGIC")
2018-11-18 15:40:10 +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:
'''
cbpi.plugin.register("CustomKettleLogic", CustomLogic)