diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e5f49f9..8bfb18e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/openevsehttp/__init__.py b/openevsehttp/__init__.py index d0f1402..1b6b720 100644 --- a/openevsehttp/__init__.py +++ b/openevsehttp/__init__.py @@ -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 @@ -275,18 +275,18 @@ 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 @@ -294,7 +294,7 @@ def _update_status(self, msgtype, data, error): 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 @@ -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 diff --git a/setup.py b/setup.py index 48d6ea7..5d01307 100644 --- a/setup.py +++ b/setup.py @@ -31,5 +31,6 @@ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", ], ) diff --git a/tox.ini b/tox.ini index de8d0b8..b94fc40 100644 --- a/tox.ini +++ b/tox.ini @@ -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 =