forked from MadPatrick/somfy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_tahoma.py
45 lines (40 loc) · 1.67 KB
/
test_tahoma.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
import time
import logging
import json
import consolemenu
import tahoma
import exceptions
logging.basicConfig(format='%(asctime)s - %(levelname)-8s - %(filename)-18s - %(message)s', filename='somfy_test.log',
level=logging.DEBUG)
menuoptions = ['0 exit',"1 log in", "2 register", "3 get devices", "4 get events", "5 send command", "6 check log in"]
mymenu = consolemenu.SelectionMenu(menuoptions)
tahoma = tahoma.Tahoma()
if tahoma.cookie is None:
tahoma.cookie = 'JSESSIONID=F290EEAEC03B4838EBDA4B0CD0034BAB; Path=/enduser-mobile-web; Secure; HttpOnly; SameSite=None'
if True:
while True:
for i in menuoptions:
print(i)
x = int(input("Please Select:"))
print(x)
if x == 0: exit()
if x == 1:
try:
tahoma.tahoma_login('[email protected]', "blabla")
except exceptions.LoginFailure as exp:
print("Failed to login: " + str(exp))
if x == 2:
tahoma.register_listener()
if tahoma.listenerId is None:
tahoma.listenerId = 'b4e62511-ac10-3e01-60e0-9b9f656aea77'
if x == 3: print(tahoma.get_devices())
if x == 4: print(tahoma.get_events())
if x == 5:
data = '{"actions": [{"commands": [{"name": "open"}], "deviceURL": "io://1237-2024-7920/10464619"}], "label": "Domoticz - Somfy - Kamer_Klein - open"}'
print(tahoma.tahoma_command(json.dumps(data)))
if x == 6: print(str(tahoma.logged_in))
input("Press Enter to continue...")
# except (ValueError) as err:
# print("error in menu keuze")
else:
logging.error("initialisation failed")