PyPlumIO 0.7.8.post2__tar.gz → 0.7.10__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.
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/PKG-INFO +3 -2
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/README.md +1 -1
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/cli.rst +15 -9
- pyplumio-0.7.10/docs/source/custom_parameters.rst +195 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/frames.rst +3 -1
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/index.rst +1 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/cli/app.py +8 -16
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/cli/codegen.py +85 -94
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/cli/model.py +3 -4
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/cli/session.py +3 -1
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/cli/state.py +5 -42
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/cli/ui.py +23 -2
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/const.py +3 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/devices/ecomax.py +120 -69
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/helpers/event_manager.py +28 -6
- pyplumio-0.7.10/pyplumio/parameters/custom/__init__.py +261 -0
- pyplumio-0.7.10/pyplumio/parameters/custom/ecomax_350p2_zf.py +86 -0
- pyplumio-0.7.10/pyplumio/parameters/custom/ecomax_860d3_hb.py +25 -0
- pyplumio-0.7.10/pyplumio/parameters/custom/ecomax_860p4_nm_touch.py +99 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/parameters/ecomax.py +2 -2
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/protocol.py +3 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyproject.toml +2 -1
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/cli/conftest.py +48 -51
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/cli/test_app.py +72 -84
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/cli/test_codegen.py +117 -92
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/cli/test_model.py +1 -1
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/cli/test_session.py +7 -4
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/cli/test_state.py +56 -142
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/cli/test_ui.py +71 -31
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/devices/test_ecomax.py +520 -12
- pyplumio-0.7.10/tests/helpers/test_event_manager.py +483 -0
- pyplumio-0.7.10/tests/parameters/custom/test_ecomax_350p2_zf.py +147 -0
- pyplumio-0.7.10/tests/parameters/custom/test_init.py +293 -0
- pyplumio-0.7.10/tests/test_const.py +15 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/test_protocol.py +28 -1
- pyplumio-0.7.10/tests/testdata/parameters/ecomax_350p2_zf.json +20 -0
- pyplumio-0.7.8.post2/pyplumio/parameters/custom/__init__.py +0 -135
- pyplumio-0.7.8.post2/pyplumio/parameters/custom/ecomax_350p2_zf.py +0 -80
- pyplumio-0.7.8.post2/pyplumio/parameters/custom/ecomax_860d3_hb.py +0 -80
- pyplumio-0.7.8.post2/pyplumio/parameters/custom/ecomax_860p4_nm_touch.py +0 -301
- pyplumio-0.7.8.post2/tests/helpers/test_event_manager.py +0 -237
- pyplumio-0.7.8.post2/tests/parameters/custom/test_ecomax_350p2_zf.py +0 -100
- pyplumio-0.7.8.post2/tests/parameters/custom/test_init.py +0 -117
- pyplumio-0.7.8.post2/tests/testdata/parameters/ecomax_350p2_zf.json +0 -19
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/.gitignore +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/LICENSE +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/Makefile +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/make.bat +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/callbacks.rst +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/conf.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/connecting.rst +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/mixers_thermostats.rst +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/protocol.rst +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/reading.rst +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/schedules.rst +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/docs/source/writing.rst +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/__main__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/cli/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/connection.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/data_types.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/devices/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/devices/ecoster.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/devices/mixer.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/devices/thermostat.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/exceptions.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/filters.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/frames/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/frames/messages.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/frames/requests.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/frames/responses.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/helpers/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/helpers/async_cache.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/helpers/task_manager.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/parameters/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/parameters/mixer.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/parameters/thermostat.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/py.typed +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/stream.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/alerts.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/ecomax_parameters.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/ecomax_service_parameters.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/frame_versions.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/mixer_parameters.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/network_info.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/product_info.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/program_version.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/regulator_data.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/regulator_data_schema.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/schedules.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/sensor_data.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/structures/thermostat_parameters.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/pyplumio/utils.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/cli/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/cli/test_init.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/conftest.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/devices/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/devices/test_ecoster.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/devices/test_init.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/devices/test_mixer.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/devices/test_thermostat.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/frames/test_init.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/frames/test_messages.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/frames/test_requests.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/frames/test_responses.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/helpers/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/helpers/test_async_cache.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/helpers/test_task_manager.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/helpers/test_uid.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/parameters/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/parameters/custom/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/parameters/custom/test_ecomax_860d3_hb.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/parameters/custom/test_ecomax_860p4_nm_touch.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/parameters/test_ecomax.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/parameters/test_init.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/parameters/test_mixers.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/parameters/test_thermostats.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/ruff.toml +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/structures/__init__.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/structures/test_alerts.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/structures/test_ecomax_parameters.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/structures/test_ecomax_service_parameters.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/structures/test_frame_versions.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/structures/test_mixer_parameters.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/structures/test_product_info.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/structures/test_program_version.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/structures/test_schedules.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/test_connection.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/test_data_types.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/test_filters.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/test_init.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/test_main.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/test_stream.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/test_utils.py +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/messages/regulator_data.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/messages/sensor_data.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/parameters/ecomax_860d3_hb.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/parameters/ecomax_860p4_nm_touch.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/alerts.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/ecomax_control.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/ecomax_parameters.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/ecomax_service_parameters.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/mixer_parameters.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/set_ecomax_parameter.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/set_ecomax_service_parameter.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/set_mixer_parameter.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/set_schedule.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/set_thermostat_parameter.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/requests/thermostat_parameters.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/alerts.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/device_available.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/ecomax_parameters.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/ecomax_service_parameters.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/mixer_parameters.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/password.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/program_version.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/regulator_data_schema.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/schedules.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/thermostat_parameters.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/responses/uid.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/tests/testdata/unknown/unknown_ecomax_parameter.json +0 -0
- {pyplumio-0.7.8.post2 → pyplumio-0.7.10}/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.
|
|
3
|
+
Version: 0.7.10
|
|
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
|
|
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
19
20
|
Classifier: Topic :: Home Automation
|
|
20
21
|
Classifier: Topic :: Software Development :: Libraries
|
|
21
22
|
Classifier: Typing :: Typed
|
|
@@ -65,7 +66,7 @@ through network by using RS-485 to Ethernet/WiFi converter.
|
|
|
65
66
|
- [Requests and Responses](https://pyplumio.denpa.pro/protocol.html#requests-and-responses)
|
|
66
67
|
- [Communication](https://pyplumio.denpa.pro/protocol.html#communication)
|
|
67
68
|
- [Versioning](https://pyplumio.denpa.pro/protocol.html#versioning)
|
|
68
|
-
- [Supported
|
|
69
|
+
- [Supported Frames](https://pyplumio.denpa.pro/frames.html)
|
|
69
70
|
- [CLI Parameter Mapper](https://pyplumio.denpa.pro/cli.html)
|
|
70
71
|
|
|
71
72
|
## Parameter Mapping CLI
|
|
@@ -38,7 +38,7 @@ through network by using RS-485 to Ethernet/WiFi converter.
|
|
|
38
38
|
- [Requests and Responses](https://pyplumio.denpa.pro/protocol.html#requests-and-responses)
|
|
39
39
|
- [Communication](https://pyplumio.denpa.pro/protocol.html#communication)
|
|
40
40
|
- [Versioning](https://pyplumio.denpa.pro/protocol.html#versioning)
|
|
41
|
-
- [Supported
|
|
41
|
+
- [Supported Frames](https://pyplumio.denpa.pro/frames.html)
|
|
42
42
|
- [CLI Parameter Mapper](https://pyplumio.denpa.pro/cli.html)
|
|
43
43
|
|
|
44
44
|
## Parameter Mapping CLI
|
|
@@ -84,12 +84,13 @@ the full-screen interface opens with the parameter table already filled and keep
|
|
|
84
84
|
polling in the background.
|
|
85
85
|
|
|
86
86
|
If ``<output>/pyplumio/parameters/custom/<model_slug>.py`` exists on disk with a
|
|
87
|
-
matching model and product ID
|
|
88
|
-
|
|
87
|
+
matching model and product ID, the CLI loads its mapped ``service_parameters``,
|
|
88
|
+
``patches``, and comments automatically—taking precedence over bundled definitions in
|
|
89
89
|
PyPlumIO—and displays a confirmation notice in the status bar. If no local file exists,
|
|
90
90
|
bundled definitions for the detected model are loaded when available. If an existing
|
|
91
|
-
local file fails to load or has a mismatched
|
|
92
|
-
CLI falls back to built-in definitions.
|
|
91
|
+
local file fails to load or has a mismatched model or product ID, a warning is displayed and the
|
|
92
|
+
CLI falls back to built-in definitions. See :doc:`custom_parameters` for details on
|
|
93
|
+
``custom_parameters()`` definitions and model slugs.
|
|
93
94
|
|
|
94
95
|
The interface consists of:
|
|
95
96
|
|
|
@@ -108,7 +109,7 @@ At the bottom of the screen, a wizard guides you through naming and configuring
|
|
|
108
109
|
2. **Name**: Enter a unique snake_case name (e.g. ``heating_temp``):
|
|
109
110
|
- Standard ecoMAX parameter names for the connected device are offered as autocompletion (substring match; names already used by other indices are left out).
|
|
110
111
|
- If the name is already used by another parameter index, it is rejected.
|
|
111
|
-
- Choosing or typing a standard name pre-fills the **Type**, **Offset**, **Step**, and **Unit** defaults from that parameter's standard description. Re-editing an already-mapped parameter and keeping its name preserves its existing settings as defaults.
|
|
112
|
+
- Choosing or typing a standard name pre-fills the **Type**, **Offset**, **Step**, and **Unit** defaults from that parameter's standard description. Re-editing an already-mapped parameter and keeping its name preserves its existing settings as defaults.
|
|
112
113
|
- Submitting an empty name deletes the parameter (and its comment) if it is already mapped, or cancels and returns to the index prompt if it has not been mapped yet.
|
|
113
114
|
3. **Type**: Select ``number`` or ``switch`` (defaults to the pre-filled template type, or ``switch`` if minimum is 0 and maximum is 1, otherwise ``number``).
|
|
114
115
|
4. **Number Settings**: If configuring a number (defaults come from the matched template or existing mapping, or fall back to ``0``, ``1``, and ``none``):
|
|
@@ -116,7 +117,7 @@ At the bottom of the screen, a wizard guides you through naming and configuring
|
|
|
116
117
|
- **Step**: Multiplier/step (default: ``1``; e.g. ``1``, ``0.1``, ``10``).
|
|
117
118
|
- **Unit**: Physical unit of measurement (supports autocompletion for unit values such as ``°C``, ``kW``, ``rpm``, ``%``, etc., or enter ``none`` to clear a pre-filled unit).
|
|
118
119
|
5. **Comment**: Enter an optional comment (or leave empty for none). When re-editing a parameter that already has a comment (either loaded from an existing custom parameter module or added in the current session), the prompt is pre-filled with the existing comment. Comments are written as wrapped ``# ...`` lines directly above the parameter entry in the generated module.
|
|
119
|
-
6. **Confirm**: Confirm the
|
|
120
|
+
6. **Confirm**: Confirm that the live preview matches your controller display (``[y/N]``).
|
|
120
121
|
7. Press ``Esc`` at any point to cancel the wizard.
|
|
121
122
|
|
|
122
123
|
Connection Resilience
|
|
@@ -126,9 +127,9 @@ If the serial connection or TCP bridge drops during a session, the CLI automatic
|
|
|
126
127
|
|
|
127
128
|
.. code-block:: text
|
|
128
129
|
|
|
129
|
-
Connection lost. Reconnecting in background in
|
|
130
|
+
Connection lost. Reconnecting in background in 5 seconds...
|
|
130
131
|
|
|
131
|
-
The CLI automatically retries the connection every
|
|
132
|
+
The CLI automatically retries the connection every 5 seconds in the background while keeping the interface fully responsive. Once reconnected, it displays ``Connection restored.`` and resumes polling. Even when disconnected, you can review mapped parameters, continue editing, and press ``Ctrl+S`` to save the files from the last received frame.
|
|
132
133
|
|
|
133
134
|
Saving & Output Files
|
|
134
135
|
---------------------
|
|
@@ -148,7 +149,8 @@ The utility produces the following three files on disk (and inside ``<output>/<m
|
|
|
148
149
|
|
|
149
150
|
1. **Custom Parameter Module**:
|
|
150
151
|
``<output>/pyplumio/parameters/custom/<model_slug>.py``
|
|
151
|
-
Contains the ``
|
|
152
|
+
Contains the ``PARAMETERS = custom_parameters(...)`` definition with model,
|
|
153
|
+
product ID, and service parameters dictionary.
|
|
152
154
|
|
|
153
155
|
2. **Test Module**:
|
|
154
156
|
``<output>/tests/parameters/custom/test_<model_slug>.py``
|
|
@@ -171,3 +173,7 @@ Once you have mapped parameters for your controller model:
|
|
|
171
173
|
|
|
172
174
|
1. Open a pull request against `PyPlumIO <https://github.com/denpamusic/PyPlumIO/>`_ adding the generated files.
|
|
173
175
|
2. Alternatively, create an issue on GitHub and attach the generated ``<model_slug>.zip`` archive (or the three generated files).
|
|
176
|
+
|
|
177
|
+
For hand-authoring ``patches``, factoring repeated descriptors with ``functools.partial``,
|
|
178
|
+
configuring ``number()`` / ``switch()`` options (such as ``precision`` or ``optimistic``),
|
|
179
|
+
and running all required pre-PR verification checks, see :doc:`custom_parameters`.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Custom Parameters
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
Overview
|
|
5
|
+
--------
|
|
6
|
+
|
|
7
|
+
ecoMAX firmware varies across controller models: newer models store settings in
|
|
8
|
+
the service parameter table (:ref:`EcomaxServiceParameters<EcomaxServiceParameters>`),
|
|
9
|
+
and some models shift or repurpose entries in the standard parameter table
|
|
10
|
+
(:ref:`EcomaxParameters<EcomaxParameters>`). Custom parameter modules map those
|
|
11
|
+
entries to named parameters so they work seamlessly with :doc:`reading` and
|
|
12
|
+
:doc:`writing` (``ecomax.get(...)`` and ``ecomax.set(...)``).
|
|
13
|
+
|
|
14
|
+
A custom module defines one or both of the following tables:
|
|
15
|
+
|
|
16
|
+
.. list-table::
|
|
17
|
+
:widths: 24 76
|
|
18
|
+
:header-rows: 1
|
|
19
|
+
|
|
20
|
+
* - Table
|
|
21
|
+
- Purpose
|
|
22
|
+
* - ``service_parameters``
|
|
23
|
+
- Maps :ref:`EcomaxServiceParameters<EcomaxServiceParameters>` by index.
|
|
24
|
+
* - ``patches``
|
|
25
|
+
- Overrides :ref:`EcomaxParameters<EcomaxParameters>` by name.
|
|
26
|
+
|
|
27
|
+
To match a module to a controller, PyPlumIO converts
|
|
28
|
+
:py:class:`~pyplumio.structures.product_info.ProductInfo` ``model`` (from the
|
|
29
|
+
:ref:`UID<UID>` response) into ``<model_slug>`` by replacing ``"-"`` and
|
|
30
|
+
``" "`` with ``"_"`` and lowercasing (for example, ``"ecoMAX 350P2-ZF"`` becomes
|
|
31
|
+
``ecomax_350p2_zf``). **Both** the exact ``model`` string and numeric ``id``
|
|
32
|
+
(visible in the CLI header or via ``await ecomax.get("product")``) must match
|
|
33
|
+
the connected controller.
|
|
34
|
+
|
|
35
|
+
How-To Guides
|
|
36
|
+
-------------
|
|
37
|
+
|
|
38
|
+
Generating a Starter Module with the CLI
|
|
39
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
40
|
+
|
|
41
|
+
Use the interactive utility in :doc:`cli` to connect to your controller, inspect
|
|
42
|
+
raw :ref:`EcomaxServiceParameters<EcomaxServiceParameters>` entries, and export
|
|
43
|
+
a starter ``service_parameters`` module, test file, and captured frame JSON
|
|
44
|
+
(optionally bundled as ``<model_slug>.zip``). Saving in the CLI regenerates
|
|
45
|
+
plain ``number()`` and ``switch()`` entries for ``service_parameters``, so add
|
|
46
|
+
manual ``patches`` or ``functools.partial`` helpers afterward.
|
|
47
|
+
|
|
48
|
+
Writing or Patching a Module by Hand
|
|
49
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
50
|
+
|
|
51
|
+
Create ``pyplumio/parameters/custom/<model_slug>.py`` with a module docstring,
|
|
52
|
+
``from __future__ import annotations``, and a module-level
|
|
53
|
+
``PARAMETERS = custom_parameters(...)`` constant. See
|
|
54
|
+
`ecomax_350p2_zf.py <https://github.com/denpamusic/PyPlumIO/blob/main/pyplumio/parameters/custom/ecomax_350p2_zf.py>`_
|
|
55
|
+
(``pyplumio/parameters/custom/ecomax_350p2_zf.py``) for a complete reference.
|
|
56
|
+
|
|
57
|
+
For ``service_parameters``, map each raw index to ``number()`` or ``switch()``,
|
|
58
|
+
use ``#`` comments to document enum-style numeric options, and factor repeated
|
|
59
|
+
descriptors with ``functools.partial``. When raw wire values are scaled or
|
|
60
|
+
shifted, PyPlumIO unpacks them as
|
|
61
|
+
``unpacked = round((raw - offset) * step, precision)``:
|
|
62
|
+
|
|
63
|
+
- **Positive offset**: ``number("heating_curve_shift", offset=20, unit="°C")``
|
|
64
|
+
maps raw ``0..40`` to ``-20..20 °C``.
|
|
65
|
+
- **Negative offset with step**: ``partial(number, step=10.0, offset=-30, unit="rpm")``
|
|
66
|
+
maps raw ``0..255`` to ``300..2850 rpm``.
|
|
67
|
+
|
|
68
|
+
.. code-block:: python
|
|
69
|
+
|
|
70
|
+
"""Contains custom parameters for ecoMAX 860P4-NM TOUCH."""
|
|
71
|
+
|
|
72
|
+
from __future__ import annotations
|
|
73
|
+
|
|
74
|
+
from functools import partial
|
|
75
|
+
|
|
76
|
+
from pyplumio.parameters.custom import custom_parameters, number, switch
|
|
77
|
+
|
|
78
|
+
_fan_speed = partial(number, step=10.0, offset=-30, unit="rpm")
|
|
79
|
+
|
|
80
|
+
PARAMETERS = custom_parameters(
|
|
81
|
+
model="ecoMAX 860P4-NM TOUCH",
|
|
82
|
+
id=41,
|
|
83
|
+
service_parameters={
|
|
84
|
+
0: number("max_boiler_output", unit="kW"),
|
|
85
|
+
11: _fan_speed("fan_speed_30"),
|
|
86
|
+
# 0 - off, 1 - priority, 2 - no priority.
|
|
87
|
+
90: number("water_heater_pump_mode"),
|
|
88
|
+
100: switch("heat_exchanger"),
|
|
89
|
+
220: number("fuel_correction", offset=20, unit="%"),
|
|
90
|
+
},
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
For ``patches``, keys are the **original** standard parameter names from
|
|
94
|
+
:ref:`EcomaxParameters<EcomaxParameters>`, mapped to replacement ``number()`` or
|
|
95
|
+
``switch()`` descriptors (adapted from
|
|
96
|
+
``pyplumio/parameters/custom/ecomax_860d3_hb.py``):
|
|
97
|
+
|
|
98
|
+
.. code-block:: python
|
|
99
|
+
|
|
100
|
+
PARAMETERS = custom_parameters(
|
|
101
|
+
model="ecoMAX 860D3-HB",
|
|
102
|
+
id=48,
|
|
103
|
+
patches={
|
|
104
|
+
"disable_pump_on_thermostat": number("water_heater_target_temp", unit="°C"),
|
|
105
|
+
"pump_hysteresis": switch("water_heater_disinfection"),
|
|
106
|
+
},
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
Testing and Contributing
|
|
110
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
111
|
+
|
|
112
|
+
You can contribute mapped parameters in two ways:
|
|
113
|
+
|
|
114
|
+
1. **GitHub Issue**: Attach the ``<model_slug>.zip`` archive exported by
|
|
115
|
+
:doc:`cli` to an issue on `PyPlumIO <https://github.com/denpamusic/PyPlumIO/>`_.
|
|
116
|
+
2. **Pull Request**: Open a PR containing all three required files:
|
|
117
|
+
|
|
118
|
+
- ``pyplumio/parameters/custom/<model_slug>.py`` — exports ``PARAMETERS``
|
|
119
|
+
with ``model`` matching ``<model_slug>``, a non-bool integer ``id``, and
|
|
120
|
+
non-empty ``service_parameters`` or ``patches``.
|
|
121
|
+
- ``tests/testdata/parameters/<model_slug>.json`` — real frame data captured
|
|
122
|
+
from the controller.
|
|
123
|
+
- ``tests/parameters/custom/test_<model_slug>.py`` — parametrized tests
|
|
124
|
+
verifying each parameter's class, value, bounds, and unit; use
|
|
125
|
+
`test_ecomax_350p2_zf.py <https://github.com/denpamusic/PyPlumIO/blob/main/tests/parameters/custom/test_ecomax_350p2_zf.py>`_
|
|
126
|
+
(``service_parameters``) or
|
|
127
|
+
`test_ecomax_860d3_hb.py <https://github.com/denpamusic/PyPlumIO/blob/main/tests/parameters/custom/test_ecomax_860d3_hb.py>`_
|
|
128
|
+
(``patches``) as a template.
|
|
129
|
+
|
|
130
|
+
Before opening a PR, verify the test suite and linters pass locally:
|
|
131
|
+
|
|
132
|
+
.. code-block:: console
|
|
133
|
+
|
|
134
|
+
$ uv run pytest
|
|
135
|
+
$ prek run --all-files
|
|
136
|
+
|
|
137
|
+
DSL Reference
|
|
138
|
+
-------------
|
|
139
|
+
|
|
140
|
+
.. autofunction:: pyplumio.parameters.custom.custom_parameters
|
|
141
|
+
|
|
142
|
+
.. autofunction:: pyplumio.parameters.custom.number
|
|
143
|
+
|
|
144
|
+
.. autofunction:: pyplumio.parameters.custom.switch
|
|
145
|
+
|
|
146
|
+
Supported Units
|
|
147
|
+
~~~~~~~~~~~~~~~
|
|
148
|
+
|
|
149
|
+
``number(..., unit=...)`` accepts ``UnitOfMeasurement`` enum members,
|
|
150
|
+
``PERCENTAGE``, ``None``, or any string literal listed below. Passing an
|
|
151
|
+
unrecognized string raises ``ValueError``.
|
|
152
|
+
|
|
153
|
+
.. list-table::
|
|
154
|
+
:widths: 20 35 45
|
|
155
|
+
:header-rows: 1
|
|
156
|
+
|
|
157
|
+
* - Literal
|
|
158
|
+
- ``UnitOfMeasurement`` / Constant
|
|
159
|
+
- Meaning
|
|
160
|
+
* - ``"°C"``
|
|
161
|
+
- ``CELSIUS``
|
|
162
|
+
- Degrees Celsius
|
|
163
|
+
* - ``"kW"``
|
|
164
|
+
- ``KILO_WATT``
|
|
165
|
+
- Kilowatts
|
|
166
|
+
* - ``"g"``
|
|
167
|
+
- ``GRAMS``
|
|
168
|
+
- Grams
|
|
169
|
+
* - ``"kg"``
|
|
170
|
+
- ``KILOGRAMS``
|
|
171
|
+
- Kilograms
|
|
172
|
+
* - ``"kWh/kg"``
|
|
173
|
+
- ``KILO_WATT_HOUR_PER_KILOGRAM``
|
|
174
|
+
- Kilowatt-hours per kilogram
|
|
175
|
+
* - ``"kg/h"``
|
|
176
|
+
- ``KILOGRAMS_PER_HOUR``
|
|
177
|
+
- Kilograms per hour
|
|
178
|
+
* - ``"s"``
|
|
179
|
+
- ``SECONDS``
|
|
180
|
+
- Seconds
|
|
181
|
+
* - ``"min"``
|
|
182
|
+
- ``MINUTES``
|
|
183
|
+
- Minutes
|
|
184
|
+
* - ``"days"``
|
|
185
|
+
- ``DAYS``
|
|
186
|
+
- Days
|
|
187
|
+
* - ``"Pa"``
|
|
188
|
+
- ``PASCAL``
|
|
189
|
+
- Pascals
|
|
190
|
+
* - ``"rpm"``
|
|
191
|
+
- ``REVOLUTIONS_PER_MINUTE``
|
|
192
|
+
- Revolutions per minute
|
|
193
|
+
* - ``"%"``
|
|
194
|
+
- ``PERCENTAGE``
|
|
195
|
+
- Percentage
|
|
@@ -113,7 +113,8 @@ changes.
|
|
|
113
113
|
Parameters are represented in the same way as in :ref:`ecomaxparameters`.
|
|
114
114
|
Raw parameters are available under the ``ecomax_service_parameters`` key.
|
|
115
115
|
Parameters with known meaning are also available by name for verified
|
|
116
|
-
products only
|
|
116
|
+
products only; see :doc:`custom_parameters` for defining product-specific
|
|
117
|
+
``service_parameters`` mappings and standard ``patches``.
|
|
117
118
|
|
|
118
119
|
Request
|
|
119
120
|
^^^^^^^
|
|
@@ -794,5 +795,6 @@ Handlers
|
|
|
794
795
|
^^^^^^^^
|
|
795
796
|
|
|
796
797
|
.. autoclass:: pyplumio.structures.frame_versions.FrameVersionsStructure
|
|
798
|
+
:no-index:
|
|
797
799
|
|
|
798
800
|
.. autoclass:: pyplumio.structures.sensor_data.SensorDataStructure
|
|
@@ -8,7 +8,6 @@ from collections.abc import Iterator, Sequence
|
|
|
8
8
|
from contextlib import contextmanager, suppress
|
|
9
9
|
from enum import StrEnum, unique
|
|
10
10
|
import importlib.util
|
|
11
|
-
import inspect
|
|
12
11
|
import logging
|
|
13
12
|
from pathlib import Path
|
|
14
13
|
import sys
|
|
@@ -29,7 +28,7 @@ from pyplumio.exceptions import PyPlumIOError
|
|
|
29
28
|
from pyplumio.parameters import ParameterValues
|
|
30
29
|
from pyplumio.parameters.custom import (
|
|
31
30
|
CustomParameters,
|
|
32
|
-
|
|
31
|
+
extract_custom_parameters,
|
|
33
32
|
load_custom_parameters,
|
|
34
33
|
model_slug,
|
|
35
34
|
)
|
|
@@ -129,9 +128,7 @@ def _load_comments(
|
|
|
129
128
|
"""Load parameter comments from output directory or module source."""
|
|
130
129
|
path = custom_module_path(output_dir, slug) if prefer_output else None
|
|
131
130
|
if path is None or not path.is_file():
|
|
132
|
-
|
|
133
|
-
if source_file := inspect.getsourcefile(type(custom_parameters)):
|
|
134
|
-
path = Path(source_file)
|
|
131
|
+
path = custom_parameters.source
|
|
135
132
|
|
|
136
133
|
if path is not None and path.is_file():
|
|
137
134
|
with suppress(OSError):
|
|
@@ -151,18 +148,13 @@ def _load_custom_parameters_from_file(
|
|
|
151
148
|
|
|
152
149
|
module = importlib.util.module_from_spec(spec)
|
|
153
150
|
spec.loader.exec_module(module)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
)
|
|
151
|
+
instance = extract_custom_parameters(module, path=path)
|
|
152
|
+
if instance is None:
|
|
153
|
+
raise ValueError(f"No CustomParameters instance found in {path.name}")
|
|
162
154
|
|
|
163
155
|
if not instance.validate(product_info):
|
|
164
156
|
raise ValueError(
|
|
165
|
-
f"
|
|
157
|
+
f"Model or product ID mismatch in {path.name} "
|
|
166
158
|
f"(expected {product_info.model!r} ID {product_info.id})"
|
|
167
159
|
)
|
|
168
160
|
|
|
@@ -260,12 +252,12 @@ async def run_app(args: argparse.Namespace) -> int:
|
|
|
260
252
|
model_slug(product_info.model),
|
|
261
253
|
prefer_output=from_output,
|
|
262
254
|
)
|
|
263
|
-
for index, description in custom_parameters.
|
|
255
|
+
for index, description in custom_parameters.service_parameters.items():
|
|
264
256
|
table.set_description(
|
|
265
257
|
index, description, comment=comments.get(index, "")
|
|
266
258
|
)
|
|
267
259
|
|
|
268
|
-
table.
|
|
260
|
+
table.patches = dict(custom_parameters.patches)
|
|
269
261
|
|
|
270
262
|
app, state = create_app(session, table, output_dir, zip_output=args.zip)
|
|
271
263
|
if startup_status:
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from collections.abc import Mapping, Sequence
|
|
6
|
-
from dataclasses import fields
|
|
7
6
|
import json
|
|
8
7
|
from pathlib import Path
|
|
9
8
|
import textwrap
|
|
@@ -13,7 +12,7 @@ import zipfile
|
|
|
13
12
|
from pyplumio.cli.model import Row
|
|
14
13
|
from pyplumio.const import PERCENTAGE, STATE_ON, UnitOfMeasurement
|
|
15
14
|
from pyplumio.parameters import ParameterValues
|
|
16
|
-
from pyplumio.parameters.custom import
|
|
15
|
+
from pyplumio.parameters.custom import model_slug
|
|
17
16
|
from pyplumio.parameters.ecomax import (
|
|
18
17
|
EcomaxNumberDescription,
|
|
19
18
|
EcomaxParameterDescription,
|
|
@@ -27,11 +26,13 @@ COMMENT_PREFIX: Final = " # "
|
|
|
27
26
|
ENTRY_PREFIX: Final = " "
|
|
28
27
|
|
|
29
28
|
MODULE_TEMPLATE: Final = (
|
|
30
|
-
'"""Contains
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"{
|
|
29
|
+
'"""Contains custom parameters for {model}."""\n\n'
|
|
30
|
+
"from __future__ import annotations\n\n"
|
|
31
|
+
"{imports}\n\n"
|
|
32
|
+
"PARAMETERS = custom_parameters(\n"
|
|
33
|
+
' model="{model}",\n'
|
|
34
|
+
" id={product_id},\n"
|
|
35
|
+
"{blocks})\n"
|
|
35
36
|
)
|
|
36
37
|
|
|
37
38
|
TEST_TEMPLATE: Final = (
|
|
@@ -89,8 +90,9 @@ def _format_unit(unit: UnitOfMeasurement | Literal["%"] | None) -> str:
|
|
|
89
90
|
|
|
90
91
|
def _format_field_value(field_name: str, value: Any) -> str:
|
|
91
92
|
"""Format single field value for code generation."""
|
|
92
|
-
if field_name == "
|
|
93
|
-
|
|
93
|
+
if field_name == "unit":
|
|
94
|
+
unit = PERCENTAGE if value == PERCENTAGE else UnitOfMeasurement(value).value
|
|
95
|
+
return f'"{unit}"'
|
|
94
96
|
|
|
95
97
|
if isinstance(value, float) and value.is_integer():
|
|
96
98
|
return str(int(value))
|
|
@@ -104,13 +106,27 @@ def _format_field_value(field_name: str, value: Any) -> str:
|
|
|
104
106
|
def _format_description(
|
|
105
107
|
description: EcomaxParameterDescription,
|
|
106
108
|
) -> tuple[str, list[str]]:
|
|
107
|
-
"""Format
|
|
108
|
-
arguments = [
|
|
109
|
-
|
|
110
|
-
for
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
"""Format factory function name and arguments."""
|
|
110
|
+
arguments = [f'"{description.name}"']
|
|
111
|
+
if isinstance(description, EcomaxNumberDescription):
|
|
112
|
+
for field_name, attr_name, default in (
|
|
113
|
+
("step", "step", 1.0),
|
|
114
|
+
("offset", "offset", 0),
|
|
115
|
+
("precision", "precision", 6),
|
|
116
|
+
("optimistic", "optimistic", False),
|
|
117
|
+
("unit", "unit_of_measurement", None),
|
|
118
|
+
):
|
|
119
|
+
if (value := getattr(description, attr_name)) != default:
|
|
120
|
+
arguments.append(
|
|
121
|
+
f"{field_name}={_format_field_value(field_name, value)}"
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
return "number", arguments
|
|
125
|
+
|
|
126
|
+
if description.optimistic:
|
|
127
|
+
arguments.append("optimistic=True")
|
|
128
|
+
|
|
129
|
+
return "switch", arguments
|
|
114
130
|
|
|
115
131
|
|
|
116
132
|
def _format_comment(comment: str) -> str:
|
|
@@ -125,75 +141,52 @@ def _format_comment(comment: str) -> str:
|
|
|
125
141
|
|
|
126
142
|
|
|
127
143
|
def _format_dict_entry(
|
|
128
|
-
|
|
144
|
+
key: int | str,
|
|
129
145
|
description: EcomaxParameterDescription,
|
|
130
146
|
comment: str | None = None,
|
|
131
147
|
) -> str:
|
|
132
|
-
"""Format single
|
|
148
|
+
"""Format single dictionary entry with 88-column wrapping."""
|
|
133
149
|
comment_prefix = _format_comment(comment) if comment else ""
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
150
|
+
func_name, arguments = _format_description(description)
|
|
151
|
+
formatted_key = f'"{key}"' if isinstance(key, str) else str(key)
|
|
152
|
+
prefix = f"{ENTRY_PREFIX}{formatted_key}: "
|
|
153
|
+
single_line = f"{func_name}({', '.join(arguments)})"
|
|
137
154
|
if len(prefix) + len(single_line) + 1 <= MAX_LINE_LENGTH:
|
|
138
155
|
return f"{comment_prefix}{prefix}{single_line},"
|
|
139
156
|
|
|
140
157
|
body = "\n".join(f" {arg}," for arg in arguments)
|
|
141
|
-
return f"{comment_prefix}{prefix}{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def
|
|
145
|
-
"""Format
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
body = "\n".join(f" {arg}," for arg in arguments)
|
|
153
|
-
replacement = (
|
|
154
|
-
f" replacement={single_replacement},"
|
|
155
|
-
if len(f" replacement={single_replacement},") <= MAX_LINE_LENGTH
|
|
156
|
-
else f" replacement={class_name}(\n{body}\n ),"
|
|
157
|
-
)
|
|
158
|
-
return (
|
|
159
|
-
f' ParameterOverride(\n original="{override.original}",\n'
|
|
160
|
-
f"{replacement}\n ),"
|
|
161
|
-
)
|
|
158
|
+
return f"{comment_prefix}{prefix}{func_name}(\n{body}\n ),"
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _format_dict_block(name: str, entries: list[str]) -> str:
|
|
162
|
+
"""Format a keyword dictionary block for custom_parameters()."""
|
|
163
|
+
if not entries:
|
|
164
|
+
return f" {name}={{}},\n"
|
|
165
|
+
|
|
166
|
+
joined = "\n".join(entries)
|
|
167
|
+
return f" {name}={{\n{joined}\n }},\n"
|
|
162
168
|
|
|
163
169
|
|
|
164
170
|
def _collect_module_imports(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
) ->
|
|
171
|
+
service_parameters: Mapping[int, EcomaxParameterDescription],
|
|
172
|
+
patches: Mapping[str, EcomaxParameterDescription],
|
|
173
|
+
) -> str:
|
|
168
174
|
"""Collect required module imports."""
|
|
169
|
-
all_descriptions = list(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
units = {
|
|
173
|
-
description.unit_of_measurement
|
|
175
|
+
all_descriptions = list(service_parameters.values()) + list(patches.values())
|
|
176
|
+
has_number = any(
|
|
177
|
+
isinstance(description, EcomaxNumberDescription)
|
|
174
178
|
for description in all_descriptions
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
*(["PERCENTAGE"] if has_percentage else []),
|
|
181
|
-
*(["UnitOfMeasurement"] if has_unit_of_measurement else []),
|
|
182
|
-
]
|
|
183
|
-
lines = [f"from pyplumio.const import {', '.join(consts)}"] if consts else []
|
|
179
|
+
)
|
|
180
|
+
has_switch = any(
|
|
181
|
+
isinstance(description, EcomaxSwitchDescription)
|
|
182
|
+
for description in all_descriptions
|
|
183
|
+
)
|
|
184
184
|
custom_imports = [
|
|
185
|
-
"
|
|
186
|
-
*(["
|
|
187
|
-
"
|
|
185
|
+
"custom_parameters",
|
|
186
|
+
*(["number"] if has_number else []),
|
|
187
|
+
*(["switch"] if has_switch else []),
|
|
188
188
|
]
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if classes := sorted(
|
|
192
|
-
{type(description).__name__ for description in all_descriptions}
|
|
193
|
-
):
|
|
194
|
-
lines.append(f"from pyplumio.parameters.ecomax import {', '.join(classes)}")
|
|
195
|
-
|
|
196
|
-
return lines
|
|
189
|
+
return f"from pyplumio.parameters.custom import {', '.join(custom_imports)}"
|
|
197
190
|
|
|
198
191
|
|
|
199
192
|
def _format_test_row(
|
|
@@ -279,34 +272,32 @@ def extract_comments(source: str) -> dict[int, str]:
|
|
|
279
272
|
|
|
280
273
|
def generate_custom_parameter_module(
|
|
281
274
|
product_info: ProductInfo,
|
|
282
|
-
|
|
283
|
-
|
|
275
|
+
service_parameters: Mapping[int, EcomaxParameterDescription],
|
|
276
|
+
patches: Mapping[str, EcomaxParameterDescription] | None = None,
|
|
284
277
|
comments: Mapping[int, str] | None = None,
|
|
285
278
|
) -> str:
|
|
286
279
|
"""Generate the custom parameter module file content."""
|
|
287
|
-
slug = model_slug(product_info.model)
|
|
288
280
|
comment_map = comments or {}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
)
|
|
292
|
-
description_lines = "\n".join(
|
|
281
|
+
patch_map = patches or {}
|
|
282
|
+
service_entries = [
|
|
293
283
|
_format_dict_entry(index, description, comment_map.get(index))
|
|
294
|
-
for index, description in sorted(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
284
|
+
for index, description in sorted(service_parameters.items())
|
|
285
|
+
]
|
|
286
|
+
patch_entries = [
|
|
287
|
+
_format_dict_entry(name, description) for name, description in patch_map.items()
|
|
288
|
+
]
|
|
289
|
+
blocks = ""
|
|
290
|
+
if service_entries or not patch_entries:
|
|
291
|
+
blocks += _format_dict_block("service_parameters", service_entries)
|
|
292
|
+
|
|
293
|
+
if patch_entries:
|
|
294
|
+
blocks += _format_dict_block("patches", patch_entries)
|
|
295
|
+
|
|
301
296
|
return MODULE_TEMPLATE.format(
|
|
302
297
|
model=product_info.model,
|
|
303
298
|
product_id=product_info.id,
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
override_block=(
|
|
307
|
-
f" overrides = (\n{override_lines}\n )\n\n" if overrides else ""
|
|
308
|
-
),
|
|
309
|
-
description_block=description_block,
|
|
299
|
+
imports=_collect_module_imports(service_parameters, patch_map),
|
|
300
|
+
blocks=blocks,
|
|
310
301
|
)
|
|
311
302
|
|
|
312
303
|
|
|
@@ -362,8 +353,8 @@ def generate_test_module(
|
|
|
362
353
|
|
|
363
354
|
def generate_all_files(
|
|
364
355
|
product_info: ProductInfo,
|
|
365
|
-
|
|
366
|
-
|
|
356
|
+
service_parameters: Mapping[int, EcomaxParameterDescription],
|
|
357
|
+
patches: Mapping[str, EcomaxParameterDescription] | None,
|
|
367
358
|
frame_message: bytes,
|
|
368
359
|
frame_parameters: Sequence[tuple[int, ParameterValues]],
|
|
369
360
|
output_dir: Path,
|
|
@@ -374,11 +365,11 @@ def generate_all_files(
|
|
|
374
365
|
return {
|
|
375
366
|
custom_module_path(output_dir, slug): (
|
|
376
367
|
generate_custom_parameter_module(
|
|
377
|
-
product_info,
|
|
368
|
+
product_info, service_parameters, patches, comments=comments
|
|
378
369
|
)
|
|
379
370
|
),
|
|
380
371
|
output_dir / f"tests/parameters/custom/test_{slug}.py": (
|
|
381
|
-
generate_test_module(product_info,
|
|
372
|
+
generate_test_module(product_info, service_parameters, frame_parameters)
|
|
382
373
|
),
|
|
383
374
|
output_dir / f"tests/testdata/parameters/{slug}.json": (
|
|
384
375
|
_generate_json_data(frame_message)
|