Last active
July 25, 2026 13:02
-
-
Save e1ectr0cut1e/015b9e3637320025bb3219dee03a7811 to your computer and use it in GitHub Desktop.
Novatek-Electro EM-130 HTTP API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import sys | |
| import requests | |
| import hashlib | |
| BASE_URL = "http://192.0.2.0" | |
| PASSWORD = "admin" | |
| MODE_AUTO = "0" | |
| MODE_ON = "1" | |
| MODE_OFF = "2" | |
| session = requests.Session() | |
| def salt(): | |
| response = session.get(BASE_URL + "/api/login", params={"salt": "1"}) | |
| data = response.json() | |
| if data.get("STATUS") != "OK": | |
| raise Exception("Salt: STATUS != OK") | |
| salt_ = data.get("salt") | |
| if not salt_: | |
| raise Exception("Salt: No salt") | |
| return salt_ | |
| def login(salt, password): | |
| hash_ = hashlib.sha1((salt + password.encode().hex() + salt).encode("ascii")).hexdigest() | |
| response = session.get(BASE_URL + "/api/login", params={"login": hash_}) | |
| data = response.json() | |
| if data.get("STATUS") != "OK": | |
| raise Exception("Login: STATUS != OK") | |
| def get(): | |
| response = session.get(BASE_URL + "/api/get", params={"user-ctrl": ""}) | |
| data = response.json() | |
| if data.get("STATUS") != "OK": | |
| raise Exception("Get: STATUS != OK") | |
| return data.get("user-ctrl") | |
| def set(mode): | |
| response = session.get(BASE_URL + "/api/set", params={"user-ctrl": mode}) | |
| data = response.json() | |
| if data.get("STATUS") != "OK": | |
| raise Exception("Set: STATUS != OK") | |
| login(salt(), PASSWORD) | |
| print(get()) | |
| set(MODE_AUTO) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment