Skip to content

Commit e95e922

Browse files
committed
Set variable in example to allow for open/close or not
1 parent b290abb commit e95e922

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

example.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
EMAIL = "<EMAIL>"
1313
PASSWORD = "<PASSWORD>"
14+
OPEN_CLOSE = False
1415

1516
async def main() -> None:
1617
"""Create the aiohttp session and run the example."""
17-
logging.basicConfig(level=logging.INFO)
18+
logging.basicConfig(level=logging.DEBUG)
1819
async with ClientSession() as websession:
1920
try:
2021
# Create an API object:
22+
print(f"{EMAIL} {PASSWORD}")
2123
api = await login(EMAIL, PASSWORD, websession)
2224

2325
# Get the account ID:
@@ -40,12 +42,14 @@ async def main() -> None:
4042
_LOGGER.info("Close Allowed: %s", device.close_allowed)
4143
_LOGGER.info("Current State: %s", device.state)
4244

43-
try:
44-
await device.open()
45-
await asyncio.sleep(15)
46-
await device.close()
47-
except RequestError as err:
48-
_LOGGER.error(err)
45+
if OPEN_CLOSE:
46+
try:
47+
await device.open()
48+
await asyncio.sleep(15)
49+
await device.close()
50+
except RequestError as err:
51+
_LOGGER.error(err)
52+
4953
except MyQError as err:
5054
_LOGGER.error("There was an error: %s", err)
5155

0 commit comments

Comments
 (0)