python-openevse-http 1.7.0__py3-none-any.whl → 1.7.1__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
@@ -26,6 +26,7 @@ from .const import (
26
26
  from .exceptions import (
27
27
  AlreadyListening,
28
28
  AuthenticationError,
29
+ CommandFailedError,
29
30
  MissingMethod,
30
31
  MissingSerial,
31
32
  ParseJSONError,
@@ -186,15 +187,16 @@ class OpenEVSE(CommandsMixin, ManagersMixin, SensorsMixin, PropertiesMixin):
186
187
 
187
188
  if resp.status == 400:
188
189
  if isinstance(response_content, dict) and "msg" in response_content:
189
- _LOGGER.error("Error 400: %s", response_content["msg"])
190
+ msg = str(response_content["msg"])
190
191
  elif (
191
192
  isinstance(response_content, dict)
192
193
  and "error" in response_content
193
194
  ):
194
- _LOGGER.error("Error 400: %s", response_content["error"])
195
+ msg = str(response_content["error"])
195
196
  else:
196
- _LOGGER.error("Error 400: %s", response_content)
197
- raise ParseJSONError
197
+ msg = str(response_content)
198
+ _LOGGER.error("Error 400: %s", msg)
199
+ raise CommandFailedError(msg)
198
200
  if resp.status == 401:
199
201
  _LOGGER.error("Authentication error: %s", response_content)
200
202
  raise AuthenticationError
@@ -271,17 +271,31 @@ class CoreCommandsMixin(BaseCommandMixin):
271
271
 
272
272
  # Strict success check:
273
273
  # 1. Must be a Mapping
274
- # 2. Must have "result" == "OK" OR "success" is True
275
- # 3. Must NOT have an "error" key
276
- # 4. If "msg" is present, it must be "OK" or contain "ok" (case-insensitive)
274
+ # 2. Must NOT have an "error" key
275
+ # 3. Must have "result" in ("OK", "ok", True) OR "success" is True
276
+ # OR "msg" indicating restart acknowledgment ("restart gateway", "ok")
277
277
  success = (
278
278
  isinstance(response, Mapping)
279
- and (response.get("result") == "OK" or response.get("success") is True)
280
279
  and not response.get("error")
280
+ and (
281
+ response.get("result") in ("OK", "ok", True)
282
+ or response.get("success") is True
283
+ or (
284
+ isinstance(response.get("msg"), str)
285
+ and any(
286
+ val in response["msg"].lower()
287
+ for val in ("ok", "restart gateway")
288
+ )
289
+ )
290
+ )
281
291
  )
282
292
  if success and isinstance(response, Mapping) and "msg" in response:
283
293
  msg_val = str(response["msg"]).lower()
284
- if msg_val != "ok" and "ok" not in msg_val:
294
+ if (
295
+ msg_val != "ok"
296
+ and "ok" not in msg_val
297
+ and "restart gateway" not in msg_val
298
+ ):
285
299
  success = False
286
300
 
287
301
  if not success:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python_openevse_http
3
- Version: 1.7.0
3
+ Version: 1.7.1
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,9 +1,9 @@
1
1
  openevsehttp/__init__.py,sha256=QeXl80ozsK6J9PN-jB_83Bde31YXFGgLuUdmArpZAMM,1363
2
2
  openevsehttp/__main__.py,sha256=EHmSdT7GjAVvHQxvLBTjZXsj_V5SB6B2_kpgUAT7mPM,146
3
- openevsehttp/client.py,sha256=2C2SuRkJaC2r38qo57l1gPV86Fqr8Wp72LBnv2R_tuE,22456
3
+ openevsehttp/client.py,sha256=DRiFOtXEznthZCfD5AGwI6isHMkCd7iiwFgo1W_nux8,22482
4
4
  openevsehttp/commands.py,sha256=l9mxdfgpeYzM1M6NPr0KLIaTtTsU10vzcKG1S7Z6O1M,918
5
5
  openevsehttp/commands_base.py,sha256=DnHnB-rAI7zLDIMkL66epct6KnjLsm9OhlRFlOojREI,1934
6
- openevsehttp/commands_core.py,sha256=c6gzsKqBy1t3mHwlZ6TcMMvQresettVeMvYsGhHQ-Ko,18506
6
+ openevsehttp/commands_core.py,sha256=jZZJpD9XolKW0A_1eeec_nB5Kzfbcjih18N7WI_uLvI,18941
7
7
  openevsehttp/commands_diagnostics.py,sha256=j23LX0cB9lb2UBkOpmJjNSBQm87AQijlP6qxotAmiTw,9894
8
8
  openevsehttp/commands_firmware.py,sha256=Ej_EdO8z4arA8wkqfORC0Q_zO9qi7SlC2NmPme03Llg,10308
9
9
  openevsehttp/commands_schedule.py,sha256=kBZp6hPt1qNjoZUVkhRhzB9pXlA--W1UQkQYzxEFQgw,5995
@@ -17,8 +17,8 @@ openevsehttp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  openevsehttp/sensors.py,sha256=XrAaL66jkZqh2IjYXpQI5SJc84GduanBmnbCpbta8lA,5797
18
18
  openevsehttp/utils.py,sha256=fPUWL64gFTRw4TtV4WITDAFMJ75VjNhPBaU6diwVlv0,2019
19
19
  openevsehttp/websocket.py,sha256=yMuLNsB2qYZLtfYRW7-D7NH7rv-qaSTp7F79OajKm_0,10790
20
- python_openevse_http-1.7.0.dist-info/licenses/LICENSE,sha256=hSB6TOQ7rmwSGb6XzqRjDGMvmUj5_GlacqQin3tegtA,11341
21
- python_openevse_http-1.7.0.dist-info/METADATA,sha256=K4DJbt66K11Zqi10mFJhE9krqioECU3Wn9ZY94G4rNY,7011
22
- python_openevse_http-1.7.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
23
- python_openevse_http-1.7.0.dist-info/top_level.txt,sha256=u8RUkoEIE33Cjn6gmqiEoVpZ0VZ59WJ3FXBwwOg0CPE,13
24
- python_openevse_http-1.7.0.dist-info/RECORD,,
20
+ python_openevse_http-1.7.1.dist-info/licenses/LICENSE,sha256=hSB6TOQ7rmwSGb6XzqRjDGMvmUj5_GlacqQin3tegtA,11341
21
+ python_openevse_http-1.7.1.dist-info/METADATA,sha256=5Ymc7plftTfZ9tmIhBRTJws0s9kpIU7KDrVzdYWLQQo,7011
22
+ python_openevse_http-1.7.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
23
+ python_openevse_http-1.7.1.dist-info/top_level.txt,sha256=u8RUkoEIE33Cjn6gmqiEoVpZ0VZ59WJ3FXBwwOg0CPE,13
24
+ python_openevse_http-1.7.1.dist-info/RECORD,,