Service Netatmo

Hello everyone! :waving_hand:

The Netatmo project is back on track! Before resuming the development of the camera integration (the old PR #2032, automatically closed for inactivity — a new dedicated topic is coming very soon), we decided to start by cleaning up the current service: a complete audit of the service history, followed by a series of targeted fixes.

Result: 4 PRs, all tested and validated in real conditions on my installation (thermostat, about ten valves, relays, weather station and its modules — including several devices intentionally powered off, which actually revealed a nice bug :grinning_face_with_smiling_eyes:).

The 4 PRs (in the recommended merge order)

1. #2620 — Discovery of powered-off devices :red_circle: to be merged first
A single module powered off in your home (e.g., the relay of a heat pump turned off outside the heating season) was enough to completely freeze the discovery page (page reload required), with a device named « undefined ». These modules are now properly rebuilt from the API (name, room), displayed with an explicit message « Unreachable device… (code: 6) », marked offline, and remain recordable — their values will be reported as soon as they are powered back on.

2. #2617 — Zero values are no longer lost
0 mm of rain, 0 °C, wind from the north sector (0°), gusts at 0 km/h… were treated as « missing » values (replaced by potentially different fallback data, or emitted as empty states). This is fixed: zero is a real value, and no ghost states are recorded when the data is actually absent.

3. #2618 — Connection robustness

  • a thermostat setpoint that fails no longer crashes the service silently: the failure is now properly propagated and traced (server logs + service status visible on the integration pages). Note: the Gladys dashboard does not yet display command failures — this is a general limitation of Gladys’ core (asynchronous architecture of actions), this PR lays the groundwork for future visual feedback to be possible;
  • the access token is refreshed at 80% of its lifetime (before: right at expiration, with a window of dead token);
  • device values are retrieved immediately after OAuth connection (before: up to 2 minutes wait);
  • end of features named « Minimum in undefined » for modules without a room.

4. #2619 — Internal refactor (based on #2617)
The 8 duplicated update files are replaced by a single declarative table: -370 lines of code, zero behavior change (the entire test suite passes without modifying a single expected value). This is mainly the foundation that will make adding future device types — the cameras! — much simpler.

Quality

100% test coverage on all affected code, checklists completed, CodeRabbit remarks addressed (3 fixed, the rest dismissed with justification).

@pierre-gilles everything is ready for review :slightly_smiling_face: Recommended merge order: #2620#2617#2618#2619 (PR #2620 is included in the other three branches as it is essential for testing; once merged, their diffs will be reduced accordingly. PR #2619 is stacked on PR #2617).

To be continued in the next episode: the resumption of Netatmo cameras, with a dedicated topic :video_camera: