-
Notifications
You must be signed in to change notification settings - Fork 14
/
state.py
253 lines (165 loc) · 5.65 KB
/
state.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#
# Contains State Variables
#
# FT0300 Invalid Statements
# Invalid data / null / max / min defines
INVALID_DATA_8 = 0x7a # Invalid value (corresponding to 8bit value)
INVALID_DATA_16 = 0x7ffa # Invalid value (corresponding to 16bit value)
INVALID_DATA_32 = 0x7ffffffa # Invalid value (corresponding to 32bit value)
NULL_DATA_8 = 0x7b # Indicates that the field does not exist
NULL_DATA_16 = 0x7ffb
NULL_DATA_32 = 0x7ffffffb
LOW_DATA_8 = 0x7c # Means less than the minimum value that can be expressed
LOW_DATA_16 = 0x7ffc
LOW_DATA_32 = 0x7ffffffc
HIGH_DATA_8 = 0x7d # Means greater than the maximum value that can be expressed
HIGH_DATA_16 = 0x7ffd
HIGH_DATA_32 = 0x7ffffffd
# 0x7e, 0x7f skip
# ===============================================================================
# Maximum and minimum
# ===============================================================================
TEMP_MIN_F = 0 # -40.0F, offset 40.0F
TEMP_MAX_F = 1800 # 140.0F, offset 40.0F
HUMI_MIN = 10 # 10%
HUMI_MAX = 99 # 99%
WIND_MAX = 500 # 50.0m/s
RAIN_MAX = 99999 # 9999.9mm
# WeatherSTEM info
WeatherSTEMHash = ""
# Weather Variable Sensor Reads
######################
# Weather State Variables
######################
# JSON state record
StateJSON = ""
# Weather Variable Sensor Reads
lastMainReading ="Never"
lastIndoorReading = "Never"
previousMainReading = "Never"
previousIndoorReading = "Never"
mainID = ""
insideID = ""
# Weather Variables
OutdoorTemperature = 0.0
OutdoorHumidity = 0.0
IndoorTemperature = 0.0
IndoorHumidity = 0.0
Rain60Minutes = 0.0
SunlightVisible = 0.0
SunlightUVIndex = 0.0
WindSpeed = 0
WindGust = 0
WindDirection = 0.2
TotalRain = 0
BarometricTemperature = 0
BarometricPressure = 0
Altitude = 0
BarometricPressureSeaLevel = 0
BarometricTemperature = 0
barometricTrend = True
pastBarometricReading = 0
AQI = 0.0
Hour24_AQI = 0.0
# WeatherSense AQI Values
WS_AQI = 0.0
WS_Hour24_AQI = 0.0
BatteryOK = "OK"
CPUTemperature = 0.0
SerialNumber = 0
RSSI = 0.0
SNR = 0.0
NOISE = 0.0
# Multiple WeatherRack2 Array
MWR2Array = []
# Indoor Temperature Sensor Array
IndoorTH = []
# status Values
Last_Event = "My Last Event"
# Button Variables
runRainbow = False
flashStrip = False
runOLED = True
# status Values
Last_Event = "My Last Event"
# Solar Values
batteryVoltage = 0
batteryCurrent = 0
solarVoltage = 0
solarCurrent = 0
loadVoltage = 0
loadCurrent = 0
batteryPower = 0
solarPower = 0
loadPower = 0
batteryCharge = 0
SolarMAXLastReceived = "Never"
SolarMaxInsideTemperature = 0.0
SolarMaxInsideHumidity = 0.0
# Fan State
fanState = False
def printState():
print ("-------------")
print ("Current State")
print ("-------------")
print ("-------------")
print("latest MainSensor Reading=", lastMainReading)
print("MainDeviceNumber=", mainID)
print("OutdoorTemperature = ",OutdoorTemperature )
print("OutdoorHumidity = ", OutdoorHumidity )
print("latest Indoor Sensor Reading=", lastIndoorReading)
print("IndoorDeviceNumber=", insideID)
print("IndoorTemperature = ",IndoorTemperature)
print("IndoorHumidity = ", IndoorHumidity )
print("Rain60Minutes = ", Rain60Minutes )
print("SunlightVisible = ", SunlightVisible )
print("SunlightUVIndex = ", SunlightUVIndex )
print("WindSpeed = ", WindSpeed)
print("WindGust = ", WindGust )
print("WindDirection = ", WindDirection )
print("TotalRain = ", TotalRain )
print ("BarometricTemperature = ", BarometricTemperature )
print ("BarometricPressure = ", BarometricPressure )
print ("Altitude = ", Altitude )
print ("BarometricPressureSeaLevel = ", BarometricPressureSeaLevel )
print ("BarometricTemperature = ", BarometricTemperature )
print ("barometricTrend =",barometricTrend )
print ("pastBarometricReading = ", pastBarometricReading )
print ("AQI = ", AQI )
print ("Hour24_AQI = ", Hour24_AQI )
print ("WS_AQI = ", WS_AQI )
print ("WS_Hour24_AQI = ", WS_Hour24_AQI )
print ("Main Battery Status = ", BatteryOK )
print ("CPU Temperature = ", CPUTemperature )
print ("Serial Number = ", SerialNumber )
print ("RSSI = ", RSSI )
print ("SNR = ", SNR )
print ("NOISE = ", NOISE )
print ("-------------")
print ("runRainbow = ", runRainbow )
print ("flashStrip = ", flashStrip )
print ("runOLED =", runOLED )
print ("-------------")
print ("Last_Event = ", Last_Event )
print ("-------------")
print ("batteryVoltage", batteryVoltage )
print ("batteryCurrent", batteryCurrent)
print ("solarVoltage", solarVoltage )
print ("solarCurrent", solarCurrent)
print ("loadVoltage", loadVoltage)
print ("loadCurrent", loadCurrent)
print ("batteryPower", batteryPower)
print ("solarPower", solarPower)
print ("loadPower", loadPower)
print ("batteryCharge", batteryCharge)
print ("SolarMAX Inside Temperature", SolarMaxInsideTemperature)
print ("SolarMAX Inside Humidity", SolarMaxInsideHumidity)
print ("SolarMAX Last Received", SolarMAXLastReceived)
print ("-------------")
print ("-------------")
print ("-------------")
print ("fanState = ", fanState)
print ("-------------")
import threading
buildJSONSemaphore = threading.Semaphore()
mqtt_client = None