python-openevse-http 0.4.1__py3-none-any.whl → 0.4.2__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 +3 -3
- openevsehttp/commands.py +18 -3
- {python_openevse_http-0.4.1.dist-info → python_openevse_http-0.4.2.dist-info}/METADATA +1 -1
- {python_openevse_http-0.4.1.dist-info → python_openevse_http-0.4.2.dist-info}/RECORD +7 -7
- {python_openevse_http-0.4.1.dist-info → python_openevse_http-0.4.2.dist-info}/WHEEL +0 -0
- {python_openevse_http-0.4.1.dist-info → python_openevse_http-0.4.2.dist-info}/licenses/LICENSE +0 -0
- {python_openevse_http-0.4.1.dist-info → python_openevse_http-0.4.2.dist-info}/top_level.txt +0 -0
openevsehttp/client.py
CHANGED
|
@@ -183,12 +183,12 @@ class OpenEVSE(CommandsMixin, ManagersMixin, SensorsMixin, PropertiesMixin):
|
|
|
183
183
|
return (False, "")
|
|
184
184
|
return (value["cmd"], value["ret"])
|
|
185
185
|
|
|
186
|
-
async def update(self) -> None:
|
|
186
|
+
async def update(self, force_status: bool = False) -> None:
|
|
187
187
|
"""Update the values."""
|
|
188
188
|
# TODO: add addiontal endpoints to update
|
|
189
189
|
urls = [f"{self.url}config"]
|
|
190
190
|
|
|
191
|
-
if not self._ws_listening:
|
|
191
|
+
if not self._ws_listening or force_status or self.ota_update:
|
|
192
192
|
urls = [f"{self.url}status", f"{self.url}config"]
|
|
193
193
|
|
|
194
194
|
for url in urls:
|
|
@@ -196,7 +196,7 @@ class OpenEVSE(CommandsMixin, ManagersMixin, SensorsMixin, PropertiesMixin):
|
|
|
196
196
|
response = await self.process_request(url, method="get")
|
|
197
197
|
if "/status" in url:
|
|
198
198
|
if isinstance(response, Mapping) and "error" not in response:
|
|
199
|
-
self._status
|
|
199
|
+
self._status.update(dict(response))
|
|
200
200
|
_LOGGER.debug("Status update: %s", self._status)
|
|
201
201
|
elif isinstance(response, Mapping):
|
|
202
202
|
_LOGGER.warning(
|
openevsehttp/commands.py
CHANGED
|
@@ -39,13 +39,22 @@ class CommandsMixin:
|
|
|
39
39
|
async def send_command(self, command: str) -> tuple:
|
|
40
40
|
raise NotImplementedError
|
|
41
41
|
|
|
42
|
-
async def update(self) -> None:
|
|
42
|
+
async def update(self, force_status: bool = False) -> None:
|
|
43
43
|
raise NotImplementedError
|
|
44
44
|
|
|
45
45
|
def _normalize_response(self, response: Any) -> dict[str, Any] | list[Any]:
|
|
46
46
|
"""Normalize response to a dict or list."""
|
|
47
47
|
raise NotImplementedError
|
|
48
48
|
|
|
49
|
+
def _flag_ota_if_started(self, response: Any) -> None:
|
|
50
|
+
"""Flag OTA as active if response indicates firmware update has started."""
|
|
51
|
+
normalized = self._normalize_response(response)
|
|
52
|
+
if isinstance(normalized, dict) and (
|
|
53
|
+
normalized.get("msg") == "started"
|
|
54
|
+
or normalized.get("msg") in SUCCESS_ANSWERS
|
|
55
|
+
):
|
|
56
|
+
self._status["ota_update"] = 1
|
|
57
|
+
|
|
49
58
|
async def get_schedule(self) -> Mapping[str, Any] | list[Any]:
|
|
50
59
|
"""Return the current schedule."""
|
|
51
60
|
url = f"{self.url}schedule"
|
|
@@ -473,7 +482,11 @@ class CommandsMixin:
|
|
|
473
482
|
"Uploading firmware binary to %s (%d bytes)", url, len(firmware_bytes)
|
|
474
483
|
)
|
|
475
484
|
# Rapi is mapped to http request's data kwarg in process_request
|
|
476
|
-
|
|
485
|
+
response = await self.process_request(
|
|
486
|
+
url=url, method="post", rapi=form_data
|
|
487
|
+
)
|
|
488
|
+
self._flag_ota_if_started(response)
|
|
489
|
+
return response
|
|
477
490
|
|
|
478
491
|
# 2. Resolve URL from GitHub if not specified
|
|
479
492
|
if firmware_url is None:
|
|
@@ -489,7 +502,9 @@ class CommandsMixin:
|
|
|
489
502
|
_LOGGER.debug(
|
|
490
503
|
"Requesting OpenEVSE to download and update from: %s", firmware_url
|
|
491
504
|
)
|
|
492
|
-
|
|
505
|
+
response = await self.process_request(url=url, method="post", data=data)
|
|
506
|
+
self._flag_ota_if_started(response)
|
|
507
|
+
return response
|
|
493
508
|
|
|
494
509
|
async def set_led_brightness(self, level: int) -> None:
|
|
495
510
|
"""Set LED brightness level."""
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
openevsehttp/__init__.py,sha256=I6a1mjOZHYiWb_qfCuDuFLOOncrkkB_7uwybtOIujfY,1165
|
|
2
2
|
openevsehttp/__main__.py,sha256=EHmSdT7GjAVvHQxvLBTjZXsj_V5SB6B2_kpgUAT7mPM,146
|
|
3
|
-
openevsehttp/client.py,sha256=
|
|
4
|
-
openevsehttp/commands.py,sha256=
|
|
3
|
+
openevsehttp/client.py,sha256=2SGL0RKZp08t_hGXHKIIRGk8wyrNJRcSXQE7nc0P9UU,17951
|
|
4
|
+
openevsehttp/commands.py,sha256=XJO_FPdkzqBW7AU4VvBGktZ84TxRQ3a358mNAkqXQRw,24151
|
|
5
5
|
openevsehttp/const.py,sha256=y-2hGv_PCal_-VCSGC7IIyzQYtfeVdq3MjOhBWIdZvc,1440
|
|
6
6
|
openevsehttp/exceptions.py,sha256=bqz-tHTW1AYJMKcm0s5M6z5tA6XZgjnCiBLW1XrZ_70,672
|
|
7
7
|
openevsehttp/managers.py,sha256=kEX1ZD9u-FY0UEZJsxeFEGBSGzSlkbBc0kmxCiMJtJw,5373
|
|
@@ -9,8 +9,8 @@ openevsehttp/properties.py,sha256=9fmJo6xU8im-Dd2QoH8f2E-0veD8uL1QQYiaERvIRr8,17
|
|
|
9
9
|
openevsehttp/sensors.py,sha256=sJP2FPnU1Lk5S3VUyFT14JM1nKEBQPsjl-DiZI-pZrs,4673
|
|
10
10
|
openevsehttp/utils.py,sha256=e3HH_jwZgb1iBWJgIoMOM0JPrQNwXyVdOx5vTWOh4T0,858
|
|
11
11
|
openevsehttp/websocket.py,sha256=Mi_WFmlT3-9i6bbHIN6ua09SD8CpIle2vRXB3HyWzmM,10066
|
|
12
|
-
python_openevse_http-0.4.
|
|
13
|
-
python_openevse_http-0.4.
|
|
14
|
-
python_openevse_http-0.4.
|
|
15
|
-
python_openevse_http-0.4.
|
|
16
|
-
python_openevse_http-0.4.
|
|
12
|
+
python_openevse_http-0.4.2.dist-info/licenses/LICENSE,sha256=hSB6TOQ7rmwSGb6XzqRjDGMvmUj5_GlacqQin3tegtA,11341
|
|
13
|
+
python_openevse_http-0.4.2.dist-info/METADATA,sha256=gK5gBUi_Jy8Zza4bAxOjZ51_GtLY0ILses5rYUEJBT8,4363
|
|
14
|
+
python_openevse_http-0.4.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
15
|
+
python_openevse_http-0.4.2.dist-info/top_level.txt,sha256=u8RUkoEIE33Cjn6gmqiEoVpZ0VZ59WJ3FXBwwOg0CPE,13
|
|
16
|
+
python_openevse_http-0.4.2.dist-info/RECORD,,
|
|
File without changes
|
{python_openevse_http-0.4.1.dist-info → python_openevse_http-0.4.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|