forked from enesbcs/rpieasy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.py
74 lines (60 loc) · 1.98 KB
/
controller.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
#############################################################################
########################## CONTROLLER skeleton ##############################
#############################################################################
#
# Copyright (C) 2018-2019 by Alexander Nagy - https://bitekmindenhol.blog.hu/
#
class ControllerProto:
CONTROLLER_ID = -1
CONTROLLER_NAME = "Controller"
def __init__(self,controllerindex):
self.enabled = False
self.controllerip="0.0.0.0"
self.controllerport=80
self.controlleruser=""
self.controllerpassword=""
self.initialized = False
self.controllerid = self.CONTROLLER_ID
self.controllerindex = controllerindex
self.usesID = False
self.connected = False
self.onmsgcallbacksupported = False
self.onmsgcallbackfunc = None
self.usesAccount = False
self.usesPassword = False
self.usesMQTT = False
self.timer30s = False
def getcontrollerid(self):
return self.controllerid
def getcontrollername(self):
return self.CONTROLLER_NAME
def getcontrollerindex(self):
return self.controllerindex
def controller_init(self,enablecontroller=None):
if enablecontroller != None:
self.enabled = enablecontroller
self.connect()
self.initialized = True
return True
def connect(self):
self.connected = True
return True
def disconnect(self):
self.connected = False
return True
def isconnected(self):
return self.connected
def senddata(self,idx,sensortype,value,userssi=-1,usebattery=-1):
return True
def setonmsgcallback(self,callbackfunc):
if self.onmsgcallbacksupported:
self.onmsgcallbackfunc = callbackfunc # call onmsgcallbackfunc if controller able to send data to the plugin
def controller_exit(self):
self.disconnect()
def webform_load(self): # create html page for settings
return ""
def webform_save(self,params): # process settings post reply
return True
def timer_thirty_second(self): # implement and set self.timer30s to true if you want to use
return self.timer30s