python-openevse-http 0.3.2__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {python_openevse_http-0.3.2/python_openevse_http.egg-info → python_openevse_http-0.3.3}/PKG-INFO +1 -1
  2. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/client.py +1 -1
  3. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/commands.py +6 -2
  4. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3/python_openevse_http.egg-info}/PKG-INFO +1 -1
  5. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/setup.py +1 -1
  6. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_shaper.py +27 -0
  7. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/LICENSE +0 -0
  8. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/README.md +0 -0
  9. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/__init__.py +0 -0
  10. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/__main__.py +0 -0
  11. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/const.py +0 -0
  12. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/exceptions.py +0 -0
  13. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/managers.py +0 -0
  14. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/properties.py +0 -0
  15. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/sensors.py +0 -0
  16. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/openevsehttp/websocket.py +0 -0
  17. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/pyproject.toml +0 -0
  18. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/python_openevse_http.egg-info/SOURCES.txt +0 -0
  19. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/python_openevse_http.egg-info/dependency_links.txt +0 -0
  20. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/python_openevse_http.egg-info/not-zip-safe +0 -0
  21. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/python_openevse_http.egg-info/requires.txt +0 -0
  22. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/python_openevse_http.egg-info/top_level.txt +0 -0
  23. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/setup.cfg +0 -0
  24. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_client.py +0 -0
  25. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_commands.py +0 -0
  26. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_external_session.py +0 -0
  27. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_main_edge_cases.py +0 -0
  28. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_managers.py +0 -0
  29. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_mixins.py +0 -0
  30. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_properties.py +0 -0
  31. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_sensors.py +0 -0
  32. {python_openevse_http-0.3.2 → python_openevse_http-0.3.3}/tests/test_websocket.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_openevse_http
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Python wrapper for OpenEVSE HTTP API
5
5
  Home-page: https://github.com/firstof9/python-openevse-http
6
6
  Download-URL: https://github.com/firstof9/python-openevse-http
@@ -139,7 +139,7 @@ class OpenEVSE(CommandsMixin, ManagersMixin, SensorsMixin, PropertiesMixin):
139
139
  try:
140
140
  message = json.loads(message)
141
141
  except ValueError:
142
- _LOGGER.warning("Non JSON response: %s", message)
142
+ _LOGGER.debug("Non JSON response: %s", message)
143
143
 
144
144
  if resp.status == 400:
145
145
  if isinstance(message, dict) and "msg" in message:
@@ -492,6 +492,8 @@ class CommandsMixin:
492
492
  _LOGGER.error("Problem issuing command: %s", response)
493
493
  raise UnknownError
494
494
 
495
+ self._status["divertmode"] = new_mode
496
+
495
497
  async def set_shaper(self, enable: bool = True) -> None:
496
498
  """Set shaper mode."""
497
499
  if not self._version_check("4.0.0"):
@@ -500,16 +502,18 @@ class CommandsMixin:
500
502
 
501
503
  url = f"{self.url}shaper"
502
504
  mode = 1 if enable else 0
503
- data = {"mode": mode}
505
+ data = {"shaper": mode}
504
506
 
505
507
  _LOGGER.debug("Setting shaper to %s", mode)
506
- response = await self.process_request(url=url, method="post", data=data)
508
+ response = await self.process_request(url=url, method="post", rapi=data)
507
509
  response = self._normalize_response(response)
508
510
  msg = response.get("msg") if isinstance(response, Mapping) else None
509
511
  if msg not in ["OK", "done", "no change", "Current Shaper state changed"]:
510
512
  _LOGGER.error("Problem issuing command: %s", response)
511
513
  raise UnknownError
512
514
 
515
+ self._status["shaper"] = mode
516
+
513
517
  async def toggle_shaper(self) -> None:
514
518
  """Toggle shaper mode."""
515
519
  shaper_active = self._status.get("shaper")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_openevse_http
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Python wrapper for OpenEVSE HTTP API
5
5
  Home-page: https://github.com/firstof9/python-openevse-http
6
6
  Download-URL: https://github.com/firstof9/python-openevse-http
@@ -6,7 +6,7 @@ from setuptools import find_packages, setup
6
6
 
7
7
  PROJECT_DIR = Path(__file__).parent.resolve()
8
8
  README_FILE = PROJECT_DIR / "README.md"
9
- VERSION = "0.3.2"
9
+ VERSION = "0.3.3"
10
10
 
11
11
  setup(
12
12
  name="python_openevse_http",
@@ -46,6 +46,33 @@ async def test_set_shaper_fail(test_charger, mock_aioclient, caplog):
46
46
  await test_charger.set_shaper(True)
47
47
 
48
48
 
49
+ async def test_set_shaper_non_json(test_charger, mock_aioclient, caplog):
50
+ """Test set_shaper with a non-JSON response."""
51
+ await test_charger.update()
52
+ test_charger._status["shaper"] = 0
53
+
54
+ mock_aioclient.post(
55
+ TEST_URL_SHAPER,
56
+ status=200,
57
+ body="Current Shaper state changed",
58
+ )
59
+ with caplog.at_level(logging.DEBUG):
60
+ await test_charger.set_shaper(True)
61
+ assert "Setting shaper to 1" in caplog.text
62
+ assert test_charger.shaper_active == 1
63
+
64
+ test_charger._status["shaper"] = 1
65
+ mock_aioclient.post(
66
+ TEST_URL_SHAPER,
67
+ status=200,
68
+ body="Current Shaper state changed",
69
+ )
70
+ with caplog.at_level(logging.DEBUG):
71
+ await test_charger.set_shaper(False)
72
+ assert "Setting shaper to 0" in caplog.text
73
+ assert test_charger.shaper_active == 0
74
+
75
+
49
76
  async def test_toggle_shaper(test_charger, mock_aioclient, caplog):
50
77
  """Test toggle_shaper command."""
51
78
  await test_charger.update()