-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
48 lines (35 loc) · 1.43 KB
/
Copy pathexample.py
File metadata and controls
48 lines (35 loc) · 1.43 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
44
45
46
47
48
import asyncio
from python_solarfrontier.api import SolarFrontierAPI
from python_solarfrontier.utils import UnitConverter
async def main():
host = '192.168.50.101' # IP address of the inverter
api = SolarFrontierAPI(host)
# Test if we can connect with the host
test = await api.test_connection()
print(f"Test connection: {test}")
# Get system information
system_info = await api.get_system_info()
print(f"System information: {system_info}")
# Get measurement data
measurements = await api.get_measurements()
print(f"Measurement data: {measurements}")
# Get the yield of the current day
yield_day = await api.get_yield_day()
print(f"Yield of the current day: {yield_day}")
# Get the yield of the current month
yield_month = await api.get_yield_month()
print(f"Yield of the current month: {yield_month}")
# Get the yield of the current year
yield_year = await api.get_yield_year()
print(f"Yield of the current year: {yield_year}")
#Get total yield
yield_total = await api.get_yield_total()
print(f"Total yield: {yield_total}")
# Close the session
await api.close()
# Get measurement values and units
unit_converter = UnitConverter()
total_yield_value, total_yield_unit = unit_converter.parse_measurement(yield_total)
print(f"Total yield value: {total_yield_value}, unit: {total_yield_unit}")
# Run the async main function
asyncio.run(main())