Skip to content

Adding two more API methods: get_detail and get_config. #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Vesync API in Python
Adds functions to interface with the Vesync API for Etekcity Smart Wifi Outlets.

This library allows you to get a list of devices and turn them on or off
This library allows you to get a list of devices, get a device's usage details and configuration, and turn devices on or off

## Usage
```python
Expand All @@ -10,6 +10,8 @@ api = VesyncApi("USERNAME","PASSWORD")
print(api.get_devices())
api.turn_on("DEVICE_ID")
api.turn_off("DEVICE_ID")
print(api.get_detail("DEVICE_ID"))
print(api.get_config("DEVICE_ID"))
```

## Contributions
Expand Down
10 changes: 9 additions & 1 deletion vesync/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ def get_devices(self):
self._devices = requests.get(BASE_URL + '/vold/user/devices', verify=False, headers=self.get_headers()).json()
return self._devices

def turn_on(self,id):
def get_config(self, id):
self._configuration = requests.get(BASE_URL + '/v1/device/' + id + '/configurations', verify=False, headers=self.get_headers()).json()
return self._configuration

def get_detail(self, id):
self._detail = requests.get(BASE_URL + '/v1/device/' + id + '/detail', verify=False, headers=self.get_headers()).json()
return self._detail

def turn_on(self, id):
requests.put(BASE_URL + '/v1/wifi-switch-1.3/' + id + '/status/on', verify=False, data={}, headers=self.get_headers())

def turn_off(self, id):
Expand Down