Example usage

Here we will demonstrate how to use poolcontrolpy to access a nodejs-poolController API and fetch the configuration.

Imports

import asyncio
import aiohttp

from poolcontrolpy.poolcontrolpy import Controller

Create async function

We will create an async function that instantiates a controller and gets all config values.

async def main():

    async with aiohttp.ClientSession() as client:
        controller = Controller(client, "10.0.20.13", 4200)
        return await controller._rh.get("/config")

Access values

We call the function to return the config in JSON form, where we can access the values.

loop = asyncio.get_event_loop()
config = await loop.create_task(main())

print(config['circuits'][1])
print(config['valves'][0])
{'id': 1, 'type': 0, 'circuit': 12, 'isActive': True, 'isReturn': False, 'isIntake': False, 'name': 'Fountains', 'master': 0, 'isVirtual': False}