Skip to content

Commit fb94884

Browse files
committed
Revert to old system but put in a try catch and wait longer
1 parent 16cec84 commit fb94884

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

WeatherStationCoreLink/main.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import json #To parse response
1010
import sqlite3 #Database
1111
import pusher #Pusher.com
12-
from balena import Balena #rebooting
13-
balena = Balena()
1412

1513
os.environ['TZ'] = 'Europe/London' #SetTimezone
1614
def log(message):
@@ -24,18 +22,15 @@ def log(message):
2422
def reboot():
2523
#Use Resin.io api to reboot
2624
log("Rebooting")
27-
rebootResult = balena.models.supervisor.reboot()
28-
log(rebootResult)
29-
if rebootResult['DATA'] != 'OK':
30-
log("Reboot Failed")
31-
else:
32-
log("Reboot worked")
33-
time.sleep(43200)
25+
rebooturl = str(os.environ.get('BALENA_SUPERVISOR_ADDRESS')) + '/v1/reboot?apikey=' + str(os.environ.get('BALENA_SUPERVISOR_API_KEY'))
26+
try:
27+
os.system('curl -X POST --header "Content-Type:application/json" "' + rebooturl + '"')
28+
time.sleep(43200)
29+
except:
30+
time.sleep(600) #Just in case that api call fails as it sometimes does
31+
reboot()
3432
return False #basically put itself into a loop
3533

36-
time.sleep(120)
37-
reboot()
38-
3934
serialport = "/dev/ttyUSB0"
4035
baudrate = os.environ.get('baudRate', 19200) #Set the Baudrate to 19200 which is a nice default for the davis logger
4136
try:

0 commit comments

Comments
 (0)