-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
38 lines (35 loc) · 1.25 KB
/
models.py
File metadata and controls
38 lines (35 loc) · 1.25 KB
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
import logging
class Sensor:
def __init__(self, name, description, value, unit):
self.description = description
self.name = name
self.value = value
self.unit = unit
# self.label = Label(name=self.name, text="{}: {}{}".format(self.description, self.value, self.unit), fg="#000000")
def updateValue(self, value):
self.value = value
return "{}: {}{}".format(self.description, self.value, self.unit)
class Btn():
def __init__(self, name, description, number,):
self.name = name
self.description = description
self.number = number
self.on_color = "#16DC0F"
self.off_color = "#DC0F16"
self.error_color= "#000000"
self.color = self.off_color
self.name = name
self.text = description
self.number = number
self.is_on = False
def updateState(self, value):
logging.debug("updateState: {} of type {}".format(value, type(value)))
if (int(value) == 0):
self.is_on = False
self.color = self.off_color
elif (int(value) == 1):
self.is_on = True
self.color = self.on_color
else:
self.color = self.error_color
return self.color