-
Notifications
You must be signed in to change notification settings - Fork 25
/
example-cloud-mode.py
29 lines (24 loc) · 1.14 KB
/
example-cloud-mode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Example test for pypowerwall
import os
import pypowerwall
if __name__ == "__main__":
# Optional: Turn on Debug Mode
pypowerwall.set_debug(True)
# Credentials for your Powerwall - Customer Login Data
# Set appropriate env vars or change the defaults
email = os.environ.get('PW_EMAIL', '[email protected]')
timezone = os.environ.get('PW_TIMEZONE', 'America/Los_Angeles') # Change to your local timezone/tz
auth_path = os.environ.get('PW_AUTH_PATH', "")
# Connect to Powerwall
pw = pypowerwall.Powerwall("", "", email, timezone, authpath=auth_path, cloudmode=True)
# Display Metric Examples
print("Battery power level: %0.0f%%" % pw.level())
print("Power response: %r" % pw.power())
print("Grid Power: %0.2fkW" % (float(pw.grid()) / 1000.0))
print("Solar Power: %0.2fkW" % (float(pw.solar()) / 1000.0))
print("Battery Power: %0.2fkW" % (float(pw.battery()) / 1000.0))
print("Home Power: %0.2fkW" % (float(pw.home()) / 1000.0))
# Raw JSON Data Examples
print("Status: %s" % pw.status())
print("Grid raw: %r" % pw.grid(verbose=True))
print("Solar raw: %r" % pw.solar(verbose=True))