-
Notifications
You must be signed in to change notification settings - Fork 14
/
indoorTH.py
37 lines (28 loc) · 1.23 KB
/
indoorTH.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
# handles updating the IT Sensor Dictionary
import state
import datetime
def buildITReading (DeviceID, ChannelID, Temperature, Humidity, BatteryOK, time):
newchannel = {}
newchannel["deviceID"] = DeviceID
newchannel["channelID"] = ChannelID
newchannel["temperature"] = Temperature
newchannel["humidity"] = Humidity
newchannel["batteryOK"] = BatteryOK
newchannel["time"] = time
state.IndoorTH.append(newchannel)
#print("built IndoorIH")
def addITReading(DeviceID, ChannelID, Temperature, Humidity, BatteryOK, Time):
if (len(state.IndoorTH) > 0):
# check existing records, update if found
for singleChannel in state.IndoorTH:
if (singleChannel["channelID"] == ChannelID):
#print("update IndoorIH")
singleChannel["deviceID"] = DeviceID
singleChannel["temperature"] = Temperature
singleChannel["humidity"] = Humidity
singleChannel["batteryOK"] = BatteryOK
singleChannel["time"] = Time
#print ("state.IndoorTH=",state.IndoorTH)
return
buildITReading(DeviceID, ChannelID, Temperature, Humidity, BatteryOK, Time)
#print ("state.IndoorTH=",state.IndoorTH)