forked from switchdoclabs/SDL_Pi_SkyWeather2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WeatherRack2Array.py
33 lines (24 loc) · 992 Bytes
/
WeatherRack2Array.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
# handles updating the WeatherRack2 Sensor Dictionary
import state
import datetime
def addWR2Reading(WR2JSON):
if (len(state.MWR2Array) > 0):
# check existing records, update if found
for singleChannel in state.MWR2Array:
if (singleChannel["id"] == WR2JSON['id']):
#print("update MWR2Array")
state.MWR2Array.remove (singleChannel)
state.MWR2Array.append(WR2JSON)
#print("-----------------")
#print ("state.MWR2ArrayUpdate=",state.MWR2Array)
#print("-----------------")
return
state.MWR2Array.append(WR2JSON)
#print("-----------------")
#print ("state.MWR2Array=",state.MWR2Array)
#print("-----------------")
else:
state.MWR2Array.append(WR2JSON)
#print("-----------------")
#print ("state.MWR2Array=",state.MWR2Array)
#print("-----------------")