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: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
python-version:
- "3.8"
- "3.9"
- "3.10"

steps:
- uses: actions/checkout@v2.3.4
Expand Down
49 changes: 44 additions & 5 deletions openevsehttp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
ERROR_UNKNOWN = "Unknown"
ERROR_TIMEOUT = "Timeout while updating "

LOOP_INFO = "Event loop already running, not creating new one."
INFO_LOOP_RUNNING = "Event loop already running, not creating new one."

MAX_FAILED_ATTEMPTS = 5

Expand Down Expand Up @@ -275,26 +275,26 @@ def _start_listening(self):
try:
self._loop.run_until_complete(asyncio.gather(*pending))
except RuntimeError:
_LOGGER.info(LOOP_INFO)
_LOGGER.info(INFO_LOOP_RUNNING)

def _update_status(self, msgtype, data, error):
"""Update data from websocket listener."""
if msgtype == SIGNAL_CONNECTION_STATE:
if data == STATE_CONNECTED:
_LOGGER.debug("Websocket to %s successful", self.url)
_LOGGER.debug("Websocket to %s successful", self.websocket.uri)
self._ws_listening = True
elif data == STATE_DISCONNECTED:
_LOGGER.debug(
"Websocket to %s disconnected, retrying",
self.url,
self.websocket.uri,
)
self._ws_listening = False
# Stopped websockets without errors are expected during shutdown
# and ignored
elif data == STATE_STOPPED and error:
_LOGGER.error(
"Websocket to %s failed, aborting [Error: %s]",
self.url,
self.websocket.uri,
error,
)
self._ws_listening = False
Expand Down Expand Up @@ -643,6 +643,45 @@ def ota_update(self) -> str:
assert self._status is not None
return self._status["ota_update"]

@property
def manual_override(self) -> str:
"""Return if Manual Override is set."""
assert self._status is not None
return self._status["manual_override"]

@property
def divertmode(self) -> str:
"""Return the divert mode."""
assert self._status is not None
mode = self._status["divertmode"]
if mode == 1:
return "normal"
return "eco"

@property
def available_current(self) -> float:
"""Return the computed available current for divert."""
assert self._status is not None
return self._status["available_current"]

@property
def smoothed_available_current(self) -> float:
"""Return the computed smoothed available current for divert."""
assert self._status is not None
return self._status["smoothed_available_current"]

@property
def charge_rate(self) -> float:
"""Return the divert charge rate."""
assert self._status is not None
return self._status["charge_rate"]

@property
def divert_active(self) -> bool:
"""Return if divert is active."""
assert self._status is not None
return self._status["divert_active"]

# There is currently no min/max amps JSON data
# available via HTTP API methods
@property
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
)
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[tox]
envlist = py38, py39, lint, mypy
envlist = py38, py39, py310, lint, mypy
skip_missing_interpreters = True

[gh-actions]
python =
3.8: py38, lint, mypy
3.9: py39
3.10: py310

[testenv]
commands =
Expand Down