smithops
@tsmith · Mitglied seit Januar 2026
Plant manager · automotive · 6 years in the field
- Themen
- 4
- Antworten
- 35
- Punkte
- 0
Erstellte Forenantworten
Not at 140 m next to VFDs it isn’t.
Von English mit KI übersetzt ·
Kevin hat recht, und die „preconfigured“-Verbindung ist diejenige, die der Imager aus deinem Heim-WLAN angelegt hat. Füge den Hotspot als zweite NetworkManager-Verbindung hinzu und vergib jeweils eine Priorität. Ich transportiere einen Pi genau so zwischen zwei Fabriken.
sudo nmcli con add type wifi ifname wlan0 con-name allotment
ssid "Aisha-phone" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "********"
sudo nmcli con modify allotment connection.autoconnect yes connection.autoconnect-priority 10
sudo nmcli con modify preconfigured connection.autoconnect-priority 20
nmcli -f NAME,AUTOCONNECT,AUTOCONNECT-PRIORITY con show
Wenn beide in Reichweite sind, gewinnt die höhere Priorität, also zuerst das Heimnetz. Schalte den Hotspot ein, bevor du den Pi einschaltest; bootet der Pi zuerst, gib ihm eine Minute, NetworkManager sucht dann erneut.Zur Zwischenspeicherung: Halte die Messwerte in einer kleinen SQLite-Tabelle oder sogar in einer JSONL-Datei vor und sende sie, sobald die Verbindung zurück ist, mit ihren eigenen Zeitstempeln in Stapeln:
[{"ts": 1762668000000, "values": {"soil.bed3": 31.5, "air.temp": 12.1}},
{"ts": 1762668300000, "values": {"soil.bed3": 31.2, "air.temp": 12.6}}]
ts ist in Millisekunden UTC. Lösche eine Zeile erst, nachdem die Veröffentlichung bestätigt wurde (QoS 1, in paho auf das PUBACK warten mit wait_for_publish()).Eine Falle beim Pi: Er hat keine batteriegepufferte Uhr. Startet er am Schrebergarten und bekommt längere Zeit kein Netz, ist die Uhr falsch, bis NTP synchronisiert; Messwerte mit dieser Uhr gestempelt landen dann zur falschen Zeit oder werden verworfen (mehr als 10 Minuten in der Zukunft werden abgelehnt). Versieh Messwerte nur dann mit einem Zeitstempel, wenn timedatectl show -p NTPSynchronized yes meldet; andernfalls sende sie ohne ts und lass Hermetry die Ankunftszeit verwenden.
Kevin’s right, and the „preconfigured“ connection is the one the imager created from your home WiFi. Add the hotspot as a second NetworkManager connection and give both a priority. I carry a Pi between two factories with exactly this.
sudo nmcli con add type wifi ifname wlan0 con-name allotment
ssid "Aisha-phone" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "********"
sudo nmcli con modify allotment connection.autoconnect yes connection.autoconnect-priority 10
sudo nmcli con modify preconfigured connection.autoconnect-priority 20
nmcli -f NAME,AUTOCONNECT,AUTOCONNECT-PRIORITY con show
Higher priority wins when both are in range, so home first. Turn the hotspot on before you power the Pi; if it boots first, give it a minute, NetworkManager rescans.
For buffering: keep the readings in a small SQLite table or even a JSONL file, and when the connection comes back send them with their own time stamps, in batches:
[{"ts": 1762668000000, "values": {"soil.bed3": 31.5, "air.temp": 12.1}},
{"ts": 1762668300000, "values": {"soil.bed3": 31.2, "air.temp": 12.6}}]
ts is milliseconds UTC. Delete a row only after the publish is acknowledged (QoS 1, wait for the PUBACK in paho with wait_for_publish()).
One trap with a Pi: there’s no battery-backed clock. If it boots at the allotment and gets no network for a while, the clock is wrong until NTP syncs, and readings stamped with that clock end up at the wrong time or get dropped (more than 10 minutes in the future is refused). Only stamp readings after timedatectl show -p NTPSynchronized says yes, otherwise send them without ts and let Hermetry use the arrival time.
Von English mit KI übersetzt ·
Genau das machen wir für die Linienbeleuchtung in unserem Werk, über ein kleines Skript auf dem PC des Supervisors. Es ist die Commands API mit einem API-Schlüssel.Ihre Schaltkarte sendet bereits einen Befehl, und Geräte können nur Befehle senden, die im Commands-Katalog des Gerätoprofils auf der Basic-Stufe stehen. Die Methode existiert also. Um ihren genauen Namen und ihre Parameter zu sehen, fragen Sie die API mit demselben Schlüssel ab, den Sie gleich erstellen: GET /tenant/<tenantId>/api/iot/devices/<deviceId>/rpc-commands listet auf, was eine Steuerung an dieses Gerät senden darf.Erstellen Sie den Schlüssel unter API Keys: Geben Sie ihm die Berechtigung, Basisbefehle zu senden und Befehle zu lesen, tragen Sie die Adresse Ihres Desktops in die IP-Allowlist ein und wählen Sie ein Ablaufdatum. Dann:
#!/bin/sh
# ~/bin/office-lights (chmod 700)
KEY=$(cat ~/.config/hermetry/key)
curl -s -X POST "https://<your host>/tenant/<tenantId>/api/iot/devices/<deviceId>/rpc"
-H "Authorization: Bearer $KEY"
-H "Content-Type: application/json"
-d "{"method":"light.set","params":{"on":$1},"timeoutMs":10000}"
Ein zweiseitiger Befehl mit einem Timeout von 30 Sekunden oder weniger wartet und antwortet mit 200 und dem Status, sodass Sie im Terminal SUCCESSFUL oder den Fehler sehen. Binden Sie office-lights true und office-lights false an zwei Tastenkürzel, und Sie sind fertig. Ein API-Schlüssel kann nur Methoden senden, die im Katalog stehen, was ohnehin genau das ist, was Sie hier wollen.Dokumentation: Commands API.
We do exactly this for the line lights at our plant, from a little script on the supervisor’s PC. It’s the Commands API with an API key.
Your switch card already sends a command, and boards can only send commands that are in the device profile’s Commands catalogue at the Basic tier. So the method exists. To see its exact name and params, ask the API with the same key you’re about to create: GET /tenant/<tenantId>/api/iot/devices/<deviceId>/rpc-commands lists what a control may send to that device.
Create the key under API Keys: give it the permission to send basic commands and to read commands, put your desktop’s address in the IP allowlist, and pick an expiry. Then:
#!/bin/sh
# ~/bin/office-lights (chmod 700)
KEY=$(cat ~/.config/hermetry/key)
curl -s -X POST "https://<your host>/tenant/<tenantId>/api/iot/devices/<deviceId>/rpc"
-H "Authorization: Bearer $KEY"
-H "Content-Type: application/json"
-d "{"method":"light.set","params":{"on":$1},"timeoutMs":10000}"
A two-way command with a timeout of 30 seconds or less waits and answers 200 with the status, so you see SUCCESSFUL or the error in the terminal. Bind office-lights true and office-lights false to two shortcuts and you’re done. An API key can only send methods that are in the catalogue, which is what you want here anyway.
Docs: Commands API.
Von English mit KI übersetzt ·
Machbar. Stell den Pi und den Router aber an eine kleine USV, sonst bringt dir der Pi bei Lastabwürfen nichts.
Feasible. Put the Pi and the router on a small UPS though, otherwise the Pi buys you nothing during load shedding.
Von English mit KI übersetzt ·
Teiler am Echo, gut. Wie weit ist der Sensor vom Wasser entfernt, wenn der Tank voll ist?
Divider on echo, good. How far is the sensor from the water when the tank is full?

