craftbeerpi4-pione/cbpi/api/fermenter_logic.py
avollkopf d7c1b64493 Added Fermenters (development)
Added fermenter type
Added fermenter logic (incl. new class)
-> will require cbpi4ui -> >= 0.1.a1

Still under development, but fermentation w/o steps should be working
2022-01-02 11:25:56 +01:00

51 lines
1,020 B
Python

from cbpi.api.base import CBPiBase
from cbpi.api.extension import CBPiExtension
from abc import ABCMeta
import logging
import asyncio
class CBPiFermenterLogic(CBPiBase, metaclass=ABCMeta):
def __init__(self, cbpi, id, props):
self.cbpi = cbpi
self.id = id
self.props = props
self.state = False
self.running = False
def init(self):
pass
async def on_start(self):
pass
async def on_stop(self):
pass
async def run(self):
pass
async def _run(self):
try:
await self.on_start()
self.cancel_reason = await self.run()
except asyncio.CancelledError as e:
pass
finally:
await self.on_stop()
def get_state(self):
return dict(running=self.state)
async def start(self):
self.state = True
async def stop(self):
self.task.cancel()
await self.task
self.state = False