Feature description
Following this thread: Récuperer date/heure dans mqtt - #3 par prohand
I think it would be nice to be able to retrieve the time locally in a scene and not via an external web service
@pierre-gilles Iâm bringing this request back up, which could be included in next weekâs updates.
I describe a use case:
To monitor the startup of my heat pump (itâs new, I want to keep an eye on its operation regularly), I want to be notified every hour of the last startup. A message like « The last startup of the heat pump was 26 minutes ago »
I would therefore like to do the following:
Create a virtual MQTT device âč last heat pump startup âș
In scene A, with the trigger being the heat pump starting, store the current date/time in this MQTT device
In scene B, which triggers every hour, retrieve the current date/time and the âč last heat pump startup âș date, calculate the difference and send me a message
For this, Gladys would need to:
Be able to create a virtual device of type âč date and time âș
Have a scene action to retrieve the current date and time as a variable, usable in the rest of the scene (perhaps by indicating the expected âč precision âș: second, minute, hour, day,⊠Because for example in my case the minute would suffice, and if Gladys gives me info to the millisecond, my message will be unnecessarily precise)
Define how a âč date and time âș device is taken into account in a scene calculation. I think itâs the âč timestamp âș in seconds that could be usedâŠ
Have a clean display if I display a âč date and time âș device on the dashboard, with the possibility to choose the display format
Hi everyone!
This topic is now under development .
A PR has been opened to add a scene action « Get date and time » (date, time, datetime and timestamp, with adjustable precision):
master â claude/scene-current-datetime
ouvert 02:21AM - 18 Aug 26 UTC
Implements feature request: https://community.gladysassistant.com/t/recuperer-la⊠-date-et-lheure-dans-une-scene/8821
### Description
This PR adds a new scene action, **"Get the current date and time"** (`time.get-date`), which makes the current local date/time available to the rest of the scene, without having to call an external web service.
The action stores 4 variables in the scene scope, reusable in any following action (message text, MQTT payload, formula, conditionâŠ):
| Variable | Example (precision "minute") | Usage |
|---|---|---|
| `datetime` | `2026-08-18 15:32` | Full date and time, truncated to the chosen precision |
| `date` | `2026-08-18` | Date only |
| `time` | `15:32` | Time only |
| `timestamp` | `1787153520` | Unix timestamp in seconds, usable in a calculation |
Details:
- **Precision**: the user picks the granularity in the scene editor (second, minute, hour, day â default: minute), so a message doesn't end up more precise than needed (the forum request explicitly asks for this: "si Gladys me donne une info Ă la milliseconde, mon message va ĂȘtre inutilement prĂ©cis"). The date/time is truncated (`startOf`) to that precision, and `timestamp` follows the same truncation. An unknown precision aborts the scene instead of storing an unusable date.
- **Timezone**: the date is computed with `dayjs.tz(..., self.timezone)`, i.e. the timezone configured in Gladys, exactly like the existing `condition.check-time` and `calendar.get-events` actions. It is the local time of the user, not the time of the server.
- **Calculation**: `timestamp` being a number in seconds, it covers the use case described in the topic â storing "now" in a device/variable in scene A, then in scene B computing `({{0.0.timestamp}} - {{1.0.last_value}}) / 60` to say "the heat pump last started 26 minutes ago".
- The action is also declared in the MCP scene schema (`server/services/mcp/lib/sceneSchemas.js`), so scenes created through the MCP server can use it too.
**Scope**: the forum topic also floats two broader ideas â a virtual "date and time" **device type** and its rendering on the dashboard. Those are much bigger changes (data model + dashboard boxes), so this PR deliberately implements only the core, coherent piece that was asked for: a scene action exposing the current date/time as scene variables.
This PR was created by an automated Claude Code run.
**Files changed**
- `server/utils/constants.js`: new `ACTIONS.TIME.GET_DATE`
- `server/lib/scene/scene.actions.js`: the action implementation
- `server/services/mcp/lib/sceneSchemas.js`: MCP schema for the new action
- `front/src/routes/scene/edit-scene/actions/GetDate.jsx`: new action card (precision selector + variables declaration)
- `front/src/routes/scene/edit-scene/ActionCard.jsx`, `actions/ChooseActionTypeCard.jsx`: registration of the action
- `front/src/config/i18n/{en,fr,de}.json`: translations
- `server/test/lib/scene/actions/scene.action.getDate.test.js`, `server/test/services/mcp/lib/sceneSchemas.test.js`: tests
## Forum
Forum: https://community.gladysassistant.com/t/recuperer-la-date-et-lheure-dans-une-scene/8821
### Checklist
- [x] Tests pass: `cd server && npm run coverage` (Codecov requires 100% coverage on changed lines) and Cypress (`npm run cypress:run`) if the UI changed
- [x] Linter and prettier pass on both front and server (`npm run eslint`, `npm run prettier`)
- [x] No undocumented breaking change
Notes on the checklist: the server test suite was run locally (`npm test`, all scene and MCP tests green â the only failures in this sandbox are pre-existing environment ones: missing `sqlite3` CLI binary, no Docker socket, no network access to Gladys Plus). The front was validated with `prettier-check`, `eslint`, `compare-translations` and `npm run build`. Cypress was **not** run (the Cypress binary is not installed in this environment), but no existing UI route or component behavior was modified â only a new action card was added.
---
đ€ Generated with [Claude Code](https://claude.com/claude-code)
---
_Generated by [Claude Code](https://claude.ai/code/session_01YXRz5JiaM9N42djviseBRu)_
Feel free to follow the PR, test (optional, especially for small requests) and give your feedback here if needed.
I tested on my side, everything is ok
mutmut
August 20, 2026, 2:21pm
5
Cool if we no longer have to make an HTTP GET request to retrieve the date and time
But does this take into account the host Gladysâs time?
Because I think I have a difference when I look at the logs and the corresponding times, 1 or 2 hours
It seems to take the host Gladysâs time
The times in the logs of external integrations are in UTC
I checked that the Gladys Docker logs are indeed in the correct timezone
I will create a feature request for the timezone of external integrations