-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.py
46 lines (35 loc) · 1.03 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python3
from time import sleep
from xiaomi_yi import XiaomiYi
if __name__ == "__main__":
# Make XiaomiYi object with default values.
# You can override these like :
# camera = XiaomiYi(ip="192.168.42.1", port=7878, timeout=5)
camera = XiaomiYi()
# Make connection to the camera.
camera.connect()
# Take single photo.
camera.take_photo()
# You can start recording.
camera.start_video()
sleep(5)
# And stop it manually.
camera.stop_video()
# Or record for a desired time (in seconds).
camera.start_video(10)
# Take photo every 5 seconds, for 30 sec.
# If second parameter is ommited, take photos forever.
camera.seq_photos(5, 30)
# Enable streaming for X seconds, or forever if ommited.
# Connect to stream on http://192.168.42.1/live with VLC or something.
# camera.stream(30)
# Send custom commands.
# You can find list of some common in commands.txt
cmd = { "msg_id": 2,
"token": camera.token(),
"type": "video_quality",
"param": "S.Fine"
}
camera.send(cmd)
# Close connection.
camera.close()