python-openevse-http 0.4.2__py3-none-any.whl → 0.4.3__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/commands.py CHANGED
@@ -53,7 +53,12 @@ class CommandsMixin:
53
53
  normalized.get("msg") == "started"
54
54
  or normalized.get("msg") in SUCCESS_ANSWERS
55
55
  ):
56
+ _LOGGER.debug("Firmware update started, setting ota_update flag.")
56
57
  self._status["ota_update"] = 1
58
+ else:
59
+ _LOGGER.debug(
60
+ "Firmware update response did not indicate start: %s", normalized
61
+ )
57
62
 
58
63
  async def get_schedule(self) -> Mapping[str, Any] | list[Any]:
59
64
  """Return the current schedule."""
@@ -131,7 +136,12 @@ class CommandsMixin:
131
136
  time_limit: int | None = None,
132
137
  auto_release: bool | None = None,
133
138
  ) -> Any:
134
- """Set the manual override status."""
139
+ """Set the manual override status.
140
+
141
+ Fetches the current override payload first and merges existing values
142
+ into the request payload. This prevents the firmware from clearing/resetting
143
+ previously configured properties that are not passed in the function call.
144
+ """
135
145
  if not self._version_check("4.0.1"):
136
146
  _LOGGER.debug("Feature not supported for older firmware.")
137
147
  raise UnsupportedFeature
@@ -149,6 +159,18 @@ class CommandsMixin:
149
159
  raise ValueError
150
160
 
151
161
  data: dict[str, Any] = {}
162
+ if isinstance(response, Mapping):
163
+ for key in (
164
+ "state",
165
+ "charge_current",
166
+ "max_current",
167
+ "energy_limit",
168
+ "time_limit",
169
+ "auto_release",
170
+ ):
171
+ if key in response:
172
+ data[key] = response[key]
173
+
152
174
  if auto_release is not None:
153
175
  data["auto_release"] = auto_release
154
176
 
@@ -381,6 +403,7 @@ class CommandsMixin:
381
403
  url = f"{base_url}ESP32_WiFi_V4.x/releases/latest"
382
404
  else:
383
405
  url = f"{base_url}ESP8266_WiFi_v2.x/releases/latest"
406
+ _LOGGER.debug("Firmware check URL: %s", url)
384
407
  except AwesomeVersionCompareException:
385
408
  _LOGGER.debug("Non-semver firmware version detected.")
386
409
  return None
@@ -412,6 +435,7 @@ class CommandsMixin:
412
435
  method,
413
436
  )
414
437
  async with http_method(url) as resp:
438
+ _LOGGER.debug("Firmware check response status: %d", resp.status)
415
439
  if resp.status != 200:
416
440
  return None
417
441
  message = await resp.text()
@@ -422,19 +446,51 @@ class CommandsMixin:
422
446
  return None
423
447
 
424
448
  if not isinstance(message, dict):
449
+ _LOGGER.debug(
450
+ "Invalid JSON response type from GitHub: %s", type(message)
451
+ )
425
452
  return None
426
453
 
454
+ _LOGGER.debug(
455
+ "GitHub release metadata successfully fetched for version: %s",
456
+ message.get("tag_name"),
457
+ )
458
+
427
459
  # Match browser_download_url based on buildenv
428
460
  download_url = None
429
461
  buildenv = self._config.get("buildenv")
430
462
  assets = message.get("assets", [])
431
463
 
432
- if buildenv and assets:
464
+ if not buildenv:
465
+ _LOGGER.debug(
466
+ "Cannot resolve firmware asset: missing buildenv in config."
467
+ )
468
+ assets = []
469
+ elif not isinstance(assets, list):
470
+ _LOGGER.debug("Invalid GitHub assets payload: %r", assets)
471
+ assets = []
472
+ else:
473
+ _LOGGER.debug("Matching buildenv '%s' against assets", buildenv)
433
474
  target_filename = f"{buildenv}.bin"
434
475
  for asset in assets:
476
+ if not isinstance(asset, Mapping):
477
+ continue
435
478
  if asset.get("name") == target_filename:
436
479
  download_url = asset.get("browser_download_url")
480
+ _LOGGER.debug("Found matching firmware asset: %s", download_url)
437
481
  break
482
+ if buildenv and not download_url:
483
+ _LOGGER.debug(
484
+ "Could not find asset matching target filename '%s.bin' in assets: %s",
485
+ buildenv,
486
+ [
487
+ asset.get("name")
488
+ for asset in assets
489
+ if isinstance(asset, Mapping)
490
+ ]
491
+ if assets
492
+ else "None",
493
+ )
438
494
 
439
495
  return {
440
496
  "latest_version": message.get("tag_name"),
@@ -461,10 +517,16 @@ class CommandsMixin:
461
517
  raise UnsupportedFeature
462
518
 
463
519
  if firmware_bytes is not None and firmware_url is not None:
520
+ _LOGGER.error("Cannot specify both firmware_bytes and firmware_url")
464
521
  raise ValueError("Cannot specify both firmware_bytes and firmware_url")
465
522
 
523
+ if firmware_bytes is not None and len(firmware_bytes) == 0:
524
+ _LOGGER.error("Empty firmware bytes provided")
525
+ raise ValueError("Empty firmware bytes provided")
526
+
466
527
  if firmware_url is not None:
467
528
  if not isinstance(firmware_url, str) or not firmware_url.strip():
529
+ _LOGGER.error("Invalid firmware_url: %s", firmware_url)
468
530
  raise ValueError("Invalid firmware_url")
469
531
 
470
532
  url = f"{self.url}update"
@@ -485,13 +547,20 @@ class CommandsMixin:
485
547
  response = await self.process_request(
486
548
  url=url, method="post", rapi=form_data
487
549
  )
550
+ _LOGGER.debug("Firmware upload request completed. Response: %s", response)
488
551
  self._flag_ota_if_started(response)
489
552
  return response
490
553
 
491
554
  # 2. Resolve URL from GitHub if not specified
492
555
  if firmware_url is None:
556
+ _LOGGER.debug(
557
+ "No firmware URL provided. Resolving latest matching firmware from GitHub."
558
+ )
493
559
  check_result = await self.firmware_check()
494
560
  if not check_result or not check_result.get("browser_download_url"):
561
+ _LOGGER.error(
562
+ "Could not resolve latest firmware download URL from GitHub."
563
+ )
495
564
  raise RuntimeError(
496
565
  "Could not resolve latest firmware download URL from GitHub."
497
566
  )
@@ -503,6 +572,7 @@ class CommandsMixin:
503
572
  "Requesting OpenEVSE to download and update from: %s", firmware_url
504
573
  )
505
574
  response = await self.process_request(url=url, method="post", data=data)
575
+ _LOGGER.debug("Firmware update request completed. Response: %s", response)
506
576
  self._flag_ota_if_started(response)
507
577
  return response
508
578
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_openevse_http
3
- Version: 0.4.2
3
+ Version: 0.4.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
@@ -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
3
  openevsehttp/client.py,sha256=2SGL0RKZp08t_hGXHKIIRGk8wyrNJRcSXQE7nc0P9UU,17951
4
- openevsehttp/commands.py,sha256=XJO_FPdkzqBW7AU4VvBGktZ84TxRQ3a358mNAkqXQRw,24151
4
+ openevsehttp/commands.py,sha256=vZFzNFg6-DqbpavTulypXOGCDwPChvBzoxIHXBlJrBc,27216
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.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,,
12
+ python_openevse_http-0.4.3.dist-info/licenses/LICENSE,sha256=hSB6TOQ7rmwSGb6XzqRjDGMvmUj5_GlacqQin3tegtA,11341
13
+ python_openevse_http-0.4.3.dist-info/METADATA,sha256=ThGhSK3mu1cGbRBLb4a5El7qhUNERBu6rC9tjdiHd20,4363
14
+ python_openevse_http-0.4.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
15
+ python_openevse_http-0.4.3.dist-info/top_level.txt,sha256=u8RUkoEIE33Cjn6gmqiEoVpZ0VZ59WJ3FXBwwOg0CPE,13
16
+ python_openevse_http-0.4.3.dist-info/RECORD,,