From 2e92ff2e4c149d31103bf11d1c2c90704804148b Mon Sep 17 00:00:00 2001 From: Sandy Date: Tue, 21 May 2024 14:04:04 -0400 Subject: [PATCH] Add some hints on how to get started (#1) * Add some hints on how to get started Wanted to try out this library to see if I could send commands to my device. Was a little confused as to where to start, so I am sharing my first steps for anyone coming after. * Add clarification about device type being hexadecimal * Add commands to get access to a device --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/README.md b/README.md index 2ffd915e..f84b3f79 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,53 @@ Control your Midea M-Smart appliances via local area network. This library is part of https://github.com/georgezhao2010/midea_ac_lan code. It was separated to segregate responsabilities. ⭐If this component is helpful for you, please star it, it encourages me a lot. + +## Getting started + +### Finding your device +```python +from midealocal.discover import discover +# Without knowing the ip address +discover() +# If you know the ip address +discover(ip_address="203.0.113.11") +# The device type is in hexadecimal and in midealocal/devices/TYPE +type_code = hex(list(discover().values())[0]['type'])[2:] +``` + +### Getting data from device +```python +from midealocal.discover import discover +from midealocal.devices import device_selector + +token = '...' +key = '...' + +# Get the first device +d = list(discover().values())[0] +# Select the device +ac = device_selector( + name="AC", + device_id=d['device_id'], + device_type=d['type'], + ip_address=d['ip_address'], + port=d['port'], + token=token, + key=key, + protocol=d['protocol'], + model=d['model'], + subtype=0, + customize="", +) + +# Connect and authenticate +ac.connect() +ac.authenticate() + +# Getting the attributes +print(ac.attributes) +# Setting the temperature +ac.set_target_temperature(23.0, None) +# Setting the swing +ac.set_swing(False, False) +```