Skip to content

Conversation

@sidey79
Copy link
Collaborator

@sidey79 sidey79 commented Dec 31, 2025

No description provided.

sidey79 and others added 17 commits December 21, 2025 21:15
STX messages (sensor data) can be interleaved with command responses, similar to MU/MS messages.
The controller must skip these messages and continue waiting for the actual command response.
The STX message is parsed to ensure sensor data is handled correctly while waiting.
- Fix busy loop in `mock_transport` fixture by adding `asyncio.sleep` to `readline` side effect.
- Fix `test_initialize_retry_logic` assertion to account for 'XQ' command sent during initialization.
- Fix `test_stx_message_bypasses_command_response` by manually starting controller tasks and updating mock response.
- Fix `test_send_command_with_response` by starting the missing `_parser_task`, updating mock to avoid StopIteration, and increasing timeout.
- Fix `test_message_callback` mock setup to yield message once and then None.
- Fix `test_send_command_fire_and_forget` cleanup logic to remove undefined `reader_task` cancellation.
This commit introduces new functionality to process Signalduino commands received via MQTT, significantly enhancing the integration capabilities of PySignalduino.

Key changes include:
- Extended the command list in `signalduino/commands.py` to include new MQTT-related commands and specific CC1101 register commands.
- Implemented and integrated the MQTT publisher logic within `signalduino/controller.py`.
- Introduced and adapted unit tests in `tests/test_mqtt_commands.py` and other test files to ensure full coverage of the new MQTT command processing.
@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

❌ Patch coverage is 81.41762% with 194 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.62%. Comparing base (57a12f0) to head (313814e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
signalduino/commands.py 64.44% 76 Missing and 4 partials ⚠️
signalduino/controller.py 70.27% 61 Missing and 5 partials ⚠️
signalduino/mqtt.py 73.07% 12 Missing and 2 partials ⚠️
tests/test_controller.py 91.76% 5 Missing and 2 partials ⚠️
tests/conftest.py 76.92% 5 Missing and 1 partial ⚠️
tests/test_transport.py 81.48% 4 Missing and 1 partial ⚠️
sd_protocols/message_unsynced.py 73.33% 3 Missing and 1 partial ⚠️
tests/test_connection_drop.py 88.46% 3 Missing ⚠️
tests/test_mqtt.py 97.11% 3 Missing ⚠️
tests/test_mqtt_commands.py 97.19% 3 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #8      +/-   ##
==========================================
+ Coverage   79.02%   80.62%   +1.59%     
==========================================
  Files          55       57       +2     
  Lines        5177     5413     +236     
  Branches      628      597      -31     
==========================================
+ Hits         4091     4364     +273     
+ Misses        863      839      -24     
+ Partials      223      210      -13     
Flag Coverage Δ
unittests 80.62% <81.41%> (+1.59%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sidey79 added 7 commits January 2, 2026 22:20
… CPU idle usage

The `_reader_task`'s `await asyncio.sleep(0)` call was conditionally placed inside the `if line is not None:` block. If the underlying transport's `readline()` implementation unexpectedly returns immediately without raising an exception or yielding correctly (e.g., in a race condition or specific platform behavior), the `while` loop could consume 100% CPU in the idle state.

Moving `await asyncio.sleep(0)` to be unconditionally executed at the end of the `try` block ensures the event loop yields to other tasks in every loop iteration, even if no line was received.
Integriert einen dedizierten MQTT Command-Listener und refaktoriert die Publisher/Controller-Beziehung für direktes Command-Handling.

- feat(mqtt): MqttPublisher verarbeitet Commands nun intern über `_handle_command`
- refactor(controller): Controller injiziert MqttPublisher für Heartbeats und direkten Zugriff
- perf(protocols): Optimierung der Demodulationsschleife für inaktive Protokolle in `message_unsynced.py`
- fix(main): Auflösung der zirkulären Abhängigkeit zwischen Controller und Publisher
- test: Anpassung der Testsuite an neue Architektur und Mocking-Strategie
Refactor MQTT handling to use MqttCommandDispatcher. Add CLI tool for MQTT commands. Add tests and architecture documentation.
@sidey79 sidey79 force-pushed the feat/mqttCommands branch from 4aaed61 to c3c36c4 Compare January 4, 2026 21:44
sidey79 added 2 commits January 4, 2026 21:49
The 'req_id' field in MQTT command payloads is now optional. This required
changes to the JSON schema validation and the response handling logic.

- Updates `BASE_SCHEMA` and `SEND_MSG_SCHEMA` in `signalduino/commands.py` to remove the `req_id` requirement.
- Modifies `MqttCommandDispatcher.dispatch` to return `None` for `req_id` if not present in the payload.
- Adjusts `MqttPublisher._handle_command` to correctly extract the optional `req_id` for success and error responses.
- Adds `test_controller_handles_get_frequency_without_req_id` to verify the new optional behavior.
- Updates `docs/architecture/proposals/mqtt_set_commands.adoc` to document the optional nature of `req_id`.
Die Debug-Meldungen in den Protokolldateien wurden fälschlicherweise über print() ausgegeben, was dazu führte, dass sie unabhängig vom konfigurierten log-level (z.B. INFO) im Terminal erschienen.

Die direkten print()-Aufrufe wurden durch korrekte logging.debug()-Aufrufe in sd_protocols/message_synced.py und sd_protocols/pattern_utils.py ersetzt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants