Consumo semanal de gas con un ESP32 que cuenta pulsos en nuestro contador Landis+Gyr, enviado por correo a finanzas cada lunes
Traducido del English por IA ·
Jefe de planta, taller de pintura de automoción. Finanzas quiere una cifra semanal de gas para los hornos de pintura cada lunes a las 7, y ahora mismo alguien lee el contador a mano el domingo por la noche. No es lo ideal.El contador es un contador de membrana Landis+Gyr con salida de pulsos por lámina Reed, 1 pulso = 0,01 m³. Uno de nuestros técnicos de mantenimiento instaló un ESP32 que cuenta los pulsos por interrupción y publica el total acumulado una vez por minuto:
{"gas_m3": 18234.57}
Eso lleva un mes funcionando en Hermetry y la gráfica se ve bien. Supuse que habría algún informe programado que envíe por correo el total semanal, pero he revisado todo y no lo encuentro. ¿Qué hace la gente para esto? Prefiero no tener que exportar un CSV cada lunes; eso es justo lo que quiero eliminar.
Plant manager, automotive paint shop. Finance wants a weekly gas figure for the paint ovens every Monday at 7, and right now someone reads the meter by hand on Sunday night. Not great.
The meter is a Landis+Gyr diaphragm meter with a reed pulse output, 1 pulse = 0.01 m³. One of our maintenance guys put an ESP32 on it that counts pulses on an interrupt and publishes the running total once a minute:
{"gas_m3": 18234.57}
That’s been in Hermetry for a month and the chart looks right. I assumed there’d be a scheduled report somewhere that mails a weekly total, but I’ve clicked through everything and can’t find one. What do people do for this? I’d rather not have a person export a CSV every Monday, that’s the thing I’m trying to get rid of.
Traducido del English por IA ·
A mí también me gustaría saberlo, es lo mismo para los contadores de gas de nuestros edificios.
I’d like to know too, same thing for our buildings’ gas meters.
Traducido del English por IA ·
¿El total de pulsos se conserva durante un corte de energía? Si el ESP32 arranca desde cero tras una interrupción, sus totales semanales serán incorrectos.
Is the pulse total kept over a power cut? If the ESP32 starts from zero after an outage your weekly totals go wrong.
Traducido del English por IA ·
Se almacena en FRAM y sobrevive a los cortes de energía. Solo vuelve a cero cuando cargamos un nuevo firmware.
It’s stored in FRAM, survives power cuts. It only goes back to zero when we flash new firmware.
Traducido del English por IA ·
¿Pensaba que en los dashboards había una opción de «Enviar informe»?
I thought there was a «send report» option on dashboards?
Traducido del English por IA ·
No lo creo. La página Exportar datos indica que no hay informes programados ni enviados por correo electrónico integrados. Las tarjetas tienen descarga en CSV y Excel, pero eso requiere que alguien haga clic.
I don’t think so. The Exporting data page says there are no built-in scheduled or e-mailed reports. Cards have a CSV and Excel download, but that’s someone clicking.
Traducido del English por IA ·
Banerjee tiene razón, no existe un informe enviado por correo. Lo hacemos para unos 20 contadores de energía con un pequeño script en nuestro propio servidor, basado en la API de historial. Nos llevó medio día de trabajo y lleva un año funcionando sin cambios.Pida el agregado increase. Para un contador como gas_m3, indica cuánto subió por intervalo, y si el contador se reinicia (por ejemplo, al flashear el firmware) cuenta desde cero en lugar de quedar en negativo.
import requests, time, smtplib
from email.message import EmailMessage
BASE = "https://<host>/tenant/<tenantId>"
KEY = "sk_live_..." # Read-only telemetry key, IP allowlist = this server
now = int(time.time() * 1000)
week_ago = now - 7 * 24 * 3600 * 1000
r = requests.get(BASE + "/api/telemetry/series", headers={"Authorization": "Bearer " + KEY},
params={"kind": "iot_device", "entityId": "<meter device id>", "keys": "gas_m3",
"from": week_ago, "to": now, "bucket": "1h", "agg": "increase"}, timeout=30)
r.raise_for_status()
# sum the hourly increases and mail the total to finance
Lo ejecutamos con cron a las 07:00 los lunes. Algunas lecciones aprendidas:
- Los intervalos diarios son días UTC. Si finanzas quiere días locales, pida intervalos de 1h y súmelos usted mismo.
- Asigne a la clave de API el preajuste Read-only y una lista de IP permitidas con solo ese servidor. Las claves caducan por defecto a los 90 días, así que ponga un recordatorio o una caducidad más larga (máximo un año).
- Como máximo 50 claves y 10.000 puntos por clave y por solicitud, lo cual sobra para una lectura horaria semanal.
Si prefiere no ejecutar un servidor, un flujo con un disparador Schedule y un bloque de solicitud HTTP puede llamar a su propio servicio de informes para generarlo y enviarlo. Nosotros optamos por el script.Exporting data enumera ambas opciones.
Banerjee’s right, there’s no mailed report. We do this for about 20 energy meters with a small script on our own server, built on the history API. It’s half a day of work and has run untouched for a year.
Ask for the increase aggregate. For a counter like gas_m3 it gives you how much it rose per bucket, and it handles a counter restart (your firmware flash) by counting from zero instead of going negative.
import requests, time, smtplib
from email.message import EmailMessage
BASE = "https://<host>/tenant/<tenantId>"
KEY = "sk_live_..." # Read-only telemetry key, IP allowlist = this server
now = int(time.time() * 1000)
week_ago = now - 7 * 24 * 3600 * 1000
r = requests.get(BASE + "/api/telemetry/series", headers={"Authorization": "Bearer " + KEY},
params={"kind": "iot_device", "entityId": "<meter device id>", "keys": "gas_m3",
"from": week_ago, "to": now, "bucket": "1h", "agg": "increase"}, timeout=30)
r.raise_for_status()
# sum the hourly increases and mail the total to finance
Run it from cron at 07:00 on Mondays. A few things we learned:
- Day buckets are UTC days. If finance wants local days, ask for 1h and add them up yourself.
- Give the API key the Read-only preset and an IP allowlist with just that server. Keys expire after 90 days by default, so set a reminder or a longer expiry (max a year).
- At most 50 keys and 10,000 points per key per request, which is nothing for a weekly hourly read.
If you’d rather not run a server, a flow with a Schedule trigger and an HTTP request block can poke your own reporting service to build and send it. We went with the script.
Exporting data lists both options.
Traducido del English por IA ·
Funciona desde la semana pasada en el equipo de reporting que ya genera nuestros informes de turno. El primer lunes la cifra estaba un poco desviada porque usaba intervalos de 1d y acabábamos de cambiar a horario de verano. Pasé a intervalos de 1h y coincide con la lectura manual con una precisión de 0,1 m³. Finanzas está contenta, y nadie tiene que leer el contador el domingo por la noche.
Running since last week on the reporting box that already does our shift reports. First Monday the figure was off a little because I used 1d buckets and we’d just moved to summer time, switched to 1h buckets and it matches the manual reading to 0.1 m³. Finance is happy, and nobody reads the meter on Sunday night anymore.
Traducido del English por IA ·
El mismo patrón funciona para contadores de agua. increase nos salvó cuando un contador se cambió a mitad de mes y el nuevo empezó en 0.
Same pattern works for water meters. increase saved us when a meter was swapped mid-month and the new one started at 0.
- Debes estar registrado para responder a este debate.
Únete a la conversación
Inicia sesión para preguntar y responder, dar me gusta a las publicaciones útiles y marcar la respuesta que resolvió tu problema. Cada aportación suma puntos y niveles.

