smithops
@tsmith · Membre depuis janvier 2026
Plant manager · automotive · 6 years in the field
- Sujets
- 4
- Réponses
- 35
- Points
- 0
Toutes mes réponses sur les forums
Not at 140 m next to VFDs it isn’t.
Traduit de English par IA ·
Kevin a raison, et la connexion « preconfigured » est celle que l’imageur a créée à partir de ton WiFi domestique. Ajoute le point d’accès comme seconde connexion NetworkManager et donne une priorité à chacune. Je transporte un Pi entre deux usines exactement avec ce montage.
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
Quand les deux sont à portée, la priorité la plus élevée l’emporte, donc le réseau domestique d’abord. Active le point d’accès avant d’alimenter le Pi ; s’il démarre en premier, patiente une minute, NetworkManager relance la recherche.Pour la mise en mémoire tampon : conserve les relevés dans une petite table SQLite, voire dans un fichier JSONL, et quand la connexion revient, envoie-les avec leurs propres horodatages, par lots :
[{"ts": 1762668000000, "values": {"soil.bed3": 31.5, "air.temp": 12.1}},
{"ts": 1762668300000, "values": {"soil.bed3": 31.2, "air.temp": 12.6}}]
ts est exprimé en millisecondes UTC. Ne supprime une ligne qu’après confirmation de la publication (QoS 1, attends le PUBACK dans paho avec wait_for_publish()).Un piège avec un Pi : il n’a pas d’horloge sauvegardée par batterie. S’il démarre au jardin partagé et ne reçoit aucun réseau pendant un moment, l’horloge est fausse jusqu’à la synchronisation NTP ; les relevés horodatés avec cette horloge se retrouvent à la mauvaise heure ou sont rejetés (plus de 10 minutes dans le futur, c’est refusé). N’horodate les relevés qu’après que timedatectl show -p NTPSynchronized indique yes ; sinon, envoie-les sans ts et laisse Hermetry utiliser l’heure d’arrivée.
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.
Traduit de English par IA ·
Nous faisons exactement cela pour l’éclairage des lignes de notre usine, à partir d’un petit script sur le PC du superviseur. C’est l’API Commands avec une clé d’API.Votre carte de commutation envoie déjà une commande, et les cartes ne peuvent envoyer que les commandes présentes dans le catalogue Commands du profil d’appareil au niveau Basic. La méthode existe donc. Pour voir son nom exact et ses paramètres, interrogez l’API avec la même clé que vous allez créer : GET /tenant/<tenantId>/api/iot/devices/<deviceId>/rpc-commands liste ce qu’une commande peut envoyer à cet appareil.Créez la clé sous API Keys : accordez-lui la permission d’envoyer des commandes de base et de lire les commandes, ajoutez l’adresse de votre bureau à la liste d’adresses IP autorisées, puis choisissez une date d’expiration. Ensuite :
#!/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}"
Une commande bidirectionnelle avec un délai d’expiration de 30 secondes ou moins attend et répond 200 avec le statut, vous voyez donc SUCCESSFUL ou l’erreur dans le terminal. Associez office-lights true et office-lights false à deux raccourcis et c’est terminé. Une clé d’API ne peut envoyer que les méthodes présentes dans le catalogue, ce qui est d’ailleurs ce que vous voulez ici.Documentation : 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.
Traduit de English par IA ·
Faisable. Branchez toutefois le Pi et le routeur sur un petit onduleur (UPS), sinon le Pi ne vous sert à rien pendant les délestages.
Feasible. Put the Pi and the router on a small UPS though, otherwise the Pi buys you nothing during load shedding.
Traduit de English par IA ·
Diviseur sur l’écho, c’est bien. À quelle distance se trouve le capteur de l’eau lorsque le réservoir est plein ?
Divider on echo, good. How far is the sensor from the water when the tank is full?

