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

49 lines
1 KiB
Python
Raw Normal View History

2018-11-01 19:50:04 +01:00
from core.database.model import ActorModel
from core.api.decorator import action, background_task
from core.api.property import Property
2018-11-01 21:25:42 +01:00
from core.api.actor import CBPiActor
import logging
2018-11-01 19:50:04 +01:00
2018-11-01 21:25:42 +01:00
class MyActor(CBPiActor):
2018-11-01 19:50:04 +01:00
name = Property.Number(label="Test")
name1 = Property.Text(label="Test")
name2 = Property.Kettle(label="Test")
@background_task("s1", interval=2)
async def bg_job(self):
print("WOOH BG")
@action(key="name", parameters={})
def myAction(self):
2018-11-01 21:25:42 +01:00
pass
2018-11-01 19:50:04 +01:00
def state(self):
super().state()
def off(self):
super().off()
def on(self, power=100):
super().on(power)
2018-11-01 21:25:42 +01:00
def __init__(self,cbpi=None):
if cbpi is None:
return
self.cfg = self.load_config()
print(self.cfg)
self.logger = logging.getLogger(__file__)
logging.basicConfig(level=logging.INFO)
2018-11-01 19:50:04 +01:00
2018-11-01 21:25:42 +01:00
self.logger.info("########WOOHOO MY ACTOR")
self.cbpi = cbpi
2018-11-01 19:50:04 +01:00
def setup(cbpi):
cbpi.actor.register("MyActor", MyActor)