Skip to content

Commit

Permalink
Added raw device response
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Sep 6, 2020
1 parent 98c9f62 commit 2f9a28f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@ upload.sh
test.sh
.vscode/
sandbox/
.DS_Store
.DS_Store
jason.py
9 changes: 6 additions & 3 deletions plugpower.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
print("Usage: %s <PLUGID> <PLUGIP> <PLUGKEY> <PLUGVERS>\n" % sys.argv[0])
print(" Required: <PLUGID> is the Device ID e.g. 01234567891234567890")
print(" <PLUGIP> is the IP address of the smart plug e.g. 10.0.1.99")
print(" Optional: <PLUGKEY> is the Device Keyy (default 0123456789abcdef)")
print(" <PLUGVERS> is the Firmware Version 3.1 (defualt) or 3.3\n")
print(" Optional: <PLUGKEY> is the Device Key (default 0123456789abcdef)")
print(" <PLUGVERS> is the Firmware Version 3.1 (default) or 3.3\n")
print(" Note: You may also send values via Environmental variables: ")
print(" PLUGID, PLUGIP, PLUGKEY, PLUGVERS\n")
exit()
Expand All @@ -36,7 +36,9 @@
now = datetime.datetime.utcnow()
iso_time = now.strftime("%Y-%m-%dT%H:%M:%SZ")

# Poll Smart Swich for Power Data
# Poll Smart Device for Raw Data
(raw) = tuyapower.deviceRaw(PLUGID, PLUGIP, PLUGKEY, PLUGVERS)
# Poll Smart Switch for Power Data
(on, w, mA, V, err) = tuyapower.deviceInfo(PLUGID, PLUGIP, PLUGKEY, PLUGVERS)

# Check for error
Expand All @@ -51,6 +53,7 @@
# Print Output
print("TuyaPower (Tuya Power Stats) [%s] %s [%s]"%(tuyapower.__version__,tuyapower.api,tuyapower.api_ver))
print("\nDevice %s at %s key %s protocol %s:" % (PLUGID,PLUGIP,PLUGKEY,PLUGVERS))
print(" Response Data: %s" % raw)
print(" Switch On: %r" % on)
print(" Power (W): %f" % w)
print(" Current (mA): %f" % mA)
Expand Down
5 changes: 4 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
now = datetime.datetime.utcnow()
iso_time = now.strftime("%Y-%m-%dT%H:%M:%SZ")

# Poll Smart Swich for Power Data
# Poll Smart Device for Raw Data
(raw) = tuyapower.deviceRaw(PLUGID, PLUGIP, PLUGKEY, PLUGVERS)
# Poll Smart Switch for Power Data
(on, w, mA, V, err) = tuyapower.deviceInfo(PLUGID, PLUGIP, PLUGKEY, PLUGVERS)

# Check for error
Expand All @@ -51,6 +53,7 @@
# Print Output
print("TuyaPower (Tuya Power Stats) [%s] %s [%s]"%(tuyapower.__version__,tuyapower.api,tuyapower.api_ver))
print("\nDevice %s at %s key %s protocol %s:" % (PLUGID,PLUGIP,PLUGKEY,PLUGVERS))
print(" Response Data: %s" % raw)
print(" Switch On: %r" % on)
print(" Power (W): %f" % w)
print(" Current (mA): %f" % mA)
Expand Down

0 comments on commit 2f9a28f

Please sign in to comment.