-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest.py
72 lines (57 loc) · 2.19 KB
/
test.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import configparser
import logging
from frigidaire import Action, Power, Mode, FanSpeed, Frigidaire
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
# Create a config file at config.ini to reduce the risk of accidentally committing credentials
# You can use the following contents as a starting point
"""
[credentials]
password=password
; session_key=insert_session_key_here
; regional_base_url=https://api.us.ocp.electrolux.one
"""
config = configparser.ConfigParser()
config.read('config.ini')
credentials = config['credentials'] or {}
username = credentials.get('username')
password = credentials.get('password')
session_key = credentials.get('session_key', fallback=None)
regional_base_url = credentials.get('regional_base_url', fallback=None)
frigidaire = Frigidaire(
username,
password,
session_key=session_key,
regional_base_url=regional_base_url,
# timeout=5, # uncomment this if testing the request timeout
)
# tests connectivity
logging.debug("tests connectivity")
frigidaire.test_connection()
# get appliances
logging.debug("get appliance")
appliances = frigidaire.get_appliances()
# pick one arbitrarily
appliance = appliances[0]
# get some details for it
logging.debug("get details")
appliance_details = frigidaire.get_appliance_details(appliance)
# turn on
logging.debug("turn on")
frigidaire.execute_action(appliance, Action.set_power(Power.ON))
# set to cool
logging.debug("set to cool")
frigidaire.execute_action(appliance, Action.set_mode(Mode.COOL))
# set fan to medium
logging.debug("set fan to medium")
frigidaire.execute_action(appliance, Action.set_fan_speed(FanSpeed.MEDIUM))
# set temperature to 75
logging.debug("set temp to 75")
frigidaire.execute_action(appliance, Action.set_temperature(75))
# re-authenticate the connection to get a new session_key
logging.debug("re-authenticate")
frigidaire.re_authenticate()
# turn off
logging.debug("turn off")
frigidaire.execute_action(appliance, Action.set_power(Power.OFF))