forked from neroxps/midea-msmart
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.py
50 lines (45 loc) · 1.63 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
from msmart.device import device as midea_device
from msmart.device import air_conditioning_device as ac
import logging
logging.basicConfig(level=logging.DEBUG)
# first take device's ip and id
# pip3 install msmart; midea-discover
c = midea_device('YOUR_AC_IP', YOUR_AC_ID)
device = c.setup()
# Refresh the object with the actual state by querying it
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,
'indoor_temperature': device.indoor_temperature,
'outdoor_temperature': device.outdoor_temperature
})
# Set the state of the device and
device.power_state = True
device.prompt_tone = False
device.target_temperature = 25
device.operational_mode = ac.operational_mode_enum.cool
# 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
})