This repository has been archived by the owner on Apr 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 190
Basic Usage
NeoAcheron edited this page Dec 14, 2018
·
2 revisions
Below is some python that illustrates how to use this library. You can interact with the appliance by referencing the midea.device
objects. Just make sure not to reuse the midea.client
class, the cloud API doesn't support multiple sessions.
Can install the library in your global python reference library by using pip: pip install midea
from midea.client import client as midea_client
from midea.device import air_conditioning_device as ac
# The client takes an App_Key, an account email address and a password
client = midea_client('3742e9e5842d4ad59c2db887e12449f9', 'foo@bar.com', 'account_password')
# Log in right now, to check credentials (this step is optional, and will be called when listing devices)
client.setup()
# List devices. These are complex state holding objects, no other trickery needed from here.
devices = client.devices()
for device in devices:
# Refresh the object with the actual state by querying it
device.refresh()
print({
'id': device.id,
'name': device.name,
'power_state': device.power_state,
'audible_feedback': device.audible_feedback,
'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
})
# Set the state of the device and
device.power_state = True
device.audible_feedback = True
device.target_temperature = 21
device.operational_mode = ac.operational_mode_enum.auto
device.fan_speed = ac.fan_speed_enum.Auto
device.swing_mode = ac.swing_mode_enum.Off
device.eco_mode = False
device.turbo_mode = False
# commit the changes with apply()
device.apply()