File: testing_main_template.py

package info (click to toggle)
pyatmo 9.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,292 kB
  • sloc: python: 4,474; makefile: 3
file content (42 lines) | stat: -rw-r--r-- 963 bytes parent folder | download | duplicates (2)
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
import asyncio

from aiohttp import ClientSession

import pyatmo
from pyatmo.auth import AbstractAsyncAuth
from pyatmo.modules.module import MeasureInterval

MY_TOKEN_FROM_NETATMO = "MY_TOKEN"


class MyAuth(AbstractAsyncAuth):
    async def async_get_access_token(self):
        return MY_TOKEN_FROM_NETATMO


async def main():
    session = ClientSession()
    async_auth = MyAuth(session)
    account = pyatmo.AsyncAccount(async_auth)

    t = asyncio.create_task(account.async_update_topology())
    home_id = "MY_HOME_ID"
    module_id = "MY_MODULE_ID"

    await asyncio.gather(t)

    await account.async_update_status(home_id=home_id)

    strt = 1709766000 + 10 * 60
    end = 1709852400 + 10 * 60
    await account.async_update_measures(
        home_id=home_id,
        module_id=module_id,
        interval=MeasureInterval.HALF_HOUR,
        start_time=strt,
        end_time=end,
    )


if __name__ == "__main__":
    topology = asyncio.run(main())