-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunInBackground.py
More file actions
43 lines (33 loc) · 1.21 KB
/
RunInBackground.py
File metadata and controls
43 lines (33 loc) · 1.21 KB
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
from microdot import Microdot
import sys
import urequests
from wifi_connector import Wifi_Connector
from relay import Relay
import ssl
from forecastAnalyzer import ForecastAnalyzer
_WIFI_CONNECTOR = Wifi_Connector() # current defaults to my wifi and password, can chance ssid and password here by updating initialization
_LED = Relay()
_RELAY1 = Relay(pinTag=21)
_RELAY_MAP = {
_LED.pinTag(): _LED,
_RELAY1.pinTag(): _RELAY1
}
def RunInBackground():
global _WIFI_CONNECTOR, _RELAY_MAP
if not (_WIFI_CONNECTOR.connect()):
print(f"wireless connection failed")
sys.exit()
forecast_analyzer = ForecastAnalyzer("config.json")
if not forecast_analyzer._zipcode:
forecast_analyzer.set_zipcode("94127")
print("setting latitude and longitude...")
if not forecast_analyzer._latitude or not forecast_analyzer._longitude:
forecast_analyzer.set_lat_lon()
print("saving config")
forecast_analyzer.save_config()
print("Fetching weather for tomorrow:")
forecast_analyzer.fetch_weather_tomorrow()
print("\nFetching weather for the next week:")
forecast_analyzer.fetch_weather_next_week()
if __name__ == '__main__':
RunInBackground()