# Semaine ultra intensive sur Gladys

**URL:** <https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374>\
**Category:** Actualités\
**Created:** [Juillet 23, 2026, 11:43 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374 "2026-07-23T11:43:50Z")\
**Posts on this page:** 9\
**Page:** 2

<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:** [Août 1, 2026, 5:57 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/25 "2026-08-01T05:57:05Z")

</div>

Pour rappel la semaine n’est pas terminée, elle ne fait que commencer !!

Encore aujourd’hui, demain et lundi à temps plein sur Gladys 🔥🔥

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [Août 1, 2026, 7:48 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/26 "2026-08-01T07:48:57Z")

</div>

Salut @pierre-gilles !

« La semaine ne fait que commencer » : ça fait plaisir à lire 🔥  
Justement, j’en profite pour te remonter un truc qu’on vient de rencontrer en développant l’intégration externe Shelly, parce qu’on pense que ça touche le SDK/core.

## Le problème

`publishDiscoveredDevices()` (donc `POST /discovered_device`) se prend un **`PayloadTooLargeError: request entity too large`** dès qu’on dépasse une petite douzaine d’appareils.

Le souci, c’est que **la découverte entière est alors perdue** : les appareils ont bien été trouvés, mais rien n’arrive à l’écran et l’utilisateur conclut que l’intégration ne les voit pas.

## Les chiffres

Un Shelly Pro 3EM expose **24 fonctionnalités** (3 phases × puissance active / apparente / tension / intensité, les totaux, et 8 compteurs d’énergie). Ça fait environ **8,4 Ko par appareil** une fois sérialisé.

| Appareils | Fonctionnalités | Taille du corps |
| --- | --- | --- |
| 10 | 240 | 82 Ko |
| 12 | 288 | 99 Ko |
| **13** | **312** | **107 Ko → refusé** |
| 17 | 408 | 140 Ko → refusé |

Le seuil tombe donc autour de **12 appareils** , ce qui est vite atteint sur une installation de suivi d’énergie. Chez moi : 19 Shelly, dont une dizaine de Pro 3EM.

Ça ne concerne pas que Shelly — n’importe quelle intégration avec des appareils riches en fonctionnalités (Zigbee, Z-Wave, compteurs) tapera dans le même mur.

## Pourquoi je ne peux pas contourner proprement

La doc du SDK est explicite :

> `publishDiscoveredDevices(devices)` — Publishes the complete list of discovered devices ( **replaces the previous one** ).

Donc je ne peux pas découper en plusieurs envois : le deuxième lot effacerait le premier et l’utilisateur verrait _moins_ d’appareils qu’avant. En attendant, j’ai mis un repli qui publie le plus gros sous-ensemble acceptable et journalise nommément ce qui a été écarté — ça évite l’échec silencieux, mais ça reste un pansement.

À noter aussi : `publishStates` et `publishTransports` documentent chacun un maximum de 100 éléments par requête. `publishDiscoveredDevices` n’annonce aucune limite, d’où la surprise.

## Deux propositions

**Option A — le minimum vital**  
Relever la limite de taille du corps sur cette route (1 Mo par exemple). Une ligne côté core, ça débloque tout de suite, mais ça reste non borné.

**Option B — cohérent avec le reste du SDK (ma préférence)**  
Aligner cette route sur le modèle `publishStates` : une limite documentée par requête, et **le SDK découpe tout seul** , de façon transparente pour l’intégrateur.

Côté core, il suffirait d’un drapeau :

```auto
POST /discovered_device { devices: [...], replace: true|false }

```

- `replace: true` → comportement actuel (remplace la liste)
- `replace: false` → fusionne par `external_id`

Côté SDK, **aucun changement d’API** : `publishDiscoveredDevices(devices)` envoie le premier lot avec `replace: true` puis les suivants avec `replace: false`. Les intégrations existantes ne changent pas d’une ligne, et celles qui ont beaucoup d’appareils fonctionnent enfin.

## On peut le faire

On a nos forks du core et du SDK — si l’option B te convient (ou l’option A si tu préfères aller au plus simple pour l’instant), dis-nous et on prépare la PR. Autant que tu gardes ta semaine intensive pour le reste 🙂

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:** [Août 1, 2026, 7:50 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/27 "2026-08-01T07:50:33Z")

</div>

Ah mince c’est critique ça !! Je demande à Claude de corriger

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [Août 1, 2026, 7:52 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/28 "2026-08-01T07:52:08Z")

</div>

En effet, j’arrive a avoir entre 11 et 13 appareils max sur les 19 ^^ Et ca tourne, mais il y en a 5 qui ne se montre jamais (visiblement les plus lents à répondre - RSSI très bas, ca coincide ^^)

---

<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:** [Août 1, 2026, 8:13 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/29 "2026-08-01T08:13:22Z")

</div>

> <https://github.com/GladysAssistant/Gladys/pull/2732>
>
> \### Description
> 
> This PR increases the JSON body size limit for the external int…egration host API (\`/api/integration/v1/\*\`) from 100 kB to 5 MB, while keeping the 100 kB limit for frontend routes.
> 
> The integration host API endpoints are batch-oriented by design. For example, \`POST /discovered\_device\` publishes the \*\*complete\*\* list of discovered devices in a single request (a second call replaces the first), and \`POST /camera/image\` carries base64-encoded images up to 150 kB. Devices with many features (e.g., Shelly Pro 3EM with 24 features) quickly exceed the frontend's 100 kB bound—discovery would fail silently around 13 devices, leaving users with no devices at all.
> 
> \*\*Changes:\*\*
> \- New middleware \`jsonBodyMiddleware.js\` that routes requests to different JSON parsers based on path prefix
> \- Updated error handling to properly catch and report \`413 PAYLOAD\_TOO\_LARGE\` errors from body-parser instead of returning opaque 500s
> \- Added \`Error413\` HTTP error class
> \- Updated documentation to explain the 5 MB limit and its rationale
> \- Added comprehensive tests covering both the middleware behavior and error handling
> 
> \*\*Benefits:\*\*
> \- Integrations can now publish large device batches without hitting payload limits
> \- Clear \`413\` error responses help integrations diagnose payload issues instead of failing silently
> \- Frontend routes remain protected with the original 100 kB limit
> 
> \### Checklist
> 
> \- \[x\] Tests pass: Added unit tests for \`jsonBodyMiddleware\` and error handling for oversized payloads; integration test validates publishing 40 devices with 24 features each
> \- \[x\] Linter and prettier pass
> \- \[x\] No breaking changes (frontend routes unaffected, integration API now more permissive)
> 
> https://claude.ai/code/session\_01Mvmsho1Pu6yH3kxr1UcJSE
> 
> 
> 
> \## Summary by CodeRabbit
> 
> \* \*\*New Features\*\*
> \* External integration endpoints now support JSON requests up to 5 MB, enabling larger device batches.
> \* Requests exceeding the limit return a clear \`413 PAYLOAD\_TOO\_LARGE\` response.
> 
> \* \*\*Documentation\*\*
> \* Updated integration API documentation to describe the 5 MB request limit and oversized-request behavior.
> 
> \* \*\*Bug Fixes\*\*
> \* Oversized JSON requests are now handled consistently instead of returning an opaque server error.

---

<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:** [Août 1, 2026, 8:35 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/30 "2026-08-01T08:35:19Z")

</div>

Le correctif est live sur master

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [Août 1, 2026, 8:48 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/31 "2026-08-01T08:48:00Z")

</div>

J’avais oublié, en lien avec les PR core [Semaine ultra intensive sur Gladys - #21 par Terdious](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/21), il y aura celles du SDK :

> <https://github.com/GladysAssistant/integration-sdk-js/pull/6>
>
> Mirror of the \`battery-storage\` category added to Gladys core (GladysAssistant/G…ladys#2682): the \`battery-storage\` category with \`battery-level\`, \`charge-power\`, \`discharge-power\`, \`charge-index\`, \`discharge-index\` and \`battery-energy-remaining\` types, in lib/device-constants.js and index.d.ts, with test coverage.
> 
> Needed by external integrations reporting battery storage telemetry, starting with the Zendure integration (Terdious/gladys-zendure).
> 
> 
> Claude-Session: https://claude.ai/code/session\_012157sX3FKhVYmndWLJdhfo
> 
> 
> \## Summary by CodeRabbit
> 
> \* \*\*New Features\*\*
> \* Added a new \`battery-storage\` device feature category.
> \* Introduced new battery-storage feature types for battery state of charge, charge/discharge power, cumulative charged/discharged energy indices, and remaining stored battery energy.
> \* \*\*Tests\*\*
> \* Updated canonical constant string assertions to include the new \`battery-storage\` category and related feature-type identifiers.

> <https://github.com/GladysAssistant/integration-sdk-js/pull/8>
>
> Mirrors GladysAssistant/Gladys#2693 in the SDK constants so external integration…s can expose the full energy-flow telemetry:
> 
> \- \`DEVICE\_FEATURE\_TYPES.ENERGY\_PRODUCTION\_SENSOR.POWER\` (\`'power'\`) — instantaneous production power in watt (live solar/production power);
> \- new \`grid-sensor\` category — \`input-power\`, \`output-power\`, signed \`power\`, \`input-index\`, \`output-index\` (the device's own grid exchange);
> \- new \`home-output-sensor\` category — \`power\`, \`index\`, \`off-grid-power\`, \`off-grid-index\` (power delivered to the home / backup output).
> 
> Added in \`lib/device-constants.js\` and \`index.d.ts\`, with test coverage.
> 
> Claude-Session: https://claude.ai/code/session\_012157sX3FKhVYmndWLJdhfo
> 
> 
> 
> \## Summary by CodeRabbit
> 
> \* \*\*New Features\*\*
> \* Added support for grid sensor features, including imported/exported power and energy indexes.
> \* Added home output sensor features, including delivered power, energy indexes, and off-grid measurements.
> \* Expanded energy production sensor feature mappings.
> 
> \* \*\*Tests\*\*
> \* Added coverage validating the new energy-related categories and feature types.

> <https://github.com/GladysAssistant/integration-sdk-js/pull/10>
>
> Mirror of the Gladys core addition (air-conditioning FAN\_SPEED, SWING\_HORIZONTAL… and SWING\_VERTICAL feature types) in the device constants and the TypeScript typings, so integrations can declare the full control surface of an AC unit. Companion of the core PR extracted from the Tuya air-conditioner work (#2591).
> 
> 
> 
> \## Summary by CodeRabbit
> 
> \* \*\*New Features\*\*
> \* Added support for air-conditioning fan speed control.
> \* Added support for horizontal and vertical swing controls.
> \* Updated type definitions to expose the new feature options.

---

<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:** [Août 1, 2026, 10:41 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/32 "2026-08-01T10:41:05Z")

</div>

@Terdious pour les PRs sur le SDK JS, je sais pas si c’est nécessaire, en vrai je pense que je vais juste dire au SDK «&nbsp;sync toi avec Gladys&nbsp;» à chaque modification, non ?

---

<div class="post-metadata">

**Author:** ![Terdious](https://gladys-assistant-community.b-cdn.net/user_avatar/community.gladysassistant.com/terdious/32/6316_2.png) [@Terdious](https://community.gladysassistant.com/u/Terdious)\
**Post date:** [Août 1, 2026, 10:43 UTC](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374/33 "2026-08-01T10:43:41Z")

</div>

Ce serait parfait ^^  
Je ferme !!

[Page précédente](https://community.gladysassistant.com/t/semaine-ultra-intensive-sur-gladys/10374.md?page=1)
