I also propose this small widget to visually display the position of the sun at home.
Created from the suncalc library already present in Gladys, which performs calculations based on the home coordinates configured
the PR
master â William-De71:feature/sun-horizon-widget
ouvert 01:32PM - 05 Jul 26 UTC
### Pull Request check-list
To ensure your Pull Request can be accepted as fa⊠st 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**
- [x] Did Cypress E2E tests pass? (`npm run cypress:run` from repo root, if UI changed)
- [x] Is the linter passing? (`npm run eslint` on both front/server)
- [x] Did you run prettier? (`npm run prettier` on both front/server)
- [x] If you are adding a new feature/service, did you run the integration comparator? (`npm run compare-translations` on front)
- [x] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community ([forum](https://community.gladysassistant.com/)) for testing before merging.
- [ ] If your changes modify the API (REST or Node.js), did you modify the API documentation? (Documentation is based on comments in code)
- [ ] If you are adding a new features/services which needs explanation, did you modify the user documentation? See [the GitHub repo](https://github.com/GladysAssistant/v4-website) and the [website](https://gladysassistant.com).
- [ ] 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? (if needed) See [https://demo.gladysassistant.com](https://demo.gladysassistant.com).
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
### Description of change
# Add sun horizon widget to the dashboard
New standalone dashboard widget showing the sun's journey for a house, an SVG elevation curve with the sun's current position, dawn, solar noon, dusk, azimuth and elevation.
Everything is computed locally with `suncalc` (already a server dependency) from the house coordinates â no weather service or external API needed.
- New route `GET /api/v1/house/:house_selector/sun` (400 if the house has no coordinates)
- New `sun` dashboard box with house selection, refreshed every minute, identical rendering in light and dark mode
<img width="373" height="293" alt="image" src="https://github.com/user-attachments/assets/34deb782-7fd5-48dd-a472-0c8870ab7e17" />
<img width="373" height="293" alt="image" src="https://github.com/user-attachments/assets/cf1daa68-0e9b-4f6e-8499-0225fe7ebbb1" />
## Summary by CodeRabbit
* **New Features**
* Added a new Sun dashboard widget showing sunrise, sunset, dawn, solar noon, dusk, and current solar position.
* Users can now choose which house the widget is based on, and the display updates automatically.
* **Bug Fixes**
* Added support for the Sun widget in dashboard display and edit views.
* Improved handling for missing house coordinates and unavailable solar data.
* **Documentation**
* Added localized labels and messages for English, French, and German.
Great, canât wait for it to be officially integrated (along with MĂ©tĂ©o-France)!
I agree!
@Will_71 will there be an implementation in the triggers or a check of the sunâs position in real time?
Hello,
je dĂ©terre un peu ce sujet car jâaurais besoin de rĂ©cupĂ©rer (sans API externe de prĂ©fĂ©rence) lâaltitude et lâazimuth du soleil afin de gĂ©rer au mieux (ouverture/fermeture partielles) mes volets roulants dans les scĂšnes.
Est-ce que ce serait possible de les rajouter dans le core de Gladys sachant quâon utilise la fonction suncalc (de ce que jâai lu sur le forum) ?
[image]
Merci dâavance
EDIT : je reprends quelques infos issues de la doc de Lunarok pour son module hĂ©liâŠ
No, itâs just a widget, I donât touch the scene.
However, there is an open PR for this. In fact, it was when I saw the open PR that it gave me the idea to make this widget.
master â cursor/sun-position-scene-trigger-7a98
ouvert 04:56PM - 03 Jul 26 UTC
### Description
Implémente la [demande de la communauté](https://community.glad⊠ysassistant.com/t/ajouter-un-declencheur-de-scenes-selon-l-altitude-et-l-azimut-du-soleil/7881) : permettre de déclencher une scÚne quand le soleil atteint une altitude et un azimut précis (ex. altitude 31°, azimuth 160°).
Cas d'usage typique : ouvrir/fermer des volets en fonction de l'orientation des fenĂȘtres par rapport au soleil, pour optimiser le confort thermique Ă©tĂ©/hiver.
### Changements
**Serveur**
- Nouveau type de déclencheur `time.sun-position` dans les constantes
- Module `server/lib/sun/sunPosition.js` utilisant `suncalc` (déjà présent dans le core) pour :
- convertir altitude/azimut en degrés (azimut 0-360° depuis le nord, sens horaire)
- rechercher les moments de la journĂ©e oĂč le soleil atteint la position cible
- Planification quotidienne dans `scene.dailyUpdate.js` (mĂȘme mĂ©canisme que lever/coucher du soleil)
- Matching des déclencheurs dans `scene.triggers.js`
- Schéma MCP mis à jour
**Front**
- Nouveau composant `SunPositionTrigger.jsx` : sélection de la maison + champs altitude (-90° à 90°) et azimut (0° à 360°)
- Traductions en/fr/de
**Tests**
- Tests unitaires du module `sunPosition`
- Tests d'intégration pour le scheduling et le déclenchement de scÚne
### Check-list
- [x] Tests écrits et passants (`npm test -- --grep "sunPosition"`)
- [x] Traductions synchronisées (`npm run compare-translations`)
- [ ] Testé en conditions réelles avec une maison ayant des coordonnées GPS
### Notes techniques
- L'azimut est mesuré dans le sens horaire depuis le nord (0° = nord, 90° = est, 180° = sud, 270° = ouest), comme documenté dans le fil de la communauté.
- La tolérance de matching est de ±0,5° en altitude et ±1° en azimut, avec une recherche minute par minute.
- Si la combinaison altitude/azimut n'est pas atteinte un jour donné (selon la saison et la latitude), aucun job n'est planifié ce jour-là .
<div><a href="https://cursor.com/agents/bc-019f28e4-93a7-730c-b840-2617809e7a98"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-019f28e4-93a7-730c-b840-2617809e7a98"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div>
From what I can see, @pierre-gilles is on it
Awesome! For my part, I use Node-red to get the elevation and azimuth, which is a much more visually appealing integration!