cibernox / homeassistant-poolstation

HomeAssistant custom component for integrating the Poolstation platform.
MIT License
9 stars 4 forks source link

API documentation #6

Open emcepe opened 2 years ago

emcepe commented 2 years ago

Hi,

this is not an issue but a question: do you have a documentation for the idegis API?

I'm not able to find anything about it :-(

Or did you do trial and error?

Thank you!

cibernox commented 2 years ago

Pretty much, yeah. What I did is use the web client in https://poolstation.net/ with the dev tools open and check the requests being made. And the name of the fields in the JSON are not very intuitive either. There's no pubic documentation at all.

emcepe commented 2 years ago

Hi Miguel,

I feared it 😞

Well, I did it the same way as you and implemented all type of alarms. I'm new to python and don't know if all is correctly/best way implemented but it works 😀

If you want to incorporate the changes I can send you a diff.

emcepe commented 2 years ago

one more question. If I use your code:

#!/usr/bin/env python3

import asyncio
from aiohttp import ClientError, ClientResponseError, TCPConnector, ClientSession, DummyCookieJar
from pypoolstation import Account, Pool, Relay

import os
os.environ["AIOHTTP_NO_EXTENSIONS"] = "1"

async def test():
    connector = TCPConnector(enable_cleanup_closed=True)
    session = ClientSession(connector=connector, cookie_jar=DummyCookieJar())
    # session = ClientSession()
    account = Account(session, username="poolstation@blablub.de", password="f00b4r")
    print(vars(account))
    pools = await Pool.get_all_pools(session, account=account)
    #[pool, pool2] = pools
    [pool] = pools
    await pool.sync_info()
    print(vars(pool))

loop = asyncio.get_event_loop()
# Blocking call which returns when the display_date() coroutine is done
loop.run_until_complete(test())
loop.close()

to get the data from my poolstation back, all is working fine but the relay output is kind of useless:

[...], 'relays': [<pypoolstation.Relay object at 0xb5b31830>, <pypoolstation.Relay object at 0xb5b31930>, <pypoolstation.Relay object at 0xb5b31350>, <pypoolstation.Relay object at 0xb5243a30>], 'logger': <module 'logging' from '/usr/lib/python3.7/logging/__init__.py'>}
ERROR:asyncio:Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0xb5b02618>, 1910570.810996539)]']
connector: <aiohttp.connector.TCPConnector object at 0xb5bc7cd0>

is there some bug in your pypoolstation code?

thank you!

cibernox commented 2 years ago

I'm also very much not an expert in python. This library is the first time I wrote python since...2005 maybe. I believe however that this error is not in the library but in your test code. aiohttp's connections have to be closed before the process is terminated, otherwise they will complain. I think you can disregard it.

emcepe commented 2 years ago

The Code is from you which you removed some time ago ;-)

But the problem is not the aio disconnect, the problem is:

pypoolstation.Relay object at 0xb5b31830>, <pypoolstation.Relay object at 0xb5b31930>, <pypoolstation.Relay object at 0xb5b31350>, <pypoolstation.Relay object at 0xb5243a30>

That's not really an information about my relays :)

cibernox commented 2 years ago

That's just how python prints an object in the console. Must like the beloved [Object object] of javascript. If you want more detail on the state of the relay objects you should do print(vars(pool.relays[0])) or something similar

emcepe commented 1 year ago

Ah ok. Thank you.

Could you give me a hint also how do I set pH target and alike?

Tyia.