# IA : Demander des questions sur la consommation énergétique

**URL:** <https://community.gladysassistant.com/t/ia-demander-des-questions-sur-la-consommation-energetique/10355>\
**Category:** Demandes livrées\
**Created:** [Juillet 17, 2026, 12:54 UTC](https://community.gladysassistant.com/t/ia-demander-des-questions-sur-la-consommation-energetique/10355 "2026-07-17T12:54:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris75](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@Chris75](https://community.gladysassistant.com/u/Chris75)\
**Post date:** [Juillet 17, 2026, 12:54 UTC](https://community.gladysassistant.com/t/ia-demander-des-questions-sur-la-consommation-energetique/10355/1 "2026-07-17T12:54:17Z")

</div>

« quelle a été la consommation en Kwh de la prise onduleur pour la journée du 12 juillet 2026 »

«&nbsp;quel coût en euro pour la consommation de la prise télé pour le mois de juin 2026&nbsp;»

etc…

---

<div class="post-metadata">

**Author:** ![guim31](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/guim31/32/4840_2.png) [@guim31](https://community.gladysassistant.com/u/guim31)\
**Post date:** [Juillet 18, 2026, 4:04 UTC](https://community.gladysassistant.com/t/ia-demander-des-questions-sur-la-consommation-energetique/10355/2 "2026-07-18T16:04:18Z")

</div>

Si je ne m’abuse, ça n’a pas de rapport avec les graphiques mais avec un historique d’état ou calcul de ceux-ci 🤔 ou je me plante ?

---

<div class="post-metadata">

**Author:** ![Chris75](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@Chris75](https://community.gladysassistant.com/u/Chris75)\
**Post date:** [Juillet 19, 2026, 8:18 UTC](https://community.gladysassistant.com/t/ia-demander-des-questions-sur-la-consommation-energetique/10355/3 "2026-07-19T08:18:58Z")

</div>

@guim31 oui peut-être, mais est-ce que les cumuls (pour une journée par exemple) sont conservés en tant qu’historique ou bien sont recalculés pour l’affichage du graphique ?

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [Juillet 23, 2026, 12:16 UTC](https://community.gladysassistant.com/t/ia-demander-des-questions-sur-la-consommation-energetique/10355/4 "2026-07-23T12:16:25Z")

</div>

C’est bon, l’IA peut désormais répondre aux questions liées à la consommation électrique d’un équipement, en kWh et en euros !

> <https://github.com/GladysAssistant/Gladys/pull/2701>
>
> \### Pull Request check-list
> 
> To ensure your Pull Request can be accepted as fast… as possible, make sure to review and check all of these items:
> 
> \- \[x\] If your changes affect the code, did you write the tests?
> \- \[x\] Are server tests passing with coverage? (\`cd server && npm run coverage\`) — Codecov requires \*\*100% coverage on lines changed in this PR\*\* (all new lines in \`buildSchemas.js\` are covered by the two new tests)
> \- \[\] Did Cypress E2E tests pass? (\`npm run cypress:run\` from repo root, if UI changed) — no UI change
> \- \[x\] Is the linter passing? (\`npm run eslint\` on both front/server)
> \- \[x\] Did you run prettier? (\`npm run prettier\` on both front/server)
> \- \[\] If you are adding a new feature/service, did you run the integration comparator? (\`npm run compare-translations\` on front) — no front change
> \- \[\] Did you test this pull request in real life? With real devices? — tested with unit tests only; real-life testing with an energy monitoring setup welcome
> \- \[\] If your changes modify the API (REST or Node.js), did you modify the API documentation? — no REST API change, the new tool is documented through its MCP/JSON schema description
> \- \[\] If you are adding a new features/services which needs explanation, did you modify the user documentation?
> \- \[\] Did you add fake requests data for the demo mode (\`front/src/config/demo.js\`) so that the demo website is working without a backend? — not needed, server-side only
> 
> \### Description of change
> 
> This PR lets the AI Chat answer questions like:
> 
> \- « quelle a été la consommation en kWh de la prise onduleur pour la journée du 12 juillet 2026 »
> \- « quel coût en euro pour la consommation de la prise télé pour le mois de juin 2026 »
> 
> Previously the chat only had \`device\_get\_history\`, which works with relative intervals (\`last-day\`, \`last-month\`…) and averaged aggregates, so it could neither target a specific date/month nor compute a consumption total or a cost.
> 
> \*\*What's added:\*\*
> 
> 1. \*\*New MCP tool \`device.get-energy-consumption\`\*\* (\`server/services/mcp/lib/buildSchemas.js\`), exposed only when at least one device has \`energy-sensor\` features of type \`thirty-minutes-consumption\` or \`thirty-minutes-consumption-cost\`. It reuses the existing \`device.energySensorManager.getConsumptionByDates()\` (same code path as the energy dashboard):
> - \`device\`: energy monitoring device name (enum),
> - \`start\_date\` / \`end\_date\`: inclusive \`YYYY-MM-DD\` dates (same local-midnight boundaries as the dashboard),
> - \`unit\`: \`kwh\` (consumption, with automatic Wh → kWh conversion) or \`currency\` (cost, using the cost feature's currency unit),
> - \`group\_by\`: optional \`hour\`/\`day\`/\`week\`/\`month\`/\`year\` detail (defaults to \`day\`).
>    
> The response contains the period total first, then the per-period detail. In currency mode, the home electricity contract subscription is returned as a separate \`home\_subscription\` entry so the model doesn't mix it up with the device's own consumption cost. Friendly error messages are returned for unknown devices, invalid dates, or devices without cost tracking configured.
> 
> 2. \*\*Intent router update\*\* (\`gateway.classifyAiChatToolCategories.js\`): the \`device\_query\` category description now mentions energy consumption (kWh) and energy cost over a period, so these questions are routed with the right tools.
> 
> 3. \*\*System prompt update\*\* (\`aiChat.prompt.txt\`): a rule instructs the model to use \`device\_get\_energy\_consumption\` with inclusive \`YYYY-MM-DD\` dates for consumption/cost questions, and never \`device\_get\_history\` for consumption totals or costs.
> 
> 4. \*\*Tests\*\* (\`buildSchemas.test.js\`): two new tests covering the kWh single-day query, the monthly cost query with subscription entry, the no-cost-tracking case, empty periods, unknown device, invalid/reversed dates, and the tool not being exposed without energy monitoring devices.
> 
> 🤖 Generated with \[Claude Code\](https://claude.com/claude-code)
> 
> https://claude.ai/code/session\_01UwzEsLH8BRLUUQu9iUBvYA
> 
> \---
> \_Generated by \[Claude Code\](https://claude.ai/code/session\_01UwzEsLH8BRLUUQu9iUBvYA)\_
> 
> 
> \## Summary by CodeRabbit
> 
> \* \*\*New Features\*\*
> \* Added an energy consumption and cost reporting tool for supported smart-home devices.
> \* Supports inclusive date-range queries (YYYY-MM-DD) with daily grouping and totals in kWh or currency.
> \* Includes subscription cost details when available, and adds notes when no data exists for the selected period.
> \* \*\*Bug Fixes\*\*
> \* Energy totals and costs now rely on dedicated energy measurements rather than historical activity.
> \* \*\*Tests\*\*
> \* Added end-to-end coverage for tool exposure, output shaping, and validation/error scenarios.

Ça partira dans la prochaine version de Gladys 🙂

---

<div class="post-metadata">

**Author:** ![Chris75](https://gladys-assistant-community.b-cdn.net/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@Chris75](https://community.gladysassistant.com/u/Chris75)\
**Post date:** [Juillet 23, 2026, 9:20 UTC](https://community.gladysassistant.com/t/ia-demander-des-questions-sur-la-consommation-energetique/10355/5 "2026-07-23T21:20:34Z")

</div>

parfait et merci !

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [Juillet 30, 2026, 8:25 UTC](https://community.gladysassistant.com/t/ia-demander-des-questions-sur-la-consommation-energetique/10355/6 "2026-07-30T20:25:08Z")

</div>

C’est disponible dans Gladys Assistant 4.84 :

> [@Gladys Assistant 4.84 : Les intégrations externes sont là rocket](https://community.gladysassistant.com/t/gladys-assistant-4-84-les-integrations-externes-sont-la/10396):
>
> Bonsoir à tous !! Je suis super heureux de sortir ce soir une version qui, je pense, va vraiment changer la vitesse d’évolution du projet. Les intégrations externes arrivent enfin dans Gladys ! Elles vont permettre d’enrichir beaucoup plus rapidement la liste des appareils et services compatibles, tout en permettant à chacun de développer et partager ses propres intégrations. Je vous explique tout dans cet article backhand_index_pointing_down

---

<div class="post-metadata">

**Author:** ![pierre-gilles](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/pierre-gilles/32/5886_2.png) [@pierre-gilles](https://community.gladysassistant.com/u/pierre-gilles)\
**Post date:** [Juillet 30, 2026, 8:25 UTC](https://community.gladysassistant.com/t/ia-demander-des-questions-sur-la-consommation-energetique/10355/7 "2026-07-30T20:25:11Z")

</div>


