-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path__init__.py
More file actions
28 lines (23 loc) · 856 Bytes
/
Copy path__init__.py
File metadata and controls
28 lines (23 loc) · 856 Bytes
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
"""
A bare-bones API to control Sengled smart devices via their cloud.
"""
import os
from .sengled import SengledAPI
def api(*args, **kwargs):
return SengledAPI(*args, **kwargs)
def api_from_env():
"""
Create an API client based on environment variables:
* SENGLED_USERNAME
* SENGLED_PASSWORD
* SENGLED_SESSION_PATH (optional)
* SENGLED_DEBUG (optional, default: False)
* SENGLED_RETRY (optional, default: False)
"""
return api(
username = os.environ["SENGLED_USERNAME"],
password = os.environ["SENGLED_PASSWORD"],
session_path = os.environ.get("SENGLED_SESSION_PATH"),
debug = os.environ.get("SENGLED_DEBUG", "false").lower() in ["true", "1", "yes", "t"],
retry = os.environ.get("SENGLED_RETRY", "false").lower() in ["true", "1", "yes", "t"]
)