Skip to content

Commit 3b9b25d

Browse files
committed
update endpoints, update APP_IDs, change supported brands
1 parent 3ed6e1b commit 3b9b25d

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

pymyq/__init__.py

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,37 @@ class MyQAPI:
77

88
LIFTMASTER = 'liftmaster'
99
CHAMBERLAIN = 'chamberlain'
10-
CRAFTMASTER = 'craftmaster'
10+
CRAFTSMAN = 'craftsman'
11+
MERLIN = 'merlin'
1112

12-
SUPPORTED_BRANDS = [LIFTMASTER, CHAMBERLAIN, CRAFTMASTER]
13+
SUPPORTED_BRANDS = [LIFTMASTER, CHAMBERLAIN, CRAFTSMAN, MERLIN]
1314
SUPPORTED_DEVICE_TYPE_NAMES = ['GarageDoorOpener', 'Garage Door Opener WGDO', 'VGDO']
1415

1516
APP_ID = 'app_id'
16-
HOST_URI = 'host_uri'
17+
HOST_URI = 'myqexternal.myqdevice.com'
1718

1819
BRAND_MAPPINGS = {
1920
LIFTMASTER: {
20-
APP_ID: 'JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu',
21-
HOST_URI: 'myqexternal.myqdevice.com'
21+
APP_ID: 'Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB/i'
2222
},
2323
CHAMBERLAIN: {
24-
APP_ID: 'JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu', #Vj8pQggXLhLy0WHahglCD4N1nAkkXQtGYpq2HrHD7H1nvmbT55KqtN6RSF4ILB%2Fi
25-
HOST_URI: 'myqexternal.myqdevice.com'
24+
APP_ID: 'OA9I/hgmPHFp9RYKJqCKfwnhh28uqLJzZ9KOJf1DXoo8N2XAaVX6A1wcLYyWsnnv'
2625
},
27-
CRAFTMASTER: {
28-
APP_ID: 'eU97d99kMG4t3STJZO/Mu2wt69yTQwM0WXZA5oZ74/ascQ2xQrLD/yjeVhEQccBZ',
29-
HOST_URI: 'craftexternal.myqdevice.com'
26+
CRAFTSMAN: {
27+
APP_ID: 'YmiMRRS1juXdSd0KWsuKtHmQvh5RftEp5iewHdCvsNB77FnQbY+vjCVn2nMdIeN8'
28+
},
29+
MERLIN: {
30+
APP_ID: '3004cac4e920426c823fa6c2ecf0cc28ef7d4a7b74b6470f8f0d94d6c39eb718'
3031
}
3132
}
3233

3334
STATE_OPEN = 'open'
3435
STATE_CLOSED = 'closed'
3536

36-
LOGIN_ENDPOINT = "api/v4/user/validate"
37-
DEVICE_LIST_ENDPOINT = "api/v4/userdevicedetails/get"
37+
LOGIN_ENDPOINT = "api/v4/User/Validate"
38+
DEVICE_LIST_ENDPOINT = "api/v4/UserDeviceDetails/Get"
3839
DEVICE_SET_ENDPOINT = "api/v4/DeviceAttribute/PutDeviceAttribute"
39-
HEADERS = {'User-Agent': 'Chamberlain/3773 (iPhone; iOS 10.0.1; Scale/2.00)'}
40+
USERAGENT = "Chamberlain/3773 (iPhone; iOS 10.0.1; Scale/2.00)"
4041

4142
REQUEST_TIMEOUT = 3.0
4243

@@ -72,20 +73,18 @@ def is_login_valid(self):
7273
"""Log in to the MyQ service."""
7374
params = {
7475
'username': self.username,
75-
'password': self.password,
76-
'appId': self.BRAND_MAPPINGS[self.brand][self.APP_ID],
77-
'culture': self.LOCALE
76+
'password': self.password
7877
}
7978

8079
try:
8180
login = requests.post(
8281
'https://{host_uri}/{login_endpoint}'.format(
83-
host_uri=self.BRAND_MAPPINGS[self.brand][self.HOST_URI],
82+
host_uri=self.HOST_URI,
8483
login_endpoint=self.LOGIN_ENDPOINT),
8584
json=params,
8685
headers={
87-
'MyQApplicationId': 'JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu',
88-
'User-Agent': 'Chamberlain/3773 (iPhone; iOS 10.0.1; Scale/2.00)'
86+
'MyQApplicationId': self.BRAND_MAPPINGS[self.brand][self.APP_ID],
87+
'User-Agent': self.USERAGENT
8988
},
9089
timeout=self.REQUEST_TIMEOUT
9190
)
@@ -107,18 +106,16 @@ def get_devices(self):
107106
if not self._logged_in:
108107
self._logged_in = self.is_login_valid()
109108

110-
params = {
111-
'appId': self.BRAND_MAPPINGS[self.brand][self.APP_ID],
112-
'securityToken': self.security_token
113-
}
114-
115109
try:
116110
devices = requests.get(
117111
'https://{host_uri}/{device_list_endpoint}'.format(
118-
host_uri=self.BRAND_MAPPINGS[self.brand][self.HOST_URI],
112+
host_uri=self.HOST_URI,
119113
device_list_endpoint=self.DEVICE_LIST_ENDPOINT),
120-
params=params,
121-
headers=self.HEADERS
114+
headers={
115+
'MyQApplicationId': self.BRAND_MAPPINGS[self.brand][self.APP_ID],
116+
'SecurityToken': self.security_token,
117+
'User-Agent': self.USERAGENT
118+
}
122119
)
123120

124121
devices.raise_for_status()
@@ -175,22 +172,21 @@ def open_device(self, device_id):
175172
def set_state(self, device_id, state):
176173
"""Set device state."""
177174
payload = {
178-
'AttributeName': 'desireddoorstate',
179-
'MyQDeviceId': device_id,
180-
'ApplicationId': 'JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu',
175+
'attributeName': 'desireddoorstate',
176+
'myQDeviceId': device_id,
181177
'AttributeValue': state,
182-
'SecurityToken': self.security_token,
183178
}
184179

185180
try:
186181
device_action = requests.put(
187182
'https://{host_uri}/{device_set_endpoint}'.format(
188-
host_uri=self.BRAND_MAPPINGS[self.brand][self.HOST_URI],
183+
host_uri=self.HOST_URI,
189184
device_set_endpoint=self.DEVICE_SET_ENDPOINT),
190185
data=payload,
191186
headers={
192-
'MyQApplicationId': 'JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu',
193-
'SecurityToken': self.security_token
187+
'MyQApplicationId': self.BRAND_MAPPINGS[self.brand][self.APP_ID],
188+
'SecurityToken': self.security_token,
189+
'User-Agent': self.USERAGENT
194190
}
195191
)
196192

@@ -200,4 +196,3 @@ def set_state(self, device_id, state):
200196
return False
201197

202198
return device_action.status_code == 200
203-

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='pymyq',
9-
version='0.0.2',
9+
version='0.0.4',
1010
description='Python package for controlling MyQ-Enabled Garage Door',
1111
author='Chris Campbell',
1212
author_email='[email protected]',

0 commit comments

Comments
 (0)