Skip to content

Commit 4175fbd

Browse files
firstof9jcsogo
andauthored
0.1.13 (#16)
* add set_charge_mode function Utilizes the HTTP API to set the charge_mode configuration. * refactor: move all aiohttp handling into separate function * fix: make websocket listener not automatic (#12) * fix tests * handle running loop better * formatting * rename variable * refactor: update websocket error message with correct url * add python 3.10 to tests * Capture additional properties from OpenEVSE status (#15) * Add manual_override and divertmode * Add available_current, charge_rate and divert_active properties * Add smoothed_available_current * Add several additional properties - manual_override - divertmode - available_current - charge_rate - divert_active - smoothed_available_current * formatting * linting Co-authored-by: Jose Carlos Garcia Sogo <[email protected]>
1 parent 6b4822b commit 4175fbd

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: [3.8, 3.9]
17+
python-version:
18+
- "3.8"
19+
- "3.9"
20+
- "3.10"
1821

1922
steps:
2023
- uses: actions/[email protected]

openevsehttp/__init__.py

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
ERROR_UNKNOWN = "Unknown"
4141
ERROR_TIMEOUT = "Timeout while updating "
4242

43-
LOOP_INFO = "Event loop already running, not creating new one."
43+
INFO_LOOP_RUNNING = "Event loop already running, not creating new one."
4444

4545
MAX_FAILED_ATTEMPTS = 5
4646

@@ -275,26 +275,26 @@ def _start_listening(self):
275275
try:
276276
self._loop.run_until_complete(asyncio.gather(*pending))
277277
except RuntimeError:
278-
_LOGGER.info(LOOP_INFO)
278+
_LOGGER.info(INFO_LOOP_RUNNING)
279279

280280
def _update_status(self, msgtype, data, error):
281281
"""Update data from websocket listener."""
282282
if msgtype == SIGNAL_CONNECTION_STATE:
283283
if data == STATE_CONNECTED:
284-
_LOGGER.debug("Websocket to %s successful", self.url)
284+
_LOGGER.debug("Websocket to %s successful", self.websocket.uri)
285285
self._ws_listening = True
286286
elif data == STATE_DISCONNECTED:
287287
_LOGGER.debug(
288288
"Websocket to %s disconnected, retrying",
289-
self.url,
289+
self.websocket.uri,
290290
)
291291
self._ws_listening = False
292292
# Stopped websockets without errors are expected during shutdown
293293
# and ignored
294294
elif data == STATE_STOPPED and error:
295295
_LOGGER.error(
296296
"Websocket to %s failed, aborting [Error: %s]",
297-
self.url,
297+
self.websocket.uri,
298298
error,
299299
)
300300
self._ws_listening = False
@@ -643,6 +643,45 @@ def ota_update(self) -> str:
643643
assert self._status is not None
644644
return self._status["ota_update"]
645645

646+
@property
647+
def manual_override(self) -> str:
648+
"""Return if Manual Override is set."""
649+
assert self._status is not None
650+
return self._status["manual_override"]
651+
652+
@property
653+
def divertmode(self) -> str:
654+
"""Return the divert mode."""
655+
assert self._status is not None
656+
mode = self._status["divertmode"]
657+
if mode == 1:
658+
return "normal"
659+
return "eco"
660+
661+
@property
662+
def available_current(self) -> float:
663+
"""Return the computed available current for divert."""
664+
assert self._status is not None
665+
return self._status["available_current"]
666+
667+
@property
668+
def smoothed_available_current(self) -> float:
669+
"""Return the computed smoothed available current for divert."""
670+
assert self._status is not None
671+
return self._status["smoothed_available_current"]
672+
673+
@property
674+
def charge_rate(self) -> float:
675+
"""Return the divert charge rate."""
676+
assert self._status is not None
677+
return self._status["charge_rate"]
678+
679+
@property
680+
def divert_active(self) -> bool:
681+
"""Return if divert is active."""
682+
assert self._status is not None
683+
return self._status["divert_active"]
684+
646685
# There is currently no min/max amps JSON data
647686
# available via HTTP API methods
648687
@property

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
"Programming Language :: Python :: 3",
3232
"Programming Language :: Python :: 3.8",
3333
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
3435
],
3536
)

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[tox]
2-
envlist = py38, py39, lint, mypy
2+
envlist = py38, py39, py310, lint, mypy
33
skip_missing_interpreters = True
44

55
[gh-actions]
66
python =
77
3.8: py38, lint, mypy
88
3.9: py39
9+
3.10: py310
910

1011
[testenv]
1112
commands =

0 commit comments

Comments
 (0)