smithops
@tsmith · Se unió el enero 2026
Plant manager · automotive · 6 years in the field
- Temas
- 4
- Respuestas
- 35
- Puntos
- 0
Respuestas de foro creadas
Not at 140 m next to VFDs it isn’t.
Traducido del English por IA ·
Kevin tiene razón, y la conexión «preconfigured» es la que creó el imager a partir de tu WiFi de casa. Añade el hotspot como segunda conexión de NetworkManager y asigna una prioridad a ambas. Yo llevo una Pi entre dos fábricas exactamente con esta configuración.
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
Si ambas están al alcance, gana la prioridad más alta, así que primero la de casa. Enciende el hotspot antes de alimentar la Pi; si arranca primero, dale un minuto, NetworkManager vuelve a escanear.Para el almacenamiento temporal: guarda las lecturas en una tabla SQLite pequeña o incluso en un archivo JSONL, y cuando vuelva la conexión envíalas con sus propias marcas de tiempo, en lotes:
[{"ts": 1762668000000, "values": {"soil.bed3": 31.5, "air.temp": 12.1}},
{"ts": 1762668300000, "values": {"soil.bed3": 31.2, "air.temp": 12.6}}]
ts está en milisegundos UTC. Borra una fila solo después de confirmar la publicación (QoS 1, espera el PUBACK en paho con wait_for_publish()).Una trampa con la Pi: no tiene reloj con batería de respaldo. Si arranca en el huerto y no obtiene red durante un rato, el reloj es incorrecto hasta que NTP se sincroniza, y las lecturas marcadas con ese reloj acaban con la hora equivocada o se descartan (más de 10 minutos en el futuro se rechaza). Marca las lecturas con hora solo cuando timedatectl show -p NTPSynchronized diga yes; si no, envíalas sin ts y deja que Hermetry use la hora de llegada.
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.
Traducido del English por IA ·
Hacemos exactamente esto para las luces de línea de nuestra planta, desde un pequeño script en el PC del supervisor. Es la API de Commands con una clave de API.Su tarjeta de conmutación ya envía un comando, y las placas solo pueden enviar comandos que estén en el catálogo Commands del perfil del dispositivo en el nivel Basic. Así que el método existe. Para ver su nombre exacto y sus parámetros, consulte la API con la misma clave que va a crear: GET /tenant/<tenantId>/api/iot/devices/<deviceId>/rpc-commands lista lo que un control puede enviar a ese dispositivo.Cree la clave en API Keys: concédale el permiso para enviar comandos básicos y leer comandos, añada la dirección de su escritorio a la lista de IP permitidas y elija una caducidad. Después:
#!/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}"
Un comando bidireccional con un tiempo de espera de 30 segundos o menos espera y responde 200 con el estado, así que verá SUCCESSFUL o el error en el terminal. Asigne office-lights true y office-lights false a dos atajos y listo. Una clave de API solo puede enviar métodos que estén en el catálogo, que es justo lo que se quiere aquí.Documentación: 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.
Traducido del English por IA ·
Factible. Eso sí, conecta la Pi y el router a un pequeño SAI (UPS); si no, la Pi no te sirve de nada durante los cortes de carga.
Feasible. Put the Pi and the router on a small UPS though, otherwise the Pi buys you nothing during load shedding.
Traducido del English por IA ·
Divisor en el echo, bien. ¿A qué distancia está el sensor del agua cuando el depósito está lleno?
Divider on echo, good. How far is the sensor from the water when the tank is full?

