From f7b2b765295ff123e8d87513473757dc63cbde53 Mon Sep 17 00:00:00 2001 From: chicken Date: Wed, 3 Oct 2018 14:04:12 -0700 Subject: [PATCH] Adding two more API methods: get_detail and get_config. --- README.md | 4 +++- vesync/api.py | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5428f46..ad5a5de 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/vesync/api.py b/vesync/api.py index 7b4f328..2abd8ed 100644 --- a/vesync/api.py +++ b/vesync/api.py @@ -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):