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
|
import asyncio
import logging
import os
from pprint import pprint
from aiohttp import ClientResponse
from pyenphase.envoy import Envoy
logging.basicConfig(level=logging.DEBUG)
async def main() -> None:
envoy = Envoy(os.environ.get("ENVOY_HOST", "envoy.local"))
await envoy.setup()
username = os.environ.get("ENVOY_USERNAME")
password = os.environ.get("ENVOY_PASSWORD")
token = os.environ.get("ENVOY_TOKEN")
await envoy.authenticate(username=username, password=password, token=token)
# Test https://enphase.com/download/iq-gateway-access-using-local-apis-or-local-ui-token-based-authentication-tech-brief endpoints
print(await envoy.update())
end_points = [
"/ivp/livedata/status",
"/api/v1/production",
"/api/v1/production/inverters",
"/production.json",
"/production",
"/ivp/meters",
"/ivp/meters/readings",
"/ivp/meters/reports/consumption",
"/ivp/ensemble/inventory",
"/ivp/ensemble/dry_contacts",
"/ivp/ss/dry_contact_settings",
"/ivp/pdm/device_data",
]
for end_point in end_points:
try:
response: ClientResponse = await envoy.request(end_point)
except Exception as e:
print(e)
continue
json_dict = await response.json()
print((end_point, "=" * 80))
pprint(json_dict)
print((end_point, "=" * 80))
asyncio.run(main())
|