Hola,
Esta solicitud está relacionada con esta issue cerrada para discutirla aquí, pero no he visto ningún post:
ouvert 11:20PM - 17 Oct 26 UTC
fermé 08:42AM - 23 Oct 26 UTC
claude:blocked
## Problem
An external integration cannot publish the position of a Gladys user… today (checked on core `0027571e` and `@gladysassistant/integration-sdk` 0.15.0):
- the SDK has no method for it: `getHouses()` reads the houses only (behind `location: true`), nothing about users or their location;
- the host API (`/api/integration/v1/*` in `server/api/routes.js`) has no user or location route;
- `post /api/v1/user/:user_selector/location` exists, but it takes a user session (`authenticated: true`), not the token of an integration;
- OwnTracks reaches `location.create` only through the Gladys Plus gateway (`location.handleNewGatewayOwntracksLocation.js`).
So location trackers integrated as external integrations can only publish latitude/longitude as plain device features: the user map, the areas (`user.new-location`) and the scenes based on them do not react.
The first case is [gladys-phonetrack](https://github.com/LM1LC3N7/gladys-phonetrack) (PhoneTrack, the Nextcloud app: self-hosted phone tracking), but the same need applies to any tracker (Traccar, Invoxia, car integrations with a GPS position…).
## Proposal
A minimal host route, with an explicit manifest declaration and a per-user consent:
1. `server/api/routes.js`: `'post /api/integration/v1/user/:user_selector/location'`, with `authenticated: false, externalIntegrationAuth: true`, controller `integrationHostController.publishUserLocation`.
2. `server/api/controllers/integrationHost.controller.js`: body `{ latitude, longitude, accuracy?, altitude?, created_at? }` (validated: numbers and ranges), calling a new `server/lib/external-integration/externalIntegration.publishUserLocation.js` that:
- checks a manifest declaration `user_location: true` (shown on the install screen, 403 otherwise, like `location` for the houses);
- checks that this user chose this integration as a source of their position (consent per user, for example a `users` dynamic source in `DYNAMIC_SOURCES` of `server/lib/external-integration/constants.js`, so a device can be linked to its user in the integration's configuration);
- then calls `gladys.location.create(userSelector, location)`, which already updates the user, emits `user.new-location` for the areas and the websocket event of the map.
3. `validateManifest.js`, and `docs/specs/external-integrations/contracts/host-api-endpoints.md` and `manifest.md`: the new field and route; tests next to the house ones.
4. SDK: `gladys.publishUserLocation(userSelector, { latitude, longitude, accuracy, altitude })`, and the `users` source in the fake Gladys used by integration tests.
Nothing changes for existing integrations: without `user_location: true` in the manifest, the route answers 403.
Happy to open the PR if the approach suits you.
¿Sería posible actualizar la posición de un usuario a través del protocolo de integraciones externas? Esto equivaldría a generalizar parte de la integración con owntracker, imagino. (Estoy redescubriendo Gladys después de una pausa de casi 10 años si me creo mi inscripción en el foro)
Otro añadido interesante sería poder actualizar la posición de un dispositivo desde el protocolo. Esto serviría, por ejemplo, para los coches (ej: Intégration domotique MySkoda, gratuite et open source | Gladys Assistant que almacena la posición como texto por el momento).