-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
36 lines (26 loc) · 1 KB
/
test.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
#!/usr/bin/python3
import asyncio
import logging
import traceback
from aiohttp import ClientConnectionError, ClientSession
from .solcastapi import ConnectionOptions, SolcastApi
#logging.basicConfig(level=logging.DEBUG)
_LOGGER = logging.getLogger(__name__)
async def test():
try:
options = ConnectionOptions(
"changetoyourapikey",
"https://api.solcast.com.au",
'solcast.json'
)
async with ClientSession() as session:
solcast = SolcastApi(session, options, apiCacheEnabled=True)
await solcast.sites_data()
await solcast.load_saved_data()
print("Total today " + str(solcast.get_total_kwh_forecast_today()))
print("Peak today " + str(solcast.get_peak_w_today()))
print("Peak time today " + str(solcast.get_peak_w_time_today()))
except Exception as err:
_LOGGER.error("async_setup_entry: %s",traceback.format_exc())
return False
asyncio.run(test())