¡Hola! Acabo de recibir mi resumen semanal y tuve que releerlo tres veces antes de darme cuenta de que las comas habían sido reemplazadas por puntos, al estilo estadounidense… ¡Sería genial poder volver a un estado más coherente con el SI!
Hola @GBoulvin ,
Gracias por el feedback, ¡buena observación!
La IA redacta el resumen semanal a partir de los datos de tu casa, y Gladys se los envía en formato JSON. En JSON, los números siempre se escriben con un punto. Nada en las instrucciones dadas a la IA le pedía convertir los números al formato de tu idioma, por lo que los copió tal cual, al estilo americano
Tu captura también muestra un segundo problema: Gladys no redondea los valores antes de enviarlos, de ahí los « 92.168 kWh » y « 28.7603 euros ». ¡A nadie le hace falta el coste en centésimas de céntimo!
Voy a corregir los dos:
Gladys redondeará los consumos y los costes antes de enviarlos a la IA.
La IA tendrá la instrucción de escribir los números según las convenciones de tu idioma: la coma en francés, español y alemán, el punto en inglés.
He abierto un issue en GitHub para seguir la corrección: #3355
Te mantendré informado aquí en cuanto esté disponible
¡Hola a todos!
Este tema ahora está en desarrollo .
Se ha abierto una PR para escribir los números del resumen semanal de IA en el idioma del usuario y redondearlos:
master ← fix/weekly-digest-number-format
opened 09:06AM - 13 Nov 26 UTC
### Description
The AI weekly digest wrote numbers the American way even for Fr… ench-speaking users (`111.34 kWh`, `33.93 euros`), and some values were not rounded at all (`92.168 kWh`, `28.7603 euros` for the previous week).
**Root cause**
- `gateway.buildWeeklyDigestData.js` sent the raw sums of the daily buckets (`current_week_kwh`, `previous_week_kwh`, `current_week_cost`, `previous_week_cost`) with every decimal.
- `gateway.sendWeeklyDigest.js` sends that data as JSON, where numbers always use a period.
- `weeklyDigest.prompt.txt` said nothing about number formatting, so the AI copied the JSON numbers as they were and rounded only some of them.
**Fix**
- **Rounding before the AI**: the weekly kWh and cost totals are rounded to two decimals (`roundDigestValue`), and a missing total stays `null`. `92.168` → `92.17`, `28.7603` → `28.76`.
- **Decimal separator per admin**: each digest request now says which decimal separator the admin's language uses (`Decimal separator: ","` for fr / es / de, `"."` for en). `getDecimalSeparator` reads it from `Intl.NumberFormat` and falls back on a period for an unknown language.
- **Prompt**: a new "Numbers" section tells the AI that the JSON always uses a period and must not be copied as is. It also says to use the separator given in the request (with examples), never to write more decimals than the payload has, and to write costs with two decimals.
No living spec in `docs/specs/` covers the digest payload or prompt (`ai-type.md` only covers routing, and `energy-contracts.md` §8.3 only covers the main-meter lookup), so no spec update was needed.
**Tests**
- `gateway.buildWeeklyDigestData.test.js`: unit tests for `roundDigestValue`; kWh and cost totals rounded in `fetchEnergyConsumptionForFeature` (current and previous week, using the forum values); a missing previous-week total stays `null`.
- `gateway.sendWeeklyDigest.test.js`: the exact user message for a French and an English admin; `getDecimalSeparator` for fr / es / de / en and for an invalid language.
### Related request
Forum: https://community.gladysassistant.com/t/resume-hebdomadaire-ou-sont-les-virgules/10819
Closes #3355
### Checklist
- [x] If a forum topic or GitHub issue exists, the description links it (`Forum: https://community.gladysassistant.com/t/...` or `Closes #...`)
- [x] Tests pass: `cd server && npm run coverage` (Codecov requires 100% coverage on changed lines) and Cypress (`npm run cypress:run`) if the UI changed
- Changed files: `gateway.sendWeeklyDigest.js` 100% on every metric. In `gateway.buildWeeklyDigestData.js` every changed line and branch is covered; the only uncovered branches are on lines this PR does not touch. No UI change, so Cypress was not run.
- In the agent's sandbox, 26 tests outside this area fail, the same 26 on an untouched `master`: backup / restore tests need the `sqlite3` CLI, which the sandbox lacks, and Gladys Plus API controller tests get a `405` from the sandbox HTTP proxy instead of their mocked responses.
- [x] Linter and prettier pass on both front and server (`npm run eslint`, `npm run prettier`): server only, no front change. ESLint reports 0 errors and no warnings in the changed files.
- [x] No undocumented breaking change
---
_Generated by [Claude Code](https://claude.ai/code/session_01MNjB3688t7fM4zbqhd2Rvn)_
No dudes en seguir la PR, probar (opcional, especialmente para pequeñas solicitudes) y dar tus comentarios aquí si es necesario.
Hola,
El formato de los números en el resumen semanal (comas según el idioma, y redondeo) se ha corregido en Gladys Assistant 5.3.3 .
Los detalles están en el anuncio:
¡Hola a todos!
¡Gladys Assistant 5.3.3 está aquí
No te dejes engañar por el número de versión: este lanzamiento se centra casi por completo en un proyecto, Gladys en tu teléfono. Muchos de vosotros consultáis vuestro panel de control en el móvil, pero en cuanto queréis cambiar un widget o una escena, os encontráis con un formulario de escritorio comprimido en una pantalla pequeña. Por eso hemos reconstruido el panel de control y la edición de escenas partiendo del teléfono. En un ordena…