Skip to content

Instantly share code, notes, and snippets.

@lukecyca
Created July 19, 2020 18:18
Show Gist options
  • Save lukecyca/9f88aad1b6473047ec7a0d5a8afd37fe to your computer and use it in GitHub Desktop.
Save lukecyca/9f88aad1b6473047ec7a0d5a8afd37fe to your computer and use it in GitHub Desktop.
Capture data from MrCool Cielo mini split
import requests
import json
session = requests.Session()
def login(username, password):
# Initial request - get session id
r = session.get('https://smartcielo.com/')
r.raise_for_status()
r = session.get(
'https://smartcielo.com/Content/css/libs/bootstrap.min.css')
r.raise_for_status()
session_id = r.cookies.get('ASP.NET_SessionId')
# Get our public IP
r = session.get('http://icanhazip.com')
r.raise_for_status()
my_ip = r.text
# Login Request
r = session.post(
'https://smartcielo.com/auth/login',
{
"mobileDeviceName": "chrome",
"deviceTokenId": my_ip,
"timeZone": "-07:00",
"state": '',
"client_id": '',
"response_type": '',
"scope": '',
"redirect_uri": '',
"userId": username,
"password": password,
"rememberMe": "false"
},
headers={
}
)
r.raise_for_status()
# Get Auth Access Token
r = session.post(
"https://smartcielo.com/cAcc",
{
"grant_type": "password",
"username": username,
"password": "undefined"
}
)
r.raise_for_status()
auth = r.json()
# Get data
payload = {
"accessToken": auth.get('access_token'),
"expiresIn": auth.get('expires_in'),
"sessionId": session_id,
"userID": auth.get('userName')
}
r = requests.post(
"https://smartcielo.com/api/device/initsubscription",
headers={
"authorization": "Bearer " + auth.get('access_token')
},
json=payload
)
r.raise_for_status()
return r.json()
def main():
data = login("MYLOGIN", "MYPASSWORD")
print(json.dumps(data['data']['listDevices'][0], indent=2))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment