Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions contributors.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Origional code by Jan Weltmeyer
Original code by Jan Weltmeyer
Timeout support added by Tim Graves
Updates to support interacting with the battery (updating operating mode, time of use schedule, battery reserve, flow rate) by Tim Graves
Updates to support interacting with the battery (updating operating mode, time of use schedule, battery reserve, flow rate) by Tim Graves
Async API by @RustyDust
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = sonnenbatterie
version = 0.5.0
version = 0.5.1
author = Jan Weltmeyer
description = "Access Sonnenbatterie REST API"
long_description = file: README.md
Expand Down
3 changes: 3 additions & 0 deletions sonnenbatterie/sonnenbatterie.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ async def _get(self, what, isretry=False) -> json:
)

if not isretry and response.status == 401:
await self.login()
return await self._get(what, True)

if response.status != 200:
Expand All @@ -297,6 +298,7 @@ async def _post(self, what, isretry=False) -> json:
)

if not isretry and response.status == 401:
await self.login()
return await self._post(what, True)
if response.status != 200:
response.raise_for_status()
Expand All @@ -317,6 +319,7 @@ async def _put(self, what, payload, isretry=False) -> json:
)

if not isretry and response.status == 401:
await self.login()
return await self._put(what, True)

if response.status != 200:
Expand Down
4 changes: 2 additions & 2 deletions test/login.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SONNEN_USERNAME = "User"
SONNEN_PASSWORD = "sonnenUser3552"
SONNEN_IP = "192.168.27.21"
SONNEN_TOKEN = "cd46d0f2-201e-4e82-882b-f590d9e754b8"
SONNEN_IP = "192.168.1.2"
SONNEN_TOKEN = "SeCrEtToKeN!"
8 changes: 4 additions & 4 deletions timeofuse/timeofuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, start_time:time, stop_time:time, max_power:int=20000):
if stop_time == MIDNIGHT:
stop_time = time.max
self.stop_time = stop_time
self.max_power = max_power
self.max_power = max_power if max_power < 22000 else 22000

def __eq__(self, other) -> bool :
if not isinstance(other, type(self)):
Expand Down Expand Up @@ -167,9 +167,9 @@ def get_as_string(self) -> str:
result = result + str(entry.get_as_string())
return result

# retained fore compatibility purposed, is not just a wrapper roung def load_tou_schedule
def load_tou_schedule(self, schedcule):
self.load_tou_schedule_from_json(schedcule)
# retained fore compatibility purposed, is not just a wrapper around `def load_tou_schedule`
def load_tou_schedule(self, schedule):
self.load_tou_schedule_from_json(schedule)

# replace the current tou schedule data with the new dicitonary data
def load_tou_schedule_from_json(self, json_schedule):
Expand Down
Loading