Created
January 13, 2020 13:56
-
-
Save AlexxIT/3b163770e8d0c9edc0919c9f3ccc716b to your computer and use it in GitHub Desktop.
This file contains 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
import socket | |
_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
_socket.settimeout(5.0) | |
try: | |
_socket.sendto('{"cmd":"whois"}'.encode(), ('224.0.0.50', 4321)) | |
recv = _socket.recvfrom(1024) | |
print(recv) | |
except Exception as e: | |
print('ERROR', e) | |
finally: | |
_socket.close() |
This file contains 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
import socket | |
HOST = '192.168.1.123' | |
MAC = '04:CF:8C:XX:XX:XX' | |
sid = MAC.replace(':', '').lower() | |
_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
_socket.settimeout(10.0) | |
try: | |
_socket.sendto(f'{{"cmd":"read","sid":"{sid}"}}'.encode(), (HOST, 9898)) | |
recv = _socket.recvfrom(1024) | |
print(recv) | |
except Exception as e: | |
print('ERROR', e) | |
finally: | |
_socket.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Первый скрипт найдёт Xiaomi Gateway в сети (в режиме разработчика).
Второй скрипт узнает у Gateway его состояние (необходимо заменить HOST и MAC на свои, можно узнать в окне, где включается режим разработчика).