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

60 lines
1.2 KiB
Python
Raw Normal View History

2018-11-04 00:47:26 +01:00
import logging
2018-11-01 19:50:04 +01:00
2018-11-16 20:35:59 +01:00
from core.api import CBPiActor, Property, action, background_task
2018-11-01 19:50:04 +01:00
2018-11-16 21:42:59 +01:00
class CustomActor(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):
2018-11-16 20:35:59 +01:00
print("OFF")
self.state = False
2018-11-01 19:50:04 +01:00
def on(self, power=100):
2018-11-16 20:35:59 +01:00
print("ON")
self.state = True
def __init__(self, cbpi=None):
2018-11-01 21:25:42 +01:00
if cbpi is None:
return
2018-11-16 20:35:59 +01:00
print("INIT MY ACTOR111111")
2018-11-01 21:25:42 +01:00
self.cfg = self.load_config()
2018-11-04 00:47:26 +01:00
2018-11-01 21:25:42 +01:00
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):
2018-11-16 21:42:59 +01:00
'''
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("CustomActor", CustomActor)