From 9691f75070d1c3ce9aca4f5d87d5bec8863da50f Mon Sep 17 00:00:00 2001 From: "Jason A. Cox" Date: Sat, 5 Sep 2020 21:29:55 -0700 Subject: [PATCH] v0.0.24 - added deviceRaw() --- README.md | 5 +++++ tuyapower/__init__.py | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1e93c7c..e197eac 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,10 @@ For a helpful video walk-through of getting the KEYS you can also watch this gre ```python (on, w, mA, V, err) = tuyapower.deviceInfo(PLUGID, PLUGIP, PLUGKEY, PLUGVERS) ``` +* deviceRaw - Poll device and return raw response data. + ```python + rawData = tuyapower.deviceRaw(PLUGID, PLUGIP, PLUGKEY, PLUGVERS) + ``` * devicePrint - Poll device and print formatted output to stdout. ```python tuyapower.devicePrint(PLUGID, PLUGIP, PLUGKEY, PLUGVERS) @@ -90,6 +94,7 @@ For a helpful video walk-through of getting the KEYS you can also watch this gre * mA = milliamps * V = Voltage * err = Error message or OK +* rawData = Raw response from device * devices = Dictionary of all devices found with power data if available Note: If error occurs, on will be set to false, w, mA and V will be set to -99.0. diff --git a/tuyapower/__init__.py b/tuyapower/__init__.py index 3b19682..708aa30 100644 --- a/tuyapower/__init__.py +++ b/tuyapower/__init__.py @@ -8,6 +8,7 @@ Functions and Usage (on, w, mA, V, err) = tuyapower.deviceInfo(id, ip, key, vers) + rawData = tuyapower.deviceRaw(id, ip, key, vers) tuyapower.devicePrint(id, ip, key, vers) dataJSON = tuyapower.deviceJSON(id, ip, key, vers) devices = deviceScan(verbose, port) @@ -27,6 +28,7 @@ mA = milliamps V = Voltage (-99 if error or not supported) err = Error message or OK + rawData = Raw response from device devices = Dictionary of all devices found with power data if available """ from __future__ import print_function # python 2.7 support @@ -185,7 +187,7 @@ def deviceInfo(deviceid, ip, key, vers): # (dps) = tuyapower.deviceInfo(id, ip, key, vers) def deviceRaw(deviceid, ip, key, vers): """Poll Device for Status - raw DPS response - (dps) = tuyapower.deviceInfo(id, ip, key, vers) + rawData = tuyapower.deviceRaw(id, ip, key, vers) Parameters : id = Device ID e.g. 01234567891234567890 @@ -194,7 +196,7 @@ def deviceRaw(deviceid, ip, key, vers): vers = Version of Protocol 3.1 or 3.3 Response : - dps = raw dps response + rawData = Data response from device """ watchdog = 0 while True: