-
Notifications
You must be signed in to change notification settings - Fork 2
/
updateBlynk.py
executable file
·541 lines (426 loc) · 22.4 KB
/
updateBlynk.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
# provides routine to update SGS Blynk Display
import time
import requests
import json
import util
import state
import traceback
# Check for user imports
try:
import conflocal as config
except ImportError:
import config
DEBUGBLYNK = config.DEBUGBLYNK
def stopFlash():
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V30?value=0')
def blynkInit():
# initalize button states
try:
print ("Entering blynkInit debug mode: " + str(DEBUGBLYNK))
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V5?value=0', timeout=10)
if (state.runOLED == True):
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V6?value=1', timeout=10)
else:
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V6?value=0', timeout=10)
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V30?value=0', timeout=10)
# initialize LEDs
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V42?value=255', timeout=10)
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V43?value=255', timeout=10)
# read english Metric in from file
try:
f = open("/home/pi/SDL_Pi_SkyWeather/state/EnglishMetric.txt", "r")
value = int(f.read())
f.close()
except Exception as e:
value = 0
#print "initial state - no EnglishMetric.txt value=", value
f1 = open("/home/pi/SDL_Pi_SkyWeather/state/EnglishMetric.txt", "w")
f1.write("0")
f1.close()
state.EnglishMetric = value
if (DEBUGBLYNK):
print ("state.EnglishMetric = ", value)
if (state.EnglishMetric == 0):
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V8?value=0')
else:
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V8?value=1')
if (DEBUGBLYNK):
print ("Exiting blynkInit:")
except Exception as e:
print ("exception in blynkInit")
print (e)
return 0
def blynkResetButton(buttonNumber):
try:
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/'+buttonNumber+'?value=0')
except Exception as e:
print ("exception in blynkResetButton")
print (e)
return 0
def blynkEventUpdate(Event):
try:
put_header={"Content-Type": "application/json"}
val = Event
put_body = json.dumps([val])
if (DEBUGBLYNK):
print ("blynkEventUpdate:",val)
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V31', data=put_body, headers=put_header, timeout=10)
if (DEBUGBLYNK):
print ("blynkEventUpdate:POST:r.status_code:",r.status_code)
return 1
except Exception as e:
print ("exception in blynkEventUpdate")
print (e)
return 0
def blynkStatusTerminalUpdate(entry):
try:
put_header={"Content-Type": "application/json"}
entry = time.strftime("%Y-%m-%d %H:%M:%S")+": "+entry+"\n"
put_body = json.dumps([entry])
if (DEBUGBLYNK):
print ("blynkStateUpdate:Pre:put_body:",put_body)
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V32', data=put_body, headers=put_header, timeout=10)
if (DEBUGBLYNK):
print ("blynkStateUpdate:POST:r.status_code:",r.status_code)
except Exception as e:
print ("exception in blynkTerminalUpdate")
print (e)
return 0
def blynkSolarMAXLine(entry, protocol):
try:
put_header={"Content-Type": "application/json"}
put_body = json.dumps([entry])
if (DEBUGBLYNK):
print ("blynkSolarMAXUpdate:Pre:put_body:",put_body)
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V75', data=put_body, headers=put_header, timeout=10)
if (DEBUGBLYNK):
print ("blynkSolarMAXUpdate:POST:r.status_code:",r.status_code)
except Exception as e:
print ("exception in blynkSolarMAXUpdate")
print (e)
return 0
def blynkSolarTerminalUpdate(entry):
try:
put_header={"Content-Type": "application/json"}
entry = time.strftime("%Y-%m-%d %H:%M:%S")+": "+entry+"\n"
put_body = json.dumps([entry])
if (DEBUGBLYNK):
print ("blynkStateUpdate:Pre:put_body:",put_body)
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V33', data=put_body, headers=put_header, timeout=10)
if (DEBUGBLYNK):
print ("blynkStateUpdate:POST:r.status_code:",r.status_code)
except Exception as e:
print ("exception in blynkTerminalUpdate")
print (e)
return 0
def blynkUpdateImage():
#Blynk.setProperty(V1, "urls", "https://image1.jpg", "https://image2.jpg");
try:
if (DEBUGBLYNK):
print ("blynkUpdateImage:started")
"""
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V70?value=2') # Picture URL
if (DEBUGBLYNK):
print "blynkUpdateImage:OTHER:r.status_code:",r.status_code
#r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V70?urls=http://www.switchdoc.com/2.jpg') # Picture URL
#r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V70?urls=http://www.switchdoc.com/skycamera.jpg,http://www.switchdoc.com/2.jpg') # Picture URL
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V70?value=1;url=http://www.switchdoc.com/skycamera.jpg')
if (DEBUGBLYNK):
print "blynkUpdateImage:OTHER:r.status_code:",r.status_code
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V70?value=2;url=http://www.switchdoc.com/2.jpg') # Picture URL
if (DEBUGBLYNK):
print "blynkUpdateImage:OTHER:r.status_code:",r.status_code
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V70?value=2') # Picture URL
if (DEBUGBLYNK):
print "blynkUpdateImage:OTHER:r.status_code:",r.status_code
"""
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V70?urls=http://www.switchdoc.com/SkyWeatherNoAlpha.png', timeout=10) # Picture URL
except Exception as e:
print ("exception in blynkUpdateImage")
print (e)
return 0
def blynkStateUpdate():
try:
blynkUpdateImage()
put_header={"Content-Type": "application/json"}
# set last sample time
put_header={"Content-Type": "application/json"}
val = time.strftime("%Y-%m-%d %H:%M:%S")
put_body = json.dumps([val])
if (DEBUGBLYNK):
print ("blynkEventUpdate:",val)
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V44', data=put_body, headers=put_header, timeout=20)
if (DEBUGBLYNK):
print ("blynkEventUpdate:POST:r.status_code:",r.status_code)
# do the graphs
val = state.Outdoor_AirQuality_Sensor_Value
put_body = json.dumps([val])
if (DEBUGBLYNK):
print ("blynkStateUpdate:Pre:put_body:",put_body)
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V7', data=put_body, headers=put_header, timeout=10)
if (DEBUGBLYNK):
print ("blynkStateUpdate:POST:r.status_code:",r.status_code)
val = util.returnTemperatureCF(state.currentOutsideTemperature)
tval = "{0:0.1f} ".format(val) + util.returnTemperatureCFUnit()
put_body = json.dumps([tval])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V0', data=put_body, headers=put_header, timeout=10)
val = util.returnTemperatureCF(state.currentOutsideTemperature)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V10', data=put_body, headers=put_header, timeout=10)
val = state.currentOutsideHumidity
put_body = json.dumps(["{0:0.1f}%".format(val)])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V1', data=put_body, headers=put_header, timeout=10)
val = state.currentOutsideHumidity
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V11', data=put_body, headers=put_header, timeout=10)
val = util.returnTemperatureCF(state.currentInsideTemperature)
tval = "{0:0.1f} ".format(val) + util.returnTemperatureCFUnit()
put_body = json.dumps([tval])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V21', data=put_body, headers=put_header, timeout=10)
val = util.returnTemperatureCF(state.currentInsideTemperature)
tval = "{0:0.1f}".format(val)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V120', data=put_body, headers=put_header, timeout=10)
val = state.currentInsideHumidity
put_body = json.dumps(["{0:0.1f}%".format(val)])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V13', data=put_body, headers=put_header, timeout=10)
val = state.currentInsideHumidity
put_body = json.dumps(["{0:0.1f}".format(val)])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V121', data=put_body, headers=put_header, timeout=10)
dewpoint = state.currentOutsideTemperature - ((100.0 - state.currentOutsideHumidity) / 5.0)
put_body = json.dumps(["{0:0.1f}".format(util.returnTemperatureCF(dewpoint)) + util.returnTemperatureCFUnit()])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V12', data=put_body, headers=put_header, timeout=10)
if (state.fanState == False):
val = 0
else:
val = 1
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V122', data=put_body, headers=put_header, timeout=10)
#wind
val = util.returnWindSpeed(state.ScurrentWindSpeed)
tval = "{0:0.1f}".format(val) + util.returnWindSpeedUnit()
put_body = json.dumps([tval])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V9', data=put_body, headers=put_header, timeout=10)
#now humiidyt
#val = util.returnWindSpeed(state.ScurrentWindSpeed)
val = state.currentOutsideHumidity
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V19', data=put_body, headers=put_header, timeout=10)
# outdoor Air Quality
val = state.Outdoor_AirQuality_Sensor_Value
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V20', data=put_body, headers=put_header, timeout=10)
#wind direction
val = "{0:0.0f}/".format(state.ScurrentWindDirection) + util.returnWindDirection(state.ScurrentWindDirection)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V2', data=put_body, headers=put_header, timeout=10)
#rain
# val = "{0:0.2f}".format(state.currentTotalRain)
if (state.EnglishMetric == 1):
tval = "{0:0.2f}mm".format(state.currentTotalRain)
else:
tval = "{0:0.2f}in".format(state.currentTotalRain / 25.4)
put_body = json.dumps([tval])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V3', data=put_body, headers=put_header, timeout=10)
#rain last hour
# val = "{0:0.2f}".format(state.currentRain60Minutes)
if (state.EnglishMetric == 1):
tval = "{0:0.2f}mm".format(state.currentRain60Minutes)
else:
tval = "{0:0.2f}in".format(state.currentRain60Minutes / 25.4)
put_body = json.dumps([tval])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V14', data=put_body, headers=put_header, timeout=10)
#rain rate
# val = "{0:0.2f}".format(state.currentRain60Minutes)
if (state.EnglishMetric == 1):
tval = "{0:0.2f}mm".format(state.currentRainRate)
else:
tval = "{0:0.2f}in".format(state.currentRainRate / 25.4)
put_body = json.dumps([tval])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V15', data=put_body, headers=put_header, timeout=10)
#Sunlight
val = "{0:0.0f}".format(state.currentSunlightVisible)
#print ("Sunlight Val = ", state.currentSunlightVisible)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V4', data=put_body, headers=put_header, timeout=10)
#barometric Pressure
if (state.EnglishMetric == 1):
tval = "{0:0.2f}hPa".format(state.currentSeaLevel)
else:
tval = "{0:0.2f}in".format((state.currentSeaLevel * 0.2953)/10.0)
put_body = json.dumps([tval])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V40', data=put_body, headers=put_header, timeout=10)
#barometric Pressure graph
if (state.EnglishMetric == 1):
tval = "{0:0.2f}".format(state.currentSeaLevel)
else:
tval = "{0:0.2f}".format((state.currentSeaLevel * 0.2953)/10.0)
put_body = json.dumps([tval])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V41', data=put_body, headers=put_header, timeout=10)
#solar data
val = "{0:0.2f}".format(state.solarVoltage)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V50', data=put_body, headers=put_header, timeout=10)
val = "{0:0.1f}".format(state.solarCurrent)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V51', data=put_body, headers=put_header, timeout=10)
val = "{0:0.2f}".format(state.batteryVoltage)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V52', data=put_body, headers=put_header, timeout=10)
val = "{0:0.1f}".format(state.batteryCurrent)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V53', data=put_body, headers=put_header, timeout=10)
val = "{0:0.2f}".format(state.loadVoltage)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V54', data=put_body, headers=put_header, timeout=10)
val = "{0:0.1f}".format(state.loadCurrent)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V55', data=put_body, headers=put_header, timeout=10)
val = "{0:0.1f}W".format(state.batteryPower)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V60', data=put_body, headers=put_header, timeout=10)
val = "{0:0.1f}W".format(state.solarPower)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V61', data=put_body, headers=put_header, timeout=10)
val = "{0:0.1f}W".format(state.loadPower)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V62', data=put_body, headers=put_header, timeout=10)
if (config.SolarMAX_Present == True):
val = util.returnTemperatureCF(state.SolarMaxInsideTemperature)
tval = "{0:0.1f} ".format(val) + util.returnTemperatureCFUnit()
put_body = json.dumps([tval])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V76', data=put_body, headers=put_header, timeout=10)
val = "{0:0.1f}%".format(state.SolarMaxInsideHumidity)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V77', data=put_body, headers=put_header, timeout=10)
val = "{0:0.1f}".format(state.batteryCharge)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V56', data=put_body, headers=put_header, timeout=10)
val = "{0:0.1f}".format(state.batteryCharge)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V127', data=put_body, headers=put_header, timeout=10)
delta = util.returnTemperatureCF(state.currentInsideTemperature)- util.returnTemperatureCF(state.currentOutsideTemperature)
val = "{0:0.1f}".format(delta)
put_body = json.dumps([val])
r = requests.put(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V128', data=put_body, headers=put_header, timeout=10)
# LEDs
if (DEBUGBLYNK):
print ("BarometricTrend: ", state.barometricTrend)
#if (state.barometricTrend): #True is up, False is down
if (state.barometricTrend == 0):
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V42?color=%23FFFFFF', timeout=10) # White
elif (state.barometricTrend == 1):
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V42?color=%2300FF00', timeout=10) # Green
else:
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V42?color=%23FF0000', timeout=10) # red
if (DEBUGBLYNK):
print ("blynkBarometricTrendUpdate:OTHER:r.status_code:",r.status_code)
print ("lightning at: ", state.currentAs3935LastLightningTimeStamp, " time: ", time.time() - state.currentAs3935LastLightningTimeStamp)
if (time.time() - state.currentAs3935LastLightningTimeStamp > 1800):
print ("time elasped since last strike")
state.currentAs3935LastLightningTimeStamp = 0
if (state.currentAs3935LastLightningTimeStamp == 0): #True is lightning, False is none
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V43?color=%2300FF00', timeout=10) # Green
if (DEBUGBLYNK):
print ("blynkAlarmUpdate:OTHER:r.status_code:",r.status_code)
else:
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/update/V43?color=%23FF0000', timeout=10) # red
return 1
except Exception as e:
print ("exception in blynkStateUpdate")
print(traceback.format_exc())
print (e)
return 0
def blynkStatusUpdate():
if (DEBUGBLYNK):
print ("blynkStatusUpdate Entry")
try:
put_header={"Content-Type": "application/json"}
# look for English or Metric
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/get/V8') # read button state
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTEM:r.status_code:",r.status_code)
print ("blynkStatusUpdate:POSTEM:r.text:",r.text)
if (r.text == '["1"]'):
if (state.EnglishMetric == 0):
state.EnglishMetric = 1
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBRC:state.EnglishMetric set to Metric")
blynkStatusTerminalUpdate("Set to Metric Units ")
f = open("/home/pi/SDL_Pi_SkyWeather/state/EnglishMetric.txt", "w")
f.write("1")
f.close()
else:
if (state.EnglishMetric == 1):
state.EnglishMetric = 0
f = open("/home/pi/SDL_Pi_SkyWeather/state/EnglishMetric.txt", "w")
f.write("0")
f.close()
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBRC:state.EnglishMetric set to English")
blynkStatusTerminalUpdate("Set to English Units ")
# look for rainbow button change
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/get/V5') # read button state
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBR:r.status_code:",r.status_code)
print ("blynkStatusUpdate:POSTBR:r.text:",r.text)
if (r.text == '["1"]'):
state.runRainbow = True
blynkStatusTerminalUpdate("Turning Rainbow On ")
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBRC:state.runRainbow set to True")
else:
if(state.runRainbow == True):
blynkStatusTerminalUpdate("Turning Rainbow Off ")
state.runRainbow = False
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBRC:state.runRainbow set to False")
# turn OLED ON and OFF
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/get/V6') # read button state
#if (DEBUGBLYNK):
if (r.text == '["1"]'):
if (state.runOLED == False):
state.runOLED = True
blynkStatusTerminalUpdate("Turning OLED On ")
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBRO:state.runOLED set to True")
if (config.OLED_Originally_Present == True):
config.OLED_Present = True
util.turnOLEDOn()
else:
if (state.runOLED == True):
blynkStatusTerminalUpdate("Turning OLED Off ")
state.runOLED = False
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBRO:state.runOLED set to False")
if (config.OLED_Originally_Present == True):
config.OLED_Present = False
util.turnOLEDOff()
# look for Flash Strip Command
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/get/V30') # read button state
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBF:r.status_code:",r.status_code)
print ("blynkStatusUpdate:POSTBF:r.text:",r.text)
if (r.text == '["1"]'):
state.flashStrip = True
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBRF:state.flashStrip set to True")
else:
state.flashStrip = False
if (DEBUGBLYNK):
print ("blynkStatusUpdate:POSTBRF:state.flashStrip set to False")
return 1
except Exception as e:
print ("exception in blynkStatusUpdate")
print (e)
return 0
def blynkSGSAppOnline():
try:
r = requests.get(config.BLYNK_URL+config.BLYNK_AUTH+'/isAppConnected')
if (DEBUGBLYNK):
print ("blynkSGSAppOnline:POSTCHECK:r.text:",r.text)
return r.text
except Exception as e:
print ("exception in blynkApponline")
print (e)
return ""