python-openevse-http 1.3.0__py3-none-any.whl → 1.5.0__py3-none-any.whl

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.
openevsehttp/client.py CHANGED
@@ -53,11 +53,16 @@ class OpenEVSE(CommandsMixin, ManagersMixin, SensorsMixin, PropertiesMixin):
53
53
  user: str | None = None,
54
54
  pwd: str | None = None,
55
55
  session: aiohttp.ClientSession | None = None,
56
+ ssl: bool = False,
57
+ ssl_verify: bool = True,
56
58
  ) -> None:
57
59
  """Connect to an OpenEVSE charger equipped with wifi or ethernet."""
58
60
  self._user = user or ""
59
61
  self._pwd = pwd or ""
60
- self.url = f"http://{host}/"
62
+ self.ssl = ssl
63
+ self.ssl_verify = ssl_verify
64
+ scheme = "https" if ssl else "http"
65
+ self.url = f"{scheme}://{host}/"
61
66
  self._status: dict[str, Any] = {}
62
67
  self._config: dict[str, Any] = {}
63
68
  self._override: Any = None
@@ -134,6 +139,8 @@ class OpenEVSE(CommandsMixin, ManagersMixin, SensorsMixin, PropertiesMixin):
134
139
  kwargs = {"data": rapi, "auth": auth}
135
140
  if data is not None:
136
141
  kwargs["json"] = data
142
+ if url.startswith("https://") and not self.ssl_verify:
143
+ kwargs["ssl"] = False
137
144
  async with http_method(url, **kwargs) as resp:
138
145
  try:
139
146
  raw = await resp.text()
@@ -285,6 +292,7 @@ class OpenEVSE(CommandsMixin, ManagersMixin, SensorsMixin, PropertiesMixin):
285
292
  self._user,
286
293
  self._pwd,
287
294
  self._session,
295
+ ssl_verify=self.ssl_verify,
288
296
  )
289
297
 
290
298
  def _validate_session_loop(self, loop: asyncio.AbstractEventLoop) -> None:
openevsehttp/commands.py CHANGED
@@ -23,6 +23,8 @@ class CommandsMixin:
23
23
  """Mixin providing command methods for OpenEVSE."""
24
24
 
25
25
  url: str
26
+ ssl: bool
27
+ ssl_verify: bool
26
28
  _status: dict[str, Any]
27
29
  _config: dict[str, Any]
28
30
  _session: aiohttp.ClientSession | None
@@ -665,3 +667,23 @@ class CommandsMixin:
665
667
 
666
668
  new_state = not bool(shaper_active)
667
669
  await self.set_shaper(new_state)
670
+
671
+ async def set_mqtt_vehicle_range_miles(self, enable: bool = True) -> None:
672
+ """Set mqtt_vehicle_range_miles configuration setting.
673
+
674
+ Dynamically changing this setting will affect future evaluations of
675
+ the vehicle_range_with_unit property.
676
+ """
677
+ if not isinstance(enable, bool):
678
+ raise TypeError("Value must be a boolean.")
679
+
680
+ url = f"{self.url}config"
681
+ data = {"mqtt_vehicle_range_miles": enable}
682
+
683
+ _LOGGER.debug("Setting mqtt_vehicle_range_miles to %s", enable)
684
+ response = await self.process_request(url=url, method="post", data=data)
685
+ response = self._normalize_response(response)
686
+ msg = response.get("msg") if isinstance(response, Mapping) else None
687
+ if msg not in SUCCESS_ANSWERS:
688
+ _LOGGER.error("Problem issuing command: %s", response)
689
+ raise UnknownError
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import logging
6
+ import warnings
6
7
  from collections.abc import Mapping
7
8
  from datetime import datetime, timedelta, timezone
8
9
  from typing import Any, cast
@@ -458,11 +459,33 @@ class PropertiesMixin:
458
459
  @property
459
460
  def vehicle_range(self) -> int | None:
460
461
  """Return battery range."""
462
+ warnings.warn(
463
+ "vehicle_range is deprecated, use vehicle_range_with_unit instead",
464
+ DeprecationWarning,
465
+ stacklevel=2,
466
+ )
461
467
  return cast(
462
468
  "int | None",
463
469
  self._status.get("vehicle_range", self._status.get("battery_range", None)),
464
470
  )
465
471
 
472
+ @property
473
+ def vehicle_range_with_unit(self) -> tuple[int, str] | None:
474
+ """Return battery range and its unit."""
475
+ value = cast(
476
+ "int | None",
477
+ self._status.get("vehicle_range", self._status.get("battery_range", None)),
478
+ )
479
+ if value is None:
480
+ return None
481
+ unit = "miles" if self.mqtt_vehicle_range_miles else "km"
482
+ return (value, unit)
483
+
484
+ @property
485
+ def mqtt_vehicle_range_miles(self) -> bool:
486
+ """Return True if mqtt vehicle range is in miles, False if km."""
487
+ return bool(self._config.get("mqtt_vehicle_range_miles", False))
488
+
466
489
  @property
467
490
  def vehicle_eta(self) -> datetime | None:
468
491
  """Return time to full charge."""
openevsehttp/websocket.py CHANGED
@@ -42,9 +42,11 @@ class OpenEVSEWebsocket:
42
42
  user: str | None = None,
43
43
  password: str | None = None,
44
44
  session: aiohttp.ClientSession | None = None,
45
+ ssl_verify: bool = True,
45
46
  ) -> None:
46
47
  """Initialize a OpenEVSEWebsocket instance."""
47
48
  self.session = session
49
+ self.ssl_verify = ssl_verify
48
50
  self.uri = self._get_uri(server)
49
51
  self._user = user
50
52
  self._password = password
@@ -133,10 +135,16 @@ class OpenEVSEWebsocket:
133
135
  try:
134
136
  # Narrow type for mypy since _ensure_session sets self.session
135
137
  assert self.session is not None
138
+ ws_kwargs: dict[str, Any] = {
139
+ "heartbeat": 15,
140
+ "auth": auth,
141
+ }
142
+ if self.uri.startswith("wss://") and not self.ssl_verify:
143
+ ws_kwargs["ssl"] = False
144
+
136
145
  async with self.session.ws_connect(
137
146
  self.uri,
138
- heartbeat=15,
139
- auth=auth,
147
+ **ws_kwargs,
140
148
  ) as ws_client:
141
149
  self._client = ws_client
142
150
  await self._set_state(STATE_CONNECTED)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_openevse_http
3
- Version: 1.3.0
3
+ Version: 1.5.0
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
@@ -84,6 +84,35 @@ async def main():
84
84
  if __name__ == "__main__":
85
85
  asyncio.run(main())
86
86
  ```
87
+ ### HTTPS and SSL Verification Options
88
+
89
+ If your OpenEVSE WiFi/ethernet module uses HTTPS, you can configure the client to connect securely using the `ssl=True` parameter:
90
+
91
+ ```python
92
+ # Connect securely using HTTPS (validating SSL/TLS certificates)
93
+ charger = OpenEVSE(
94
+ "192.168.1.30",
95
+ session=session,
96
+ ssl=True,
97
+ )
98
+ ```
99
+
100
+ #### Bypassing SSL Verification (Self-Signed Certificates)
101
+
102
+ > [!WARNING]
103
+ > Disabling SSL certificate validation (`ssl_verify=False`) disables TLS verification and exposes the connection to Man-in-the-Middle (MITM) attacks. Only use this configuration when connecting to an OpenEVSE module with a self-signed certificate over a trusted local network.
104
+
105
+ To bypass certificate verification:
106
+
107
+ ```python
108
+ # Connect using HTTPS, and disable certificate verification
109
+ charger = OpenEVSE(
110
+ "192.168.1.30",
111
+ session=session,
112
+ ssl=True,
113
+ ssl_verify=False,
114
+ )
115
+ ```
87
116
 
88
117
  ## API Support Matrix
89
118
 
@@ -0,0 +1,19 @@
1
+ openevsehttp/__init__.py,sha256=I6a1mjOZHYiWb_qfCuDuFLOOncrkkB_7uwybtOIujfY,1165
2
+ openevsehttp/__main__.py,sha256=EHmSdT7GjAVvHQxvLBTjZXsj_V5SB6B2_kpgUAT7mPM,146
3
+ openevsehttp/client.py,sha256=bySzhJ9SKU0IN7-QQfW7_ZrKNw-EoPV4RvnRBXtmCQ8,19326
4
+ openevsehttp/commands.py,sha256=G6KjZpwRhjhdxFBh5Sa8jm_jjGQdoFzSf9kTMZfBhGk,28162
5
+ openevsehttp/const.py,sha256=-frkFduu8hxEBab9FnwA3D65XHrsyH0W7P9miYsWh90,1726
6
+ openevsehttp/exceptions.py,sha256=bqz-tHTW1AYJMKcm0s5M6z5tA6XZgjnCiBLW1XrZ_70,672
7
+ openevsehttp/managers.py,sha256=EtQMQziwhoZeqKe2zWY-0yS7zedhuYjYtL5j9xBBCZ0,5380
8
+ openevsehttp/properties.py,sha256=9AJeKatU4fVknLigdrF2n6Ny3DpvOQgbZgc5qpHVbnA,18785
9
+ openevsehttp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ openevsehttp/sensors.py,sha256=zhQSToY_Zp2rOhPnUXT40xS5ZnUavqNGLm4zAFiUUrY,5717
11
+ openevsehttp/utils.py,sha256=fPUWL64gFTRw4TtV4WITDAFMJ75VjNhPBaU6diwVlv0,2019
12
+ openevsehttp/websocket.py,sha256=yMuLNsB2qYZLtfYRW7-D7NH7rv-qaSTp7F79OajKm_0,10790
13
+ python_openevse_http-1.5.0.dist-info/licenses/LICENSE,sha256=hSB6TOQ7rmwSGb6XzqRjDGMvmUj5_GlacqQin3tegtA,11341
14
+ python_openevse_http-1.5.0.dist-info/METADATA,sha256=XvBR5zmlCjmOAg3TKzCnPoU_ekbRVA4sZq7MJLmcopo,5411
15
+ python_openevse_http-1.5.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
16
+ python_openevse_http-1.5.0.dist-info/scm_file_list.json,sha256=KTMxbP5zijLSBJD3NZtpfxkBeLpQgSO29uMi_dGoiEQ,2264
17
+ python_openevse_http-1.5.0.dist-info/scm_version.json,sha256=4_Kgqqqxd2ojwG9gdRVIBboF5UHJBn44SJHF9gqAcBw,160
18
+ python_openevse_http-1.5.0.dist-info/top_level.txt,sha256=u8RUkoEIE33Cjn6gmqiEoVpZ0VZ59WJ3FXBwwOg0CPE,13
19
+ python_openevse_http-1.5.0.dist-info/RECORD,,
@@ -0,0 +1,70 @@
1
+ {
2
+ "files": [
3
+ ".pre-commit-config.yaml",
4
+ ".yamllint",
5
+ "README.md",
6
+ "EXTERNAL_SESSION.md",
7
+ "tox.ini",
8
+ "requirements_lint.txt",
9
+ "requirements_test.txt",
10
+ "LICENSE",
11
+ "setup.py",
12
+ "pyproject.toml",
13
+ "requirements.txt",
14
+ "codecov.yml",
15
+ ".gitignore",
16
+ "example_external_session.py",
17
+ "openevsehttp/py.typed",
18
+ "openevsehttp/__init__.py",
19
+ "openevsehttp/const.py",
20
+ "openevsehttp/exceptions.py",
21
+ "openevsehttp/utils.py",
22
+ "openevsehttp/client.py",
23
+ "openevsehttp/websocket.py",
24
+ "openevsehttp/managers.py",
25
+ "openevsehttp/properties.py",
26
+ "openevsehttp/sensors.py",
27
+ "openevsehttp/commands.py",
28
+ "openevsehttp/__main__.py",
29
+ "tests/__init__.py",
30
+ "tests/test_managers.py",
31
+ "tests/test_client.py",
32
+ "tests/test_main_edge_cases.py",
33
+ "tests/test_shaper.py",
34
+ "tests/test_commands.py",
35
+ "tests/conftest.py",
36
+ "tests/test_external_session.py",
37
+ "tests/test_mixins.py",
38
+ "tests/test_websocket.py",
39
+ "tests/test_properties.py",
40
+ "tests/test_sensors.py",
41
+ "tests/common.py",
42
+ "tests/fixtures/github_v4.json",
43
+ "tests/fixtures/github_v2.json",
44
+ "tests/fixtures/websocket.json",
45
+ "tests/fixtures/v2_json/config.json",
46
+ "tests/fixtures/v2_json/status.json",
47
+ "tests/fixtures/v4_json/config-broken-semver.json",
48
+ "tests/fixtures/v4_json/status-new.json",
49
+ "tests/fixtures/v4_json/status-broken.json",
50
+ "tests/fixtures/v4_json/config-broken.json",
51
+ "tests/fixtures/v4_json/config-dev.json",
52
+ "tests/fixtures/v4_json/schedule.json",
53
+ "tests/fixtures/v4_json/config.json",
54
+ "tests/fixtures/v4_json/config-unknown-semver.json",
55
+ "tests/fixtures/v4_json/config-new.json",
56
+ "tests/fixtures/v4_json/config-extra-version.json",
57
+ "tests/fixtures/v4_json/status.json",
58
+ ".github/release-drafter.yml",
59
+ ".github/pull_request_template.md",
60
+ ".github/dependabot.yml",
61
+ ".github/ISSUE_TEMPLATE/bug_report.yml",
62
+ ".github/ISSUE_TEMPLATE/config.yml",
63
+ ".github/ISSUE_TEMPLATE/feature_request.yml",
64
+ ".github/workflows/test.yml",
65
+ ".github/workflows/autolabeler.yml",
66
+ ".github/workflows/release-drafter.yml",
67
+ ".github/workflows/links.yml",
68
+ ".github/workflows/publish-to-pypi.yml"
69
+ ]
70
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "1.5.0",
3
+ "distance": 0,
4
+ "node": "g1f850ad2b147d75315538154ce50b42e8ad81319",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-06-23"
8
+ }
@@ -1,17 +0,0 @@
1
- openevsehttp/__init__.py,sha256=I6a1mjOZHYiWb_qfCuDuFLOOncrkkB_7uwybtOIujfY,1165
2
- openevsehttp/__main__.py,sha256=EHmSdT7GjAVvHQxvLBTjZXsj_V5SB6B2_kpgUAT7mPM,146
3
- openevsehttp/client.py,sha256=dSvlotG7xxgnDxkI_o2KtIddVw58y6ZgIdJa9gu-WnU,19013
4
- openevsehttp/commands.py,sha256=JGxjmGvE2-eUJ1gD76y_701Qk3Kzab-6XtGeaXXDSb0,27243
5
- openevsehttp/const.py,sha256=-frkFduu8hxEBab9FnwA3D65XHrsyH0W7P9miYsWh90,1726
6
- openevsehttp/exceptions.py,sha256=bqz-tHTW1AYJMKcm0s5M6z5tA6XZgjnCiBLW1XrZ_70,672
7
- openevsehttp/managers.py,sha256=EtQMQziwhoZeqKe2zWY-0yS7zedhuYjYtL5j9xBBCZ0,5380
8
- openevsehttp/properties.py,sha256=xbQfx256FZwNPPn9ryWWOMKliyCChq4ZaTH9NDQVR_8,17968
9
- openevsehttp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- openevsehttp/sensors.py,sha256=zhQSToY_Zp2rOhPnUXT40xS5ZnUavqNGLm4zAFiUUrY,5717
11
- openevsehttp/utils.py,sha256=fPUWL64gFTRw4TtV4WITDAFMJ75VjNhPBaU6diwVlv0,2019
12
- openevsehttp/websocket.py,sha256=dOSemvm7CM5pFb9RaoJSTIM6Tf5xtWMLEBEccKlBUKI,10517
13
- python_openevse_http-1.3.0.dist-info/licenses/LICENSE,sha256=hSB6TOQ7rmwSGb6XzqRjDGMvmUj5_GlacqQin3tegtA,11341
14
- python_openevse_http-1.3.0.dist-info/METADATA,sha256=wgNS8c8fRPdgKGP7odat0kkEWdiDXah7aUhB8b7ghLo,4417
15
- python_openevse_http-1.3.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
16
- python_openevse_http-1.3.0.dist-info/top_level.txt,sha256=u8RUkoEIE33Cjn6gmqiEoVpZ0VZ59WJ3FXBwwOg0CPE,13
17
- python_openevse_http-1.3.0.dist-info/RECORD,,