From 1519cd4692e5b5907e7dda633e1a56e3b5976858 Mon Sep 17 00:00:00 2001 From: "Jason A. Cox" Date: Sun, 9 Jan 2022 15:19:51 -0800 Subject: [PATCH] v0.1.4 - Battery Level Percentage Scaling --- RELEASE.md | 8 +++++--- pypowerwall/__init__.py | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 141cbeb..254aafa 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,11 +1,13 @@ # RELEASE NOTES -## v0.1.4 - TBD (unreleased) +## v0.1.4 - Battery Level Percentage Scaling -* Added Tesla App style Battery Level Conversion option to `level()` +* PyPI 0.1.4 +* Changed "Network Scan" default timeout to 400ms for better detection. +* Added Tesla App style "Battery Level Percentage" Conversion option to `level()` to convert the level reading to the 95% scale used by the App. Ths converts the battery level percentage to be consistent with the Tesla App: ```python ->>> pw.level(appvalue=True) +>>> pw.level(scale=True) 39.971429212508326 >>> pw.level() 42.972857751882906 diff --git a/pypowerwall/__init__.py b/pypowerwall/__init__.py index 5eb25a1..0dbc7dc 100644 --- a/pypowerwall/__init__.py +++ b/pypowerwall/__init__.py @@ -41,7 +41,7 @@ import sys from . import tesla_pb2 # Protobuf definition for vitals -version_tuple = (0, 1, 3) +version_tuple = (0, 1, 4) version = __version__ = '%d.%d.%d' % version_tuple __author__ = 'jasonacox' @@ -180,12 +180,12 @@ def poll(self, api='/api/site_info/site_name', jsonformat=False, raw=False, recu else: return payload - def level(self, appvalue=False): + def level(self, scale=False): """ Battery Level Percentage Args: - appvalue = If True, convert battery level to app scale value + scale = If True, convert battery level to app scale value Note: Tesla App reserves 5% of battery = ( (batterylevel / 0.95) - (5 / 0.95) ) """ # Return power level percentage for battery @@ -193,7 +193,7 @@ def level(self, appvalue=False): payload = self.poll('/api/system_status/soe', jsonformat=True) if(payload is not None and 'percentage' in payload): level = payload['percentage'] - if appvalue: + if scale: return ((level / 0.95) - (5 / 0.95)) else: return level