Skip to content

Commit

Permalink
examples: add AIRZONE_INST definition
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
  • Loading branch information
Noltari committed Sep 13, 2024
1 parent 64bcd75 commit 15b1848
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 25 deletions.
1 change: 1 addition & 0 deletions examples/_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

from aioairzone_cloud.common import ConnectionOptions

AIRZONE_INST = 1
AIRZONE_OPTIONS = ConnectionOptions("airzone_email", "airzone_password")
4 changes: 2 additions & 2 deletions examples/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import timeit

import _secrets
from _secrets import AIRZONE_OPTIONS
import aiohttp

from aioairzone_cloud.cloudapi import AirzoneCloudApi
Expand All @@ -15,7 +15,7 @@ async def main():
"""Basic Airzone client example."""

async with aiohttp.ClientSession() as aiohttp_session:
client = AirzoneCloudApi(aiohttp_session, _secrets.AIRZONE_OPTIONS)
client = AirzoneCloudApi(aiohttp_session, AIRZONE_OPTIONS)

try:
await client.login()
Expand Down
8 changes: 4 additions & 4 deletions examples/change-device-params.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import timeit

import _secrets
from _secrets import AIRZONE_INST, AIRZONE_OPTIONS
import aiohttp

from aioairzone_cloud.cloudapi import AirzoneCloudApi
Expand All @@ -23,7 +23,7 @@ async def main():
"""Change Airzone Cloud device parameters example."""

async with aiohttp.ClientSession() as aiohttp_session:
client = AirzoneCloudApi(aiohttp_session, _secrets.AIRZONE_OPTIONS)
client = AirzoneCloudApi(aiohttp_session, AIRZONE_OPTIONS)

try:
await client.login()
Expand All @@ -35,8 +35,8 @@ async def main():
inst_list = await client.list_installations()
for inst in inst_list:
print(json.dumps(inst.data(), indent=4, sort_keys=True))
client.select_installation(inst_list[0])
await client.update_installation(inst_list[0])
client.select_installation(inst_list[AIRZONE_INST])
await client.update_installation(inst_list[AIRZONE_INST])
print("***")

update_start = timeit.default_timer()
Expand Down
8 changes: 4 additions & 4 deletions examples/change-group-params.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import timeit

import _secrets
from _secrets import AIRZONE_INST, AIRZONE_OPTIONS
import aiohttp

from aioairzone_cloud.cloudapi import AirzoneCloudApi
Expand All @@ -23,7 +23,7 @@ async def main():
"""Change Airzone Cloud group parameters example."""

async with aiohttp.ClientSession() as aiohttp_session:
client = AirzoneCloudApi(aiohttp_session, _secrets.AIRZONE_OPTIONS)
client = AirzoneCloudApi(aiohttp_session, AIRZONE_OPTIONS)

try:
await client.login()
Expand All @@ -35,8 +35,8 @@ async def main():
inst_list = await client.list_installations()
for inst in inst_list:
print(json.dumps(inst.data(), indent=4, sort_keys=True))
client.select_installation(inst_list[0])
await client.update_installation(inst_list[0])
client.select_installation(inst_list[AIRZONE_INST])
await client.update_installation(inst_list[AIRZONE_INST])
print("***")

update_start = timeit.default_timer()
Expand Down
8 changes: 4 additions & 4 deletions examples/raw-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import timeit

import _secrets
from _secrets import AIRZONE_INST, AIRZONE_OPTIONS
import aiohttp

from aioairzone_cloud.cloudapi import AirzoneCloudApi
Expand All @@ -15,7 +15,7 @@ async def main():
"""Raw Airzone Cloud API data example."""

async with aiohttp.ClientSession() as aiohttp_session:
client = AirzoneCloudApi(aiohttp_session, _secrets.AIRZONE_OPTIONS)
client = AirzoneCloudApi(aiohttp_session, AIRZONE_OPTIONS)

try:
await client.login()
Expand All @@ -27,8 +27,8 @@ async def main():
inst_list = await client.list_installations()
for inst in inst_list:
print(json.dumps(inst.data(), indent=4, sort_keys=True))
client.select_installation(inst_list[0])
await client.update_installation(inst_list[0])
client.select_installation(inst_list[AIRZONE_INST])
await client.update_installation(inst_list[AIRZONE_INST])
print("***")

update_start = timeit.default_timer()
Expand Down
10 changes: 5 additions & 5 deletions examples/select-installation-group.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import timeit

import _secrets
from _secrets import AIRZONE_INST, AIRZONE_OPTIONS
import aiohttp

from aioairzone_cloud.cloudapi import AirzoneCloudApi
Expand All @@ -15,7 +15,7 @@ async def main():
"""Basic Airzone client example."""

async with aiohttp.ClientSession() as aiohttp_session:
client = AirzoneCloudApi(aiohttp_session, _secrets.AIRZONE_OPTIONS)
client = AirzoneCloudApi(aiohttp_session, AIRZONE_OPTIONS)

try:
await client.login()
Expand All @@ -27,11 +27,11 @@ async def main():
inst_list = await client.list_installations()
for inst in inst_list:
print(json.dumps(inst.data(), indent=4, sort_keys=True))
client.select_installation(inst_list[0])
await client.update_installation(inst_list[0])
client.select_installation(inst_list[AIRZONE_INST])
await client.update_installation(inst_list[AIRZONE_INST])
print("***")

if _secrets.AIRZONE_OPTIONS.websockets:
if AIRZONE_OPTIONS.websockets:
update_start = timeit.default_timer()
await client.update()
update_end = timeit.default_timer()
Expand Down
6 changes: 3 additions & 3 deletions examples/select-installation-webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import timeit

import _secrets
from _secrets import AIRZONE_INST, AIRZONE_OPTIONS
import aiohttp

from aioairzone_cloud.cloudapi import AirzoneCloudApi
Expand All @@ -15,7 +15,7 @@ async def main():
"""Basic Airzone client example."""

async with aiohttp.ClientSession() as aiohttp_session:
client = AirzoneCloudApi(aiohttp_session, _secrets.AIRZONE_OPTIONS)
client = AirzoneCloudApi(aiohttp_session, AIRZONE_OPTIONS)

try:
await client.login()
Expand All @@ -27,7 +27,7 @@ async def main():
inst_list = await client.list_installations()
for inst in inst_list:
print(json.dumps(inst.data(), indent=4, sort_keys=True))
client.select_installation(inst_list[0])
client.select_installation(inst_list[AIRZONE_INST])
await client.update_webservers(True)
print("***")

Expand Down
6 changes: 3 additions & 3 deletions examples/token-refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import timeit

import _secrets
from _secrets import AIRZONE_INST, AIRZONE_OPTIONS
import aiohttp

from aioairzone_cloud.cloudapi import AirzoneCloudApi
Expand All @@ -15,7 +15,7 @@ async def main():
"""Airzone Cloud token refresh example."""

async with aiohttp.ClientSession() as aiohttp_session:
client = AirzoneCloudApi(aiohttp_session, _secrets.AIRZONE_OPTIONS)
client = AirzoneCloudApi(aiohttp_session, AIRZONE_OPTIONS)

try:
await client.login()
Expand All @@ -27,7 +27,7 @@ async def main():
inst_list = await client.list_installations()
for inst in inst_list:
print(json.dumps(inst.data(), indent=4, sort_keys=True))
client.select_installation(inst_list[0])
client.select_installation(inst_list[AIRZONE_INST])
await client.update_webservers(True)
print("***")

Expand Down

0 comments on commit 15b1848

Please sign in to comment.