-
Notifications
You must be signed in to change notification settings - Fork 39
/
example.py
56 lines (53 loc) · 1.81 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
47
48
49
50
51
52
53
54
55
56
from msmart.device import air_conditioning as ac
from msmart.device.base import device
import logging
import time
logging.basicConfig(level=logging.DEBUG)
# first take device's ip and id, port is generally 6444
# pip3 install msmart; midea-discover
device = ac('YOUR_AC_IP', int('YOUR_AC_ID'), 6444)
# If the device is using protocol 3 (aka 8370)
# you must authenticate with device's k1 and token.
# adb logcat | grep doKeyAgree
device.authenticate('YOUR_AC_K1', 'YOUR_AC_TOKEN')
# Refresh the object with the actual state by querying it
device.get_capabilities()
device.refresh()
print({
'id': device.id,
'name': device.ip,
'power_state': device.power_state,
'prompt_tone': device.prompt_tone,
'target_temperature': device.target_temperature,
'operational_mode': device.operational_mode,
'fan_speed': device.fan_speed,
'swing_mode': device.swing_mode,
'eco_mode': device.eco_mode,
'turbo_mode': device.turbo_mode,
'fahrenheit': device.fahrenheit,
'indoor_temperature': device.indoor_temperature,
'outdoor_temperature': device.outdoor_temperature
})
# Set the state of the device and
device.prompt_tone = True
device.power_state = True
device.prompt_tone = False
device.target_temperature = 25
device.operational_mode = ac.operational_mode_enum.cool
time.sleep(1)
# commit the changes with apply()
device.apply()
print({
'id': device.id,
'name': device.ip,
'power_state': device.power_state,
'prompt_tone': device.prompt_tone,
'target_temperature': device.target_temperature,
'operational_mode': device.operational_mode,
'fan_speed': device.fan_speed,
'swing_mode': device.swing_mode,
'eco_mode': device.eco_mode,
'turbo_mode': device.turbo_mode,
'indoor_temperature': device.indoor_temperature,
'outdoor_temperature': device.outdoor_temperature
})