mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-12 18:27:47 +01:00
35 lines
748 B
Python
35 lines
748 B
Python
from cbpi.api.base import CBPiBase
|
|
from cbpi.api.extension import CBPiExtension
|
|
from abc import ABCMeta
|
|
import logging
|
|
import asyncio
|
|
|
|
|
|
|
|
class CBPiKettleLogic(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 run(self):
|
|
self.state = True
|
|
while self.running:
|
|
await asyncio.sleep(1)
|
|
self.state = False
|
|
|
|
def get_state(self):
|
|
return dict(running=self.running)
|
|
|
|
async def start(self):
|
|
self.running = True
|
|
|
|
async def stop(self):
|
|
self.task.cancel()
|
|
await self.task
|