PyPlumIO 0.7.8__tar.gz → 0.7.8.post2__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 (154) hide show
  1. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/PKG-INFO +1 -1
  2. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/cli.rst +18 -6
  3. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/cli/__init__.py +1 -1
  4. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/cli/app.py +86 -9
  5. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/cli/state.py +11 -12
  6. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyproject.toml +1 -1
  7. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/cli/test_app.py +309 -14
  8. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/cli/test_init.py +2 -1
  9. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/cli/test_state.py +88 -0
  10. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/cli/test_ui.py +20 -12
  11. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/.gitignore +0 -0
  12. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/LICENSE +0 -0
  13. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/README.md +0 -0
  14. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/Makefile +0 -0
  15. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/make.bat +0 -0
  16. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/callbacks.rst +0 -0
  17. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/conf.py +0 -0
  18. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/connecting.rst +0 -0
  19. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/frames.rst +0 -0
  20. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/index.rst +0 -0
  21. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/mixers_thermostats.rst +0 -0
  22. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/protocol.rst +0 -0
  23. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/reading.rst +0 -0
  24. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/schedules.rst +0 -0
  25. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/docs/source/writing.rst +0 -0
  26. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/__init__.py +0 -0
  27. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/__main__.py +0 -0
  28. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/cli/codegen.py +0 -0
  29. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/cli/model.py +0 -0
  30. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/cli/session.py +0 -0
  31. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/cli/ui.py +0 -0
  32. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/connection.py +0 -0
  33. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/const.py +0 -0
  34. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/data_types.py +0 -0
  35. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/devices/__init__.py +0 -0
  36. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/devices/ecomax.py +0 -0
  37. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/devices/ecoster.py +0 -0
  38. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/devices/mixer.py +0 -0
  39. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/devices/thermostat.py +0 -0
  40. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/exceptions.py +0 -0
  41. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/filters.py +0 -0
  42. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/frames/__init__.py +0 -0
  43. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/frames/messages.py +0 -0
  44. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/frames/requests.py +0 -0
  45. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/frames/responses.py +0 -0
  46. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/helpers/__init__.py +0 -0
  47. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/helpers/async_cache.py +0 -0
  48. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/helpers/event_manager.py +0 -0
  49. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/helpers/task_manager.py +0 -0
  50. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/parameters/__init__.py +0 -0
  51. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/parameters/custom/__init__.py +0 -0
  52. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/parameters/custom/ecomax_350p2_zf.py +0 -0
  53. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/parameters/custom/ecomax_860d3_hb.py +0 -0
  54. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/parameters/custom/ecomax_860p4_nm_touch.py +0 -0
  55. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/parameters/ecomax.py +0 -0
  56. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/parameters/mixer.py +0 -0
  57. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/parameters/thermostat.py +0 -0
  58. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/protocol.py +0 -0
  59. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/py.typed +0 -0
  60. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/stream.py +0 -0
  61. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/__init__.py +0 -0
  62. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/alerts.py +0 -0
  63. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/ecomax_parameters.py +0 -0
  64. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/ecomax_service_parameters.py +0 -0
  65. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/frame_versions.py +0 -0
  66. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/mixer_parameters.py +0 -0
  67. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/network_info.py +0 -0
  68. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/product_info.py +0 -0
  69. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/program_version.py +0 -0
  70. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/regulator_data.py +0 -0
  71. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/regulator_data_schema.py +0 -0
  72. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/schedules.py +0 -0
  73. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/sensor_data.py +0 -0
  74. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/structures/thermostat_parameters.py +0 -0
  75. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/pyplumio/utils.py +0 -0
  76. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/__init__.py +0 -0
  77. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/cli/__init__.py +0 -0
  78. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/cli/conftest.py +0 -0
  79. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/cli/test_codegen.py +0 -0
  80. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/cli/test_model.py +0 -0
  81. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/cli/test_session.py +0 -0
  82. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/conftest.py +0 -0
  83. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/devices/__init__.py +0 -0
  84. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/devices/test_ecomax.py +0 -0
  85. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/devices/test_ecoster.py +0 -0
  86. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/devices/test_init.py +0 -0
  87. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/devices/test_mixer.py +0 -0
  88. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/devices/test_thermostat.py +0 -0
  89. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/frames/test_init.py +0 -0
  90. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/frames/test_messages.py +0 -0
  91. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/frames/test_requests.py +0 -0
  92. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/frames/test_responses.py +0 -0
  93. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/helpers/__init__.py +0 -0
  94. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/helpers/test_async_cache.py +0 -0
  95. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/helpers/test_event_manager.py +0 -0
  96. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/helpers/test_task_manager.py +0 -0
  97. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/helpers/test_uid.py +0 -0
  98. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/__init__.py +0 -0
  99. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/custom/__init__.py +0 -0
  100. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/custom/test_ecomax_350p2_zf.py +0 -0
  101. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/custom/test_ecomax_860d3_hb.py +0 -0
  102. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/custom/test_ecomax_860p4_nm_touch.py +0 -0
  103. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/custom/test_init.py +0 -0
  104. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/test_ecomax.py +0 -0
  105. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/test_init.py +0 -0
  106. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/test_mixers.py +0 -0
  107. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/parameters/test_thermostats.py +0 -0
  108. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/ruff.toml +0 -0
  109. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/structures/__init__.py +0 -0
  110. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/structures/test_alerts.py +0 -0
  111. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/structures/test_ecomax_parameters.py +0 -0
  112. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/structures/test_ecomax_service_parameters.py +0 -0
  113. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/structures/test_frame_versions.py +0 -0
  114. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/structures/test_mixer_parameters.py +0 -0
  115. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/structures/test_product_info.py +0 -0
  116. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/structures/test_program_version.py +0 -0
  117. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/structures/test_schedules.py +0 -0
  118. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/test_connection.py +0 -0
  119. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/test_data_types.py +0 -0
  120. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/test_filters.py +0 -0
  121. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/test_init.py +0 -0
  122. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/test_main.py +0 -0
  123. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/test_protocol.py +0 -0
  124. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/test_stream.py +0 -0
  125. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/test_utils.py +0 -0
  126. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/messages/regulator_data.json +0 -0
  127. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/messages/sensor_data.json +0 -0
  128. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/parameters/ecomax_350p2_zf.json +0 -0
  129. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/parameters/ecomax_860d3_hb.json +0 -0
  130. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/parameters/ecomax_860p4_nm_touch.json +0 -0
  131. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/alerts.json +0 -0
  132. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/ecomax_control.json +0 -0
  133. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/ecomax_parameters.json +0 -0
  134. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/ecomax_service_parameters.json +0 -0
  135. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/mixer_parameters.json +0 -0
  136. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/set_ecomax_parameter.json +0 -0
  137. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/set_ecomax_service_parameter.json +0 -0
  138. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/set_mixer_parameter.json +0 -0
  139. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/set_schedule.json +0 -0
  140. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/set_thermostat_parameter.json +0 -0
  141. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/requests/thermostat_parameters.json +0 -0
  142. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/alerts.json +0 -0
  143. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/device_available.json +0 -0
  144. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/ecomax_parameters.json +0 -0
  145. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/ecomax_service_parameters.json +0 -0
  146. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/mixer_parameters.json +0 -0
  147. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/password.json +0 -0
  148. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/program_version.json +0 -0
  149. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/regulator_data_schema.json +0 -0
  150. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/schedules.json +0 -0
  151. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/thermostat_parameters.json +0 -0
  152. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/responses/uid.json +0 -0
  153. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/unknown/unknown_ecomax_parameter.json +0 -0
  154. {pyplumio-0.7.8 → pyplumio-0.7.8.post2}/tests/testdata/unknown/unknown_mixer_parameter.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: PyPlumIO
3
- Version: 0.7.8
3
+ Version: 0.7.8.post2
4
4
  Summary: PyPlumIO is a native ecoNET library for Plum ecoMAX controllers.
5
5
  Project-URL: Documentation, https://pyplumio.denpa.pro
6
6
  Project-URL: Source Code, https://github.com/denpamusic/PyPlumIO
@@ -13,7 +13,7 @@ Windows Executable
13
13
  On Windows, download the standalone ``pyplumio.exe`` executable from the
14
14
  `GitHub Releases <https://github.com/denpamusic/PyPlumIO/releases>`_ page. No Python
15
15
  installation is required—double-click ``pyplumio.exe`` or run it from Command Prompt
16
- or PowerShell. Generated files (or ``<model_slug>.zip``) are saved in the working
16
+ or PowerShell. Generated files (and optional ``<model_slug>.zip``) are saved in the working
17
17
  directory where ``pyplumio.exe`` is launched unless ``--output`` is specified.
18
18
 
19
19
  Python Package
@@ -55,7 +55,7 @@ The CLI supports the following arguments:
55
55
  --output DIR Output directory for generated files (default: current working directory).
56
56
  --interval SECONDS Polling interval in seconds (default: 2.0).
57
57
  --baudrate BAUDRATE Serial baudrate (default: 115200).
58
- -z, --zip Save output as a ZIP archive.
58
+ -z, --zip Also save output as a ZIP archive.
59
59
 
60
60
  Interactive Connection Setup
61
61
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -83,6 +83,14 @@ this phase, a connection-lost error is reported instead. Once startup succeeds,
83
83
  the full-screen interface opens with the parameter table already filled and keeps
84
84
  polling in the background.
85
85
 
86
+ If ``<output>/pyplumio/parameters/custom/<model_slug>.py`` exists on disk with a
87
+ matching model and product ID signature, the CLI loads its mapped descriptions,
88
+ overrides, and comments automatically—taking precedence over bundled definitions in
89
+ PyPlumIO—and displays a confirmation notice in the status bar. If no local file exists,
90
+ bundled definitions for the detected model are loaded when available. If an existing
91
+ local file fails to load or has a mismatched signature, a warning is displayed and the
92
+ CLI falls back to built-in definitions.
93
+
86
94
  The interface consists of:
87
95
 
88
96
  - **Header**: Inverted top bar showing connected controller model, product ID, connection URL, and last update timestamp.
@@ -131,12 +139,12 @@ Press ``Ctrl+S`` to save generated files. At least one parameter must be mapped;
131
139
 
132
140
  Nothing to save: map at least one parameter first.
133
141
 
134
- Unless ``-z`` / ``--zip`` was passed on the command line, you will be asked ``Save as a ZIP archive? [y/N]``:
142
+ Unless ``-z`` / ``--zip`` was passed on the command line, you will be asked ``Also save as a ZIP archive? [y/N]``:
135
143
 
136
- - Answering ``n`` (or pressing Enter) writes the three generated files directly into the ``<output>`` directory tree. If ``<output>/pyplumio/parameters/custom/<model_slug>.py`` already exists, you will be prompted to confirm overwrite (``Overwrite existing <model_slug>.py? [y/N]``).
137
- - Answering ``y`` (or starting the CLI with ``-z`` / ``--zip``) saves a single ``<output>/<model_slug>.zip`` archive containing the same repository-relative paths inside, which can be attached directly to a GitHub issue instead of opening a PR. If ``<output>/<model_slug>.zip`` already exists, you will be prompted to confirm overwrite (``Overwrite existing <model_slug>.zip? [y/N]``).
144
+ - Answering ``n`` (or pressing Enter) writes only the three generated files directly into the ``<output>`` directory tree. If ``<output>/pyplumio/parameters/custom/<model_slug>.py`` already exists, you will be prompted to confirm overwrite (``Overwrite existing <model_slug>.py? [y/N]``).
145
+ - Answering ``y`` (or starting the CLI with ``-z`` / ``--zip``) writes the three generated files into ``<output>`` and also saves ``<output>/<model_slug>.zip`` containing the same repository-relative paths inside, which can be attached directly to a GitHub issue instead of opening a PR. If ``<model_slug>.py``, ``<model_slug>.zip``, or both already exist, you will be prompted to confirm overwrite (``Overwrite existing <target>? [y/N]``, or ``Overwrite existing <model_slug>.py and <model_slug>.zip? [y/N]`` when both exist).
138
146
 
139
- The utility produces the following three files (either on disk or inside ``<output>/<model_slug>.zip``):
147
+ The utility produces the following three files on disk (and inside ``<output>/<model_slug>.zip`` when ZIP output is requested):
140
148
 
141
149
  1. **Custom Parameter Module**:
142
150
  ``<output>/pyplumio/parameters/custom/<model_slug>.py``
@@ -150,6 +158,10 @@ The utility produces the following three files (either on disk or inside ``<outp
150
158
  ``<output>/tests/testdata/parameters/<model_slug>.json``
151
159
  Raw frame capture used for reproducible testing.
152
160
 
161
+ Restarting the CLI with the same ``--output`` directory (or working directory)
162
+ automatically reloads these saved definitions whether running from source, an installed
163
+ package, or standalone ``pyplumio.exe``.
164
+
153
165
  Press ``Ctrl+Q`` to exit the application cleanly.
154
166
 
155
167
  Contributing Mapped Parameters
@@ -91,7 +91,7 @@ def _run_cli(argv: Sequence[str] | None) -> int:
91
91
  "--baudrate", type=int, default=DEFAULT_BAUDRATE, help="baudrate"
92
92
  )
93
93
  parser.add_argument(
94
- "-z", "--zip", action="store_true", help="save output as a ZIP archive"
94
+ "-z", "--zip", action="store_true", help="also save output as a ZIP archive"
95
95
  )
96
96
  try:
97
97
  return asyncio.run(run_app(parser.parse_args(argv)))
@@ -3,9 +3,11 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import argparse
6
+ import asyncio
6
7
  from collections.abc import Iterator, Sequence
7
8
  from contextlib import contextmanager, suppress
8
9
  from enum import StrEnum, unique
10
+ import importlib.util
9
11
  import inspect
10
12
  import logging
11
13
  from pathlib import Path
@@ -27,9 +29,13 @@ from pyplumio.exceptions import PyPlumIOError
27
29
  from pyplumio.parameters import ParameterValues
28
30
  from pyplumio.parameters.custom import (
29
31
  CustomParameters,
32
+ custom_class_name,
30
33
  load_custom_parameters,
31
34
  model_slug,
32
35
  )
36
+ from pyplumio.structures.product_info import ProductInfo
37
+
38
+ _LOGGER = logging.getLogger(__name__)
33
39
 
34
40
 
35
41
  @unique
@@ -114,22 +120,82 @@ def _write_status(message: str) -> None:
114
120
 
115
121
 
116
122
  def _load_comments(
117
- custom_parameters: CustomParameters, output_dir: Path, slug: str
123
+ custom_parameters: CustomParameters,
124
+ output_dir: Path,
125
+ slug: str,
126
+ *,
127
+ prefer_output: bool = True,
118
128
  ) -> dict[int, str]:
119
129
  """Load parameter comments from output directory or module source."""
120
- path = custom_module_path(output_dir, slug)
121
- if not path.is_file() and (
122
- source_file := inspect.getsourcefile(type(custom_parameters))
123
- ):
124
- path = Path(source_file)
130
+ path = custom_module_path(output_dir, slug) if prefer_output else None
131
+ if path is None or not path.is_file():
132
+ with suppress(TypeError):
133
+ if source_file := inspect.getsourcefile(type(custom_parameters)):
134
+ path = Path(source_file)
125
135
 
126
- if path.is_file():
136
+ if path is not None and path.is_file():
127
137
  with suppress(OSError):
128
138
  return extract_comments(path.read_text(encoding="utf-8"))
129
139
 
130
140
  return {}
131
141
 
132
142
 
143
+ def _load_custom_parameters_from_file(
144
+ path: Path, product_info: ProductInfo
145
+ ) -> CustomParameters:
146
+ """Load and validate custom parameters from a module file on disk."""
147
+ slug = model_slug(product_info.model)
148
+ spec = importlib.util.spec_from_file_location(f"_pyplumio_cli_custom_{slug}", path)
149
+ if spec is None or spec.loader is None:
150
+ raise ImportError(f"Could not create module spec for {path}")
151
+
152
+ module = importlib.util.module_from_spec(spec)
153
+ spec.loader.exec_module(module)
154
+ class_name = custom_class_name(slug)
155
+ cls = getattr(module, class_name)
156
+ instance = cls()
157
+ if not isinstance(instance, CustomParameters):
158
+ raise TypeError(
159
+ f"Expected instance of 'CustomParameters', "
160
+ f"but got '{type(instance).__name__}' from '{class_name}'"
161
+ )
162
+
163
+ if not instance.validate(product_info):
164
+ raise ValueError(
165
+ f"Signature mismatch in {path.name} "
166
+ f"(expected {product_info.model!r} ID {product_info.id})"
167
+ )
168
+
169
+ return instance
170
+
171
+
172
+ async def _load_cli_custom_parameters(
173
+ output_dir: Path, product_info: ProductInfo
174
+ ) -> tuple[CustomParameters | None, str, bool]:
175
+ """Load custom parameters from output directory or installed package."""
176
+ path = custom_module_path(output_dir, model_slug(product_info.model))
177
+ if path.is_file():
178
+ try:
179
+ custom_parameters = await asyncio.to_thread(
180
+ _load_custom_parameters_from_file, path, product_info
181
+ )
182
+ except Exception as err:
183
+ message = (
184
+ f"Failed to load custom parameters from {path}: "
185
+ f"{_format_error(err)}. Falling back to built-in definitions."
186
+ )
187
+ _LOGGER.warning("%s", message)
188
+ warning = f"Warning: {message}"
189
+ _write_status(warning)
190
+ return await load_custom_parameters(product_info), warning, False
191
+
192
+ notice = f"Loaded custom parameters from {output_dir}."
193
+ _write_status(notice)
194
+ return custom_parameters, notice, True
195
+
196
+ return await load_custom_parameters(product_info), "", False
197
+
198
+
133
199
  async def prompt_connection_url(
134
200
  session: PromptSession[str] | None = None,
135
201
  ) -> str:
@@ -182,9 +248,17 @@ async def run_app(args: argparse.Namespace) -> int:
182
248
  )
183
249
  try:
184
250
  product_info = await session.connect()
185
- if custom_parameters := await load_custom_parameters(product_info):
251
+ (
252
+ custom_parameters,
253
+ startup_status,
254
+ from_output,
255
+ ) = await _load_cli_custom_parameters(output_dir, product_info)
256
+ if custom_parameters:
186
257
  comments = _load_comments(
187
- custom_parameters, output_dir, model_slug(product_info.model)
258
+ custom_parameters,
259
+ output_dir,
260
+ model_slug(product_info.model),
261
+ prefer_output=from_output,
188
262
  )
189
263
  for index, description in custom_parameters.descriptions.items():
190
264
  table.set_description(
@@ -194,6 +268,9 @@ async def run_app(args: argparse.Namespace) -> int:
194
268
  table.overrides = tuple(custom_parameters.overrides)
195
269
 
196
270
  app, state = create_app(session, table, output_dir, zip_output=args.zip)
271
+ if startup_status:
272
+ state.status = startup_status
273
+
197
274
  with _capture_logs(state):
198
275
  _write_status("Starting interface...")
199
276
  await app.run_async()
@@ -81,7 +81,7 @@ PAGE_SIZE: Final = 25
81
81
  INDEX_PROMPT: Final = "Enter parameter index to edit: "
82
82
  NAME_PROMPT: Final = "Name: "
83
83
  COMMENT_PROMPT: Final = "Comment (leave empty for none): "
84
- ZIP_PROMPT: Final = "Save as a ZIP archive? [y/N]: "
84
+ ZIP_PROMPT: Final = "Also save as a ZIP archive? [y/N]: "
85
85
 
86
86
 
87
87
  def _normalize_number(value: float) -> float | int:
@@ -144,15 +144,14 @@ def _save_files(state: AppState) -> None:
144
144
  state.output_dir,
145
145
  comments=state.table.comments,
146
146
  )
147
+ write_files(files)
147
148
  if state.data.save_as_zip:
148
149
  zip_path = zip_archive_path(
149
150
  state.output_dir, model_slug(product_info.model)
150
151
  )
151
152
  write_zip(zip_path, files, state.output_dir)
152
- state.status = f"Files saved to {zip_path}."
153
- else:
154
- write_files(files)
155
- state.status = f"Files saved to {state.output_dir}."
153
+
154
+ state.status = f"Files saved to {state.output_dir}."
156
155
 
157
156
  except (OSError, ValueError) as err:
158
157
  state.status = f"Error saving files: {err}"
@@ -264,13 +263,13 @@ class AppState:
264
263
 
265
264
  self.data.save_as_zip = self.zip_output if save_as_zip is None else save_as_zip
266
265
  slug = model_slug(product_info.model)
267
- target_path = (
268
- zip_archive_path(self.output_dir, slug)
269
- if self.data.save_as_zip
270
- else custom_module_path(self.output_dir, slug)
271
- )
272
- if target_path.is_file():
273
- prompt = f"Overwrite existing {target_path.name}? [y/N]: "
266
+ targets = [custom_module_path(self.output_dir, slug)]
267
+ if self.data.save_as_zip:
268
+ targets.append(zip_archive_path(self.output_dir, slug))
269
+
270
+ if existing := [path.name for path in targets if path.is_file()]:
271
+ names = " and ".join(existing)
272
+ prompt = f"Overwrite existing {names}? [y/N]: "
274
273
  return self._set_step(AppStep.OVERWRITE, prompt, buffer)
275
274
 
276
275
  _save_files(self)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "PyPlumIO"
3
- version = "0.7.8"
3
+ version = "0.7.8.post2"
4
4
  authors = [
5
5
  {name = "Denis Paavilainen", email = "denpa@denpa.pro"}
6
6
  ]
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import argparse
6
+ from dataclasses import replace
6
7
  import logging
7
8
  from pathlib import Path
8
9
  from typing import Any
@@ -20,22 +21,32 @@ from serialx import SerialException
20
21
 
21
22
  from pyplumio.cli.app import (
22
23
  _format_error,
24
+ _load_cli_custom_parameters,
23
25
  _load_comments,
26
+ _load_custom_parameters_from_file,
24
27
  _StatusLogHandler,
25
28
  _write_status,
26
29
  prompt_connection_url,
27
30
  run_app,
28
31
  )
29
- from pyplumio.cli.codegen import custom_module_path
32
+ from pyplumio.cli.codegen import (
33
+ custom_module_path,
34
+ generate_custom_parameter_module,
35
+ write_zip,
36
+ zip_archive_path,
37
+ )
30
38
  from pyplumio.cli.model import ParameterTable
31
39
  from pyplumio.cli.session import Session
32
40
  from pyplumio.cli.state import AppState, AppStep, _save_files
33
41
  from pyplumio.cli.ui import create_app
34
42
  from pyplumio.exceptions import ConnectionFailedError, PyPlumIOError
35
43
  from pyplumio.parameters import ParameterValues
44
+ from pyplumio.parameters.custom import CustomParameters
36
45
  from pyplumio.parameters.ecomax import EcomaxNumberDescription
37
46
  from tests.cli.conftest import (
47
+ DUMMY_CLASS_NAME,
38
48
  DUMMY_COMMENTS,
49
+ DUMMY_ID,
39
50
  DUMMY_MODEL,
40
51
  DUMMY_SLUG,
41
52
  EcoMAX999TEST,
@@ -413,23 +424,41 @@ def test_load_comments(tmp_path: Path) -> None:
413
424
  _load_comments(EcoMAX999TEST(), tmp_path / "empty", DUMMY_SLUG)
414
425
  == DUMMY_COMMENTS
415
426
  )
427
+ assert (
428
+ _load_comments(EcoMAX999TEST(), tmp_path, DUMMY_SLUG, prefer_output=False)
429
+ == DUMMY_COMMENTS
430
+ )
416
431
 
417
432
  with patch("pyplumio.cli.app.inspect.getsourcefile", return_value=None):
418
433
  assert _load_comments(EcoMAX999TEST(), tmp_path / "empty", DUMMY_SLUG) == {}
419
434
 
435
+ dynamic_instance = _load_custom_parameters_from_file(
436
+ source_path, dummy_product_info()
437
+ )
438
+ assert (
439
+ _load_comments(dynamic_instance, tmp_path, DUMMY_SLUG, prefer_output=False)
440
+ == {}
441
+ )
442
+
420
443
  with patch.object(Path, "read_text", side_effect=OSError("Permission denied")):
421
444
  assert _load_comments(EcoMAX999TEST(), tmp_path, DUMMY_SLUG) == {}
422
445
 
423
446
 
424
447
  async def test_loaded_comments_prefill_and_preserve_on_save(tmp_path: Path) -> None:
425
448
  """Test loaded comments are pre-filled at comment step and preserved on save."""
449
+ product_info = dummy_product_info()
426
450
  existing_module = custom_module_path(tmp_path, DUMMY_SLUG)
427
451
  existing_module.parent.mkdir(parents=True, exist_ok=True)
428
452
  existing_module.write_text(
429
- " # untouched output comment\n"
430
- ' 0: EcomaxNumberDescription(name="max_boiler_power"),\n'
431
- " # 0 - pellets, 1 - wood\n"
432
- ' 4: EcomaxNumberDescription(name="fuel_type"),\n',
453
+ generate_custom_parameter_module(
454
+ product_info,
455
+ {
456
+ 0: EcoMAX999TEST.descriptions[0],
457
+ 4: EcoMAX999TEST.descriptions[4],
458
+ },
459
+ EcoMAX999TEST.overrides,
460
+ comments={0: "untouched output comment", 4: "0 - pellets, 1 - wood"},
461
+ ),
433
462
  encoding="utf-8",
434
463
  )
435
464
 
@@ -440,7 +469,6 @@ async def test_loaded_comments_prefill_and_preserve_on_save(tmp_path: Path) -> N
440
469
  baudrate=115200,
441
470
  zip=False,
442
471
  )
443
- product_info = dummy_product_info()
444
472
  created_sessions: list[Session] = []
445
473
  created_states: list[AppState] = []
446
474
  orig_init = Session.__init__
@@ -467,16 +495,15 @@ async def test_loaded_comments_prefill_and_preserve_on_save(tmp_path: Path) -> N
467
495
  sess._on_update(sess.last_parameters)
468
496
 
469
497
  state = created_states[0]
498
+ assert state.status == f"Loaded custom parameters from {tmp_path}."
499
+ assert state.table.overrides == EcoMAX999TEST.overrides
470
500
  buff = Buffer()
471
501
 
472
502
  # Edit index 4 and verify loaded comment is pre-filled
473
503
  buff.text = "4"
474
- state.dispatch_enter(buff)
475
- state.dispatch_enter(buff) # keep "fuel_type"
476
- state.dispatch_enter(buff) # keep "number"
477
- state.dispatch_enter(buff) # keep offset
478
- state.dispatch_enter(buff) # keep step
479
- state.dispatch_enter(buff) # keep unit
504
+ for _ in range(6):
505
+ state.dispatch_enter(buff) # select 4 and keep name/type/offset/step/unit
506
+
480
507
  assert _step(state) == AppStep.COMMENT
481
508
  assert buff.text == "0 - pellets, 1 - wood"
482
509
  state.dispatch_enter(buff) # keep pre-filled comment
@@ -498,8 +525,7 @@ async def test_loaded_comments_prefill_and_preserve_on_save(tmp_path: Path) -> N
498
525
  patch(
499
526
  "pyplumio.cli.app.load_custom_parameters",
500
527
  new_callable=AsyncMock,
501
- return_value=EcoMAX999TEST(),
502
- ),
528
+ ) as mock_load_builtin,
503
529
  patch(
504
530
  "pyplumio.cli.session.Session.connect",
505
531
  new_callable=AsyncMock,
@@ -513,7 +539,276 @@ async def test_loaded_comments_prefill_and_preserve_on_save(tmp_path: Path) -> N
513
539
  patch("pyplumio.cli.session.Session.close", new_callable=AsyncMock),
514
540
  ):
515
541
  assert await run_app(args) == 0
542
+ mock_load_builtin.assert_not_awaited()
516
543
 
517
544
  saved_module = existing_module.read_text(encoding="utf-8")
518
545
  assert " # untouched output comment\n 0: " in saved_module
519
546
  assert " # 0 - pellets, 1 - wood\n 4: " in saved_module
547
+
548
+
549
+ def test_load_custom_parameters_from_file(tmp_path: Path) -> None:
550
+ """Test _load_custom_parameters_from_file validation and error cases."""
551
+ product_info = dummy_product_info()
552
+ valid_path = write_dummy_custom_module(tmp_path / "valid")
553
+ loaded = _load_custom_parameters_from_file(valid_path, product_info)
554
+ assert isinstance(loaded, CustomParameters)
555
+ assert loaded.validate(product_info)
556
+ assert loaded.descriptions == EcoMAX999TEST.descriptions
557
+
558
+ invalid_suffix = tmp_path / "invalid.txt"
559
+ invalid_suffix.write_text("", encoding="utf-8")
560
+ with pytest.raises(ImportError, match="Could not create module spec"):
561
+ _load_custom_parameters_from_file(invalid_suffix, product_info)
562
+
563
+ missing_class = tmp_path / "missing.py"
564
+ missing_class.write_text("VALUE = 1\n", encoding="utf-8")
565
+ with pytest.raises(AttributeError):
566
+ _load_custom_parameters_from_file(missing_class, product_info)
567
+
568
+ wrong_class = tmp_path / "wrong.py"
569
+ wrong_class.write_text(f"class {DUMMY_CLASS_NAME}:\n pass\n", encoding="utf-8")
570
+ with pytest.raises(TypeError, match="Expected instance of 'CustomParameters'"):
571
+ _load_custom_parameters_from_file(wrong_class, product_info)
572
+
573
+ non_callable = tmp_path / "non_callable.py"
574
+ non_callable.write_text(f"{DUMMY_CLASS_NAME} = 123\n", encoding="utf-8")
575
+ with pytest.raises(TypeError):
576
+ _load_custom_parameters_from_file(non_callable, product_info)
577
+
578
+ missing_signature = tmp_path / "missing_signature.py"
579
+ missing_signature.write_text(
580
+ "from pyplumio.parameters.custom import CustomParameters\n"
581
+ f"class {DUMMY_CLASS_NAME}(CustomParameters):\n"
582
+ " pass\n",
583
+ encoding="utf-8",
584
+ )
585
+ with pytest.raises(AttributeError):
586
+ _load_custom_parameters_from_file(missing_signature, product_info)
587
+
588
+ with pytest.raises(ValueError, match="Signature mismatch"):
589
+ _load_custom_parameters_from_file(
590
+ valid_path, replace(product_info, id=DUMMY_ID + 1)
591
+ )
592
+
593
+ wrong_model = tmp_path / "wrong_model.py"
594
+ wrong_model.write_text(
595
+ "from pyplumio.parameters.custom import CustomParameters, Signature\n"
596
+ f"class {DUMMY_CLASS_NAME}(CustomParameters):\n"
597
+ f' signature = Signature(model="ecoMAX 999-OTHER", id={DUMMY_ID})\n',
598
+ encoding="utf-8",
599
+ )
600
+ with pytest.raises(ValueError, match="Signature mismatch"):
601
+ _load_custom_parameters_from_file(wrong_model, product_info)
602
+
603
+
604
+ async def test_load_cli_custom_parameters_fallback(
605
+ tmp_path: Path,
606
+ caplog: pytest.LogCaptureFixture,
607
+ capsys: pytest.CaptureFixture[str],
608
+ ) -> None:
609
+ """Test _load_cli_custom_parameters precedence, fallback, and warnings."""
610
+ product_info = dummy_product_info()
611
+
612
+ missing_dir = tmp_path / "missing"
613
+ with (
614
+ caplog.at_level(logging.WARNING),
615
+ patch(
616
+ "pyplumio.cli.app.load_custom_parameters",
617
+ new_callable=AsyncMock,
618
+ return_value=EcoMAX999TEST(),
619
+ ) as mock_load,
620
+ ):
621
+ params, status, from_output = await _load_cli_custom_parameters(
622
+ missing_dir, product_info
623
+ )
624
+
625
+ assert isinstance(params, EcoMAX999TEST)
626
+ assert status == ""
627
+ assert from_output is False
628
+ assert caplog.text == ""
629
+ assert capsys.readouterr().err == ""
630
+ mock_load.assert_awaited_once_with(product_info)
631
+
632
+ broken_dir = tmp_path / "broken"
633
+ broken_path = custom_module_path(broken_dir, DUMMY_SLUG)
634
+ broken_path.parent.mkdir(parents=True, exist_ok=True)
635
+ broken_path.write_text("def broken(:\n", encoding="utf-8")
636
+ with (
637
+ caplog.at_level(logging.WARNING),
638
+ patch(
639
+ "pyplumio.cli.app.load_custom_parameters",
640
+ new_callable=AsyncMock,
641
+ return_value=EcoMAX999TEST(),
642
+ ) as mock_load,
643
+ ):
644
+ params, status, from_output = await _load_cli_custom_parameters(
645
+ broken_dir, product_info
646
+ )
647
+
648
+ assert isinstance(params, EcoMAX999TEST)
649
+ assert from_output is False
650
+ assert status.startswith(
651
+ f"Warning: Failed to load custom parameters from {broken_path}:"
652
+ )
653
+ assert "Falling back to built-in definitions." in status
654
+ assert "Failed to load custom parameters from" in caplog.text
655
+ assert f"{status}\n" in capsys.readouterr().err
656
+ mock_load.assert_awaited_once_with(product_info)
657
+
658
+ valid_dir = tmp_path / "valid"
659
+ write_dummy_custom_module(valid_dir)
660
+ with patch(
661
+ "pyplumio.cli.app.load_custom_parameters",
662
+ new_callable=AsyncMock,
663
+ ) as mock_load:
664
+ params, status, from_output = await _load_cli_custom_parameters(
665
+ valid_dir, product_info
666
+ )
667
+
668
+ assert isinstance(params, CustomParameters)
669
+ assert status == f"Loaded custom parameters from {valid_dir}."
670
+ assert from_output is True
671
+ assert f"{status}\n" in capsys.readouterr().err
672
+ mock_load.assert_not_awaited()
673
+
674
+
675
+ async def test_load_cli_custom_parameters_zip_and_empty_error(
676
+ tmp_path: Path,
677
+ caplog: pytest.LogCaptureFixture,
678
+ capsys: pytest.CaptureFixture[str],
679
+ ) -> None:
680
+ """Test _load_cli_custom_parameters ignores zip archives and empty errors."""
681
+ product_info = dummy_product_info()
682
+ zip_only_dir = tmp_path / "zip_only"
683
+ zip_module_path = custom_module_path(zip_only_dir, DUMMY_SLUG)
684
+ write_zip(
685
+ zip_archive_path(zip_only_dir, DUMMY_SLUG),
686
+ {
687
+ zip_module_path: generate_custom_parameter_module(
688
+ product_info,
689
+ EcoMAX999TEST.descriptions,
690
+ EcoMAX999TEST.overrides,
691
+ )
692
+ },
693
+ zip_only_dir,
694
+ )
695
+ with (
696
+ caplog.at_level(logging.WARNING),
697
+ patch(
698
+ "pyplumio.cli.app.load_custom_parameters",
699
+ new_callable=AsyncMock,
700
+ return_value=EcoMAX999TEST(),
701
+ ) as mock_load,
702
+ ):
703
+ params, status, from_output = await _load_cli_custom_parameters(
704
+ zip_only_dir, product_info
705
+ )
706
+
707
+ assert isinstance(params, EcoMAX999TEST)
708
+ assert status == ""
709
+ assert from_output is False
710
+ assert caplog.text == ""
711
+ assert capsys.readouterr().err == ""
712
+ mock_load.assert_awaited_once_with(product_info)
713
+
714
+ empty_err_dir = tmp_path / "empty_err"
715
+ empty_err_path = custom_module_path(empty_err_dir, DUMMY_SLUG)
716
+ empty_err_path.parent.mkdir(parents=True, exist_ok=True)
717
+ empty_err_path.write_text("raise ValueError()\n", encoding="utf-8")
718
+ with (
719
+ caplog.at_level(logging.WARNING),
720
+ patch(
721
+ "pyplumio.cli.app.load_custom_parameters",
722
+ new_callable=AsyncMock,
723
+ return_value=None,
724
+ ) as mock_load,
725
+ ):
726
+ params, status, from_output = await _load_cli_custom_parameters(
727
+ empty_err_dir, product_info
728
+ )
729
+
730
+ assert params is None
731
+ assert from_output is False
732
+ assert status == (
733
+ f"Warning: Failed to load custom parameters from {empty_err_path}: "
734
+ "ValueError. Falling back to built-in definitions."
735
+ )
736
+ assert f"{status}\n" in capsys.readouterr().err
737
+ mock_load.assert_awaited_once_with(product_info)
738
+
739
+
740
+ async def test_run_app_invalid_output_module_fallback(
741
+ tmp_path: Path,
742
+ caplog: pytest.LogCaptureFixture,
743
+ capsys: pytest.CaptureFixture[str],
744
+ ) -> None:
745
+ """Test run_app falls back cleanly when output module fails validation."""
746
+ product_info = dummy_product_info()
747
+ mismatched_info = replace(product_info, id=DUMMY_ID + 1)
748
+ rejected_path = custom_module_path(tmp_path, DUMMY_SLUG)
749
+ rejected_path.parent.mkdir(parents=True, exist_ok=True)
750
+ rejected_path.write_text(
751
+ generate_custom_parameter_module(
752
+ mismatched_info,
753
+ {4: EcoMAX999TEST.descriptions[4]},
754
+ comments={4: "rejected output comment"},
755
+ ),
756
+ encoding="utf-8",
757
+ )
758
+ source_path = write_dummy_custom_module(tmp_path / "source")
759
+
760
+ args = argparse.Namespace(
761
+ url="socket://localhost:8899",
762
+ output=str(tmp_path),
763
+ interval=1.0,
764
+ baudrate=115200,
765
+ zip=False,
766
+ )
767
+ created_states: list[AppState] = []
768
+ orig_create_app = create_app
769
+
770
+ def track_create_app(*a: Any, **kw: Any) -> tuple[Application[None], AppState]:
771
+ app, state = orig_create_app(*a, **kw)
772
+ created_states.append(state)
773
+ return app, state
774
+
775
+ async def fake_run_async(*_args: Any, **_kwargs: Any) -> None:
776
+ state = created_states[0]
777
+ assert state.status.startswith(
778
+ f"Warning: Failed to load custom parameters from {rejected_path}:"
779
+ )
780
+ assert state.table.comments == DUMMY_COMMENTS
781
+
782
+ with (
783
+ caplog.at_level(logging.WARNING),
784
+ create_pipe_input() as pipe_input,
785
+ create_app_session(input=pipe_input, output=DummyOutput()),
786
+ patch("pyplumio.cli.app.create_app", side_effect=track_create_app),
787
+ patch(
788
+ "pyplumio.cli.app.load_custom_parameters",
789
+ new_callable=AsyncMock,
790
+ return_value=EcoMAX999TEST(),
791
+ ) as mock_load,
792
+ patch(
793
+ "pyplumio.cli.app.inspect.getsourcefile",
794
+ return_value=str(source_path),
795
+ ),
796
+ patch(
797
+ "pyplumio.cli.session.Session.connect",
798
+ new_callable=AsyncMock,
799
+ return_value=product_info,
800
+ ),
801
+ patch(
802
+ "prompt_toolkit.application.Application.run_async",
803
+ new_callable=AsyncMock,
804
+ side_effect=fake_run_async,
805
+ ),
806
+ patch("pyplumio.cli.session.Session.close", new_callable=AsyncMock),
807
+ ):
808
+ assert await run_app(args) == 0
809
+ mock_load.assert_awaited_once_with(product_info)
810
+
811
+ assert "Failed to load custom parameters from" in caplog.text
812
+ assert f"Warning: Failed to load custom parameters from {rejected_path}:" in (
813
+ capsys.readouterr().err
814
+ )