Skip to content

Commit 0572d15

Browse files
authored
Merge pull request #8 from RFD-FHEM/feat/mqttCommands
Alle Kommandos via mqtt abbilden
2 parents 47012d9 + fbcf77c commit 0572d15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3581
-7638
lines changed

.devcontainer/devcontainer.json

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,34 @@
33
{
44
"name": "Python 3",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/python:2-3-bookworm",
6+
"dockerComposeFile": "docker-compose.yml",
7+
"workspaceFolder": "/workspaces/PySignalduino",
8+
"service": "devcontainer",
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
// "features": {},
711
"features": {
12+
"ghcr.io/devcontainers/features/node:1": {
13+
"nodeGypDependencies": true,
14+
"installYarnUsingApt": true,
15+
"version": "lts",
16+
"pnpmVersion": "latest",
17+
"nvmVersion": "latest"
18+
},
19+
"ghcr.io/devcontainer-community/devcontainer-features/astral.sh-uv:1": {
20+
"shellautocompletion": true,
21+
"version": "latest"
22+
}
823
//"ghcr.io/hspaans/devcontainer-features/pytest:2": {}
924
},
10-
11-
// Features to add to the dev container. More info: https://containers.dev/features.
12-
// "features": {},
13-
1425
// Use 'forwardPorts' to make a list of ports inside the container available locally.
1526
// "forwardPorts": [],
16-
17-
// Use 'postCreateCommand' to run commands after the container is created.
18-
"postCreateCommand": "pip3 install --user -r requirements-dev.txt -r requirements.txt || exit 0",
1927
"customizations": {
2028
"vscode": {
2129
"extensions": [
2230
"RooVeterinaryInc.roo-cline"
2331
]
2432
}
2533
},
26-
"runArgs": ["--env-file", ".devcontainer/devcontainer.env"]
27-
28-
// Configure tool-specific properties.
29-
// "customizations": {},
30-
31-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
32-
// "remoteUser": "root"
34+
// Use 'postCreateCommand' to run commands after the container is created.
35+
"postCreateCommand": "pip3 install --user -r requirements-dev.txt -r requirements.txt || exit 0"
3336
}

.devcontainer/docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
devcontainer:
3+
# Build the image from the existing devcontainer setup
4+
image: mcr.microsoft.com/devcontainers/python:3
5+
# The current working directory is mounted automatically
6+
volumes:
7+
- ..:/workspaces/PySignalduino
8+
9+
# Use the existing settings from devcontainer.json
10+
# Overriding the entrypoint is necessary when using a non-Compose devcontainer base image
11+
command: /bin/bash -c "sleep infinity"
12+
13+
# Environment variables from .devcontainer/devcontainer.env
14+
env_file:
15+
- ./devcontainer.env
16+
17+
# This ensures services in the compose file can be reached by their service name
18+
# The default bridge network is sufficient for this purpose
19+
20+
mqtt:
21+
image: eclipse-mosquitto:latest
22+
container_name: mosquitto-dev-broker
23+
#ports:
24+
# Expose port 1883 on the host, so other local clients can also connect if needed
25+
#- "1883:1883"
26+
volumes:
27+
- ./mosquitto/config:/mosquitto/config
28+
- ./mosquitto/data:/mosquitto/data
29+
- ./mosquitto/log:/mosquitto/log
30+
command: mosquitto -c /mosquitto/config/mosquitto.conf
31+
restart: unless-stopped
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
listener 1883 0.0.0.0
2+
allow_anonymous true
3+
4+
# Mosquitto Standard-Pfade
5+
persistence true
6+
persistence_location /mosquitto/data/
7+
log_dest file /mosquitto/log/mosquitto.log

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ temp_repo/
66
SIGNALDuino-Firmware/
77
.devcontainer/devcontainer.env
88
.devcontainer/.devcontainer.env
9+
.devcontainer/mosquitto/data/
10+
.devcontainer/mosquitto/log/
11+
.roo/mcp.json

.roo/mcp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"mcpServers":{"filesystem":{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","/workspaces/PySignalduino"],"alwaysAllow":["edit_file","read_text_file","search_files","read_multiple_files"]},"git":{"command":"uvx","args":["mcp-server-git","--repository","/workspaces/PySignalduino"],"alwaysAllow":["git_diff_unstaged","git_checkout"]}}}

.roomodes

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
customModes:
2+
- slug: perlmigrator
3+
name: PerlMigrator
4+
roleDefinition: |-
5+
You are a Software Architect. Your a specalized on Perl and Python.
6+
First you plan your work and then you create the code.
7+
The main goal is to transform the functionality from the perl project into the python project.
8+
customInstructions: |
9+
We have a perl project which is working as expected. Every time, when migrating code to python, the perl code and also the test results act as a master.
10+
11+
If converting tests you will convert the testcases on an 1:1 basis in respect to the testdata and results.
12+
After creating a pythontest you will run it to be sure, that it passes.
13+
groups:
14+
- read
15+
- edit
16+
- browser
17+
- command
18+
- mcp
19+
source: project
20+
description: perl-2-python-architect

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,14 @@
4545
"tests"
4646
],
4747
"python.testing.unittestEnabled": false,
48-
"python.testing.pytestEnabled": true
48+
"python.testing.pytestEnabled": true,
49+
"vsmqtt.brokerProfiles": [
50+
{
51+
"name": "devmqtt",
52+
"host": "mqtt",
53+
"port": 1883,
54+
"clientId": "vsmqtt_client_db93",
55+
"savedSubscriptions": ['signalduino/v1/responses','signalduino/v1/messages','signalduino/v1/errors']
56+
}
57+
]
4958
}

AGENTS.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ This file provides guidance to agents when working with code in this repository.
1515
oder um eine längere Laufzeit zu analysieren:
1616
`python3 main.py --timeout 30`
1717

18+
## Test Timeout Configuration
19+
- Für pytest wurde ein globaler Timeout von 30 Sekunden in der `pyproject.toml` konfiguriert:
20+
```toml
21+
[tool.pytest.ini_options]
22+
timeout = 30
23+
```
24+
- Die erforderliche Abhängigkeit `pytest-timeout` wurde zur `requirements-dev.txt` hinzugefügt.
25+
1826
## Mandatory Documentation and Test Maintenance
1927

2028
Diese Richtlinie gilt für alle AI-Agenten, die Code oder Systemkonfigurationen in diesem Repository ändern. Jede Änderung **muss** eine vollständige Analyse der Auswirkungen auf die zugehörige Dokumentation und die Testsuite umfassen.
@@ -83,7 +91,7 @@ Dieser Abschnitt definiert den verbindlichen Arbeitsablauf für die Entwicklung
8391
- Aufteilung in konkrete Arbeitspakete (Tasks)
8492
- Definition von Akzeptanzkriterien für jede Komponente
8593
- Planung von Teststrategien (Unit, Integration, System)
86-
- Ressourcen- und Zeitplanung
94+
- Ressourcen- und Zeitplaning
8795
- Erstellung von Mockups/Prototypen für kritische Pfade
8896
- **Deliverables:**
8997
- Implementierungsplan mit Task-Breakdown
@@ -243,4 +251,45 @@ flowchart TD
243251

244252
Dieser Architecture-First Development Process ist für **alle** neuen Funktionen und wesentlichen Änderungen verbindlich. Ausnahmen sind nur bei kritischen Bugfixes erlaubt und müssen durch einen Emergency-ADR dokumentiert werden. Jede Abweichung vom Prozess muss vom Architecture Owner genehmigt werden.
245253

246-
Die Einhaltung dieses Prozesses gewährleistet, dass Design-Entscheidungen bewusst getroffen, dokumentiert und nachvollziehbar sind, was die langfristige Wartbarkeit, Skalierbarkeit und Qualität des PySignalduino-Projekts sicherstellt.
254+
Die Einhaltung dieses Prozesses gewährleistet, dass Design-Entscheidungen bewusst getroffen, dokumentiert und nachvollziehbar sind, was die langfristige Wartbarkeit, Skalierbarkeit und Qualität des PySignalduino-Projekts sicherstellt.
255+
256+
## Fehlerbehebungsprozess
257+
### Problemidentifikation
258+
1. **Symptom:** ImportError oder ModuleNotFoundError während der Testausführung
259+
2. **Ursachenanalyse:**
260+
- Überprüfen der Traceback-Meldung auf fehlende Module
261+
- Vergleich mit requirements.txt und requirements-dev.txt
262+
- Prüfen der Dokumentation auf Installationsanweisungen
263+
264+
### Lösungsimplementierung (Abhängigkeiten)
265+
1. **requirements-dev.txt aktualisieren:**
266+
- Modulname zur Datei hinzufügen
267+
- Commit mit Conventional Commits Syntax erstellen (z.B. "fix: add <module> to requirements-dev.txt")
268+
2. **Dokumentation prüfen:**
269+
- Sicherstellen, dass Installationsanweisungen in README.md und docs/ aktuell sind
270+
271+
### Problemidentifikation (Hohe CPU-Last im Parser)
272+
1. **Symptom:** Anhaltende 100% CPU-Auslastung auf einem oder mehreren Kernen während des Parsens von MU/MC-Nachrichten.
273+
2. **Ursachenanalyse:**
274+
- **Parser-Architektur prüfen:** Der gesamte Parservorgang sollte in [`signalduino/controller.py`](signalduino/controller.py) über `asyncio.to_thread` abgewickelt werden.
275+
- **Protokoll-Ineffizienz:** Die synchrone Demodulationsschleife in [`sd_protocols/message_unsynced.py`](sd_protocols/message_unsynced.py) oder [`sd_protocols/manchester.py`](sd_protocols/manchester.py) blockiert den Worker-Thread zu lange.
276+
3. **Validierung:** Temporäres Hinzufügen von Zeit-Logging (z.B. mit `time.perf_counter()`) in der Protokollschleife in `demodulate_mu` zur Identifizierung des blockierenden Protokolls.
277+
278+
### Lösungsimplementierung (Parser-Performance)
279+
1. **Backtracking-Hölle vermeiden:** Wenn ein Protokoll eine sehr lange Demodulationszeit (z.B. > 10ms) aufweist, liegt wahrscheinlich ein Catastrophic Backtracking in einem regulären Ausdruck vor.
280+
2 **Deaktivierung inaktiver Protokolle:** Die `active`-Prüfung in `demodulate_mu` sollte verwendet werden, um inaktive Protokolle auszuschließen.
281+
282+
### Verifikation
283+
1. **Installation testen:**
284+
```bash
285+
pip install -r requirements-dev.txt
286+
pytest
287+
```
288+
2. **Tests erneut ausführen:**
289+
```bash
290+
timeout 60 pytest ./tests/
291+
```
292+
293+
### Dokumentation
294+
- **AGENTS.md aktualisieren:** Diese Prozessbeschreibung hinzufügen
295+
- **Commit erstellen:** Änderungen mit aussagekräftiger Nachricht committen

docs/01_user_guide/index.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,5 @@ Für einen schnellen Einstieg folgen Sie diesen Schritten:
7979
Ausführliche Anleitungen finden Sie in den folgenden Kapiteln.
8080

8181
include::installation.adoc[]
82-
include::usage.adoc[]
82+
include::usage.adoc[]
83+
include::mqtt_api.adoc[]

0 commit comments

Comments
 (0)