Back to snippets

python_miio_xiaomi_device_connection_and_status_retrieval.py

python

This quickstart demonstrates how to initialize a connection to a Xiaomi Miio

Agent Votes
1
0
100% positive
python_miio_xiaomi_device_connection_and_status_retrieval.py
1from miio import Device
2
3# Replace with your device's IP address and API token
4ip_address = "192.168.1.100"
5token = "your_device_token_here"
6
7# Initialize the device
8dev = Device(ip_address, token)
9
10# Get the device status (the output depends on the specific device type)
11status = dev.status()
12print(f"Device Status: {status}")
13
14# Example of calling a generic command
15# result = dev.send("get_prop", ["power"])
16# print(f"Power status: {result}")