2019-01-28 22:21:31 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-11-18 15:40:10 +01:00
|
|
|
import asyncio
|
2021-01-22 23:25:20 +01:00
|
|
|
import random
|
|
|
|
import re
|
|
|
|
|
2019-01-14 07:33:59 +01:00
|
|
|
from aiohttp import web
|
2019-01-05 20:43:48 +01:00
|
|
|
from cbpi.api import *
|
2018-11-18 15:40:10 +01:00
|
|
|
|
2021-01-22 23:25:20 +01:00
|
|
|
|
|
|
|
@parameters([Property.Number(label="Param1", configurable=True),
|
|
|
|
Property.Text(label="Param2", configurable=True, default_value="HALLO"),
|
|
|
|
Property.Select(label="Param3", options=[1,2,4]),
|
|
|
|
Property.Sensor(label="Param4"),
|
|
|
|
Property.Actor(label="Param5")])
|
2021-01-23 14:41:26 +01:00
|
|
|
class CustomSensor(CBPiSensor):
|
2021-01-22 23:25:20 +01:00
|
|
|
|
|
|
|
@action(key="Test", parameters=[])
|
|
|
|
async def action1(self, **kwargs):
|
|
|
|
print("ACTION!", kwargs)
|
|
|
|
|
|
|
|
@action(key="Test1", parameters=[])
|
|
|
|
async def action2(self, **kwargs):
|
|
|
|
print("ACTION!", kwargs)
|
|
|
|
|
|
|
|
@action(key="Test2", parameters=[])
|
|
|
|
async def action3(self, **kwargs):
|
|
|
|
print("ACTION!", kwargs)
|
|
|
|
|
|
|
|
async def run(self):
|
|
|
|
|
|
|
|
while self.running is True:
|
|
|
|
print("HALLO")
|
|
|
|
await asyncio.sleep(1)
|
|
|
|
|
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:
|
|
|
|
'''
|
2021-01-23 14:41:26 +01:00
|
|
|
cbpi.plugin.register("CustomSensor", CustomSensor)
|