anycubic-cloud-api 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 (47) hide show
  1. {anycubic_cloud_api-0.3.2/src/anycubic_cloud_api.egg-info → anycubic_cloud_api-0.3.3}/PKG-INFO +1 -1
  2. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/pyproject.toml +1 -1
  3. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/printer.py +27 -13
  4. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3/src/anycubic_cloud_api.egg-info}/PKG-INFO +1 -1
  5. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/tests/test_lan_reports.py +39 -0
  6. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/LICENSE +0 -0
  7. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/README.md +0 -0
  8. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/setup.cfg +0 -0
  9. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/__init__.py +0 -0
  10. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/anycubic_api.py +0 -0
  11. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/api/base.py +0 -0
  12. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/api/functions.py +0 -0
  13. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/api/mqtt.py +0 -0
  14. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/const/api_endpoints.py +0 -0
  15. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/const/const.py +0 -0
  16. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/const/enums.py +0 -0
  17. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/const/lan.py +0 -0
  18. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/const/mqtt.py +0 -0
  19. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/consumable.py +0 -0
  20. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/files.py +0 -0
  21. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/gcode_file.py +0 -0
  22. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/orders.py +0 -0
  23. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/print_response.py +0 -0
  24. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/print_speed_mode.py +0 -0
  25. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/printer_properties.py +0 -0
  26. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/printing_settings.py +0 -0
  27. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/data_models/project.py +0 -0
  28. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/exceptions/error_strings.py +0 -0
  29. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/exceptions/exceptions.py +0 -0
  30. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/helpers/helpers.py +0 -0
  31. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/lan/__init__.py +0 -0
  32. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/lan/client.py +0 -0
  33. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/lan/handshake.py +0 -0
  34. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/models/auth.py +0 -0
  35. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/models/cloud_upload.py +0 -0
  36. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/models/http.py +0 -0
  37. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/resources/anycubic_mqqt_tls_ca.crt +0 -0
  38. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/resources/anycubic_mqqt_tls_client.crt +0 -0
  39. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api/resources/anycubic_mqqt_tls_client.key +0 -0
  40. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api.egg-info/SOURCES.txt +0 -0
  41. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api.egg-info/dependency_links.txt +0 -0
  42. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api.egg-info/requires.txt +0 -0
  43. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/src/anycubic_cloud_api.egg-info/top_level.txt +0 -0
  44. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/tests/test_axis_position.py +0 -0
  45. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/tests/test_lan_client.py +0 -0
  46. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/tests/test_lan_handshake.py +0 -0
  47. {anycubic_cloud_api-0.3.2 → anycubic_cloud_api-0.3.3}/tests/test_partial_reports.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anycubic-cloud-api
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Async client for the Anycubic Cloud API and its MQTT stream
5
5
  Author: Nino Bondonno
6
6
  Maintainer: Nino Bondonno
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "anycubic-cloud-api"
7
- version = "0.3.2"
7
+ version = "0.3.3"
8
8
  description = "Async client for the Anycubic Cloud API and its MQTT stream"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -375,6 +375,26 @@ class AnycubicPrinter:
375
375
  if not self._ignore_init_errors:
376
376
  raise e
377
377
 
378
+ def _apply_current_temps(self, hotbed: Any, nozzle: Any) -> None:
379
+ """Record the live temperatures, creating the holder if need be.
380
+
381
+ The cloud builds this object when the printer is first fetched. With
382
+ only a local connection there is no such fetch, so it has to be made
383
+ from the first report that carries temperatures -- otherwise every
384
+ temperature entity reads unavailable on a working printer.
385
+ """
386
+ if hotbed is None or nozzle is None:
387
+ return
388
+
389
+ if self._parameter is None:
390
+ self._set_parameter({
391
+ 'curr_hotbed_temp': hotbed,
392
+ 'curr_nozzle_temp': nozzle,
393
+ })
394
+ return
395
+
396
+ self._parameter.update_current_temps(hotbed, nozzle)
397
+
378
398
  def _set_parameter(
379
399
  self,
380
400
  parameter: dict[str, Any] | None,
@@ -893,8 +913,7 @@ class AnycubicPrinter:
893
913
  self._chamber_temp = data.get('curr_chamber_temp')
894
914
  self._target_chamber_temp = data.get('target_chamber_temp')
895
915
 
896
- if self.parameter:
897
- self.parameter.update_current_temps(curr_hotbed, curr_nozzle)
916
+ self._apply_current_temps(curr_hotbed, curr_nozzle)
898
917
 
899
918
  if self._latest_project:
900
919
  self._latest_project.update_target_temps(target_hotbed, target_nozzle)
@@ -1021,12 +1040,8 @@ class AnycubicPrinter:
1021
1040
  # each is applied only if it is actually there.
1022
1041
  settings = data.get('settings') or {}
1023
1042
 
1024
- if (
1025
- self.parameter
1026
- and 'curr_hotbed_temp' in data
1027
- and 'curr_nozzle_temp' in data
1028
- ):
1029
- self.parameter.update_current_temps(
1043
+ if 'curr_hotbed_temp' in data and 'curr_nozzle_temp' in data:
1044
+ self._apply_current_temps(
1030
1045
  data['curr_hotbed_temp'],
1031
1046
  data['curr_nozzle_temp'],
1032
1047
  )
@@ -1257,11 +1272,10 @@ class AnycubicPrinter:
1257
1272
  temp = data.get('temp')
1258
1273
 
1259
1274
  if temp:
1260
- if self.parameter:
1261
- self.parameter.update_current_temps(
1262
- temp.get('curr_hotbed_temp'),
1263
- temp.get('curr_nozzle_temp'),
1264
- )
1275
+ self._apply_current_temps(
1276
+ temp.get('curr_hotbed_temp'),
1277
+ temp.get('curr_nozzle_temp'),
1278
+ )
1265
1279
  # A Kobra S1 reports chamber temperatures of zero because it has no
1266
1280
  # chamber sensor, so they are kept raw rather than turned into an
1267
1281
  # always-zero entity.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anycubic-cloud-api
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Async client for the Anycubic Cloud API and its MQTT stream
5
5
  Author: Nino Bondonno
6
6
  Maintainer: Nino Bondonno
@@ -296,3 +296,42 @@ class TestAvailabilityFromLocalReports:
296
296
  apply(printer, report)
297
297
 
298
298
  assert printer.printer_online is True
299
+
300
+
301
+ class TestTemperaturesWithoutTheCloud:
302
+ """The cloud builds the temperature holder; a local-only printer has none."""
303
+
304
+ def test_an_info_report_creates_it(self):
305
+ printer = make_printer()
306
+
307
+ apply(printer, INFO_REPORT)
308
+
309
+ assert printer.parameter is not None
310
+ assert printer.curr_nozzle_temp == 34
311
+ assert printer.curr_hotbed_temp == 31
312
+
313
+ def test_a_temperature_report_creates_it(self):
314
+ printer = make_printer()
315
+
316
+ apply(printer, TestQueryActionReplies.TEMPERATURE)
317
+
318
+ assert printer.curr_nozzle_temp == 34
319
+
320
+ def test_later_reports_update_it(self):
321
+ printer = make_printer()
322
+ apply(printer, INFO_REPORT)
323
+
324
+ hotter = {**INFO_REPORT, "data": {**INFO_REPORT["data"]}}
325
+ hotter["data"]["temp"] = {**hotter["data"]["temp"], "curr_nozzle_temp": 210}
326
+ apply(printer, hotter)
327
+
328
+ assert printer.curr_nozzle_temp == 210
329
+
330
+ def test_a_report_without_temperatures_leaves_it_alone(self):
331
+ printer = make_printer()
332
+ report = {**INFO_REPORT, "data": {**INFO_REPORT["data"]}}
333
+ del report["data"]["temp"]
334
+
335
+ apply(printer, report)
336
+
337
+ assert printer.parameter is None