Skip to content

Commit 98d7c86

Browse files
docs(device): document the per-feature setpoint step
Gladys now stores a nullable `step` on a device feature, so a setpoint carries the resolution its physical device actually accepts instead of inheriting a per-category default (air conditioning was pinned to whole degrees, which units steppable by half a degree could not express). Nothing to add to the SDK code — features are published verbatim — but integrations have no way to discover the field without the typings and the README: - index.d.ts: `step?: number` on DeviceFeature, with its semantics - README: a "Setpoint step" section (example, positive-number rule, fallback when omitted, gladys_version caveat) - typings test: a setpoint feature literal carrying `step` Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 800bd7d commit 98d7c86

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,34 @@ changed.forEach(({ id, value }) => lastValues.set(id, value));
604604
await gladys.publishStates(changed.map(({ id, value }) => ({ device_feature_external_id: id, state: value })));
605605
```
606606

607+
### Setpoint step
608+
609+
A setpoint feature (`DEVICE_FEATURE_TYPES.*.TARGET_TEMPERATURE`, `AIR_CONDITIONING.TARGET_TEMPERATURE`…) can declare
610+
the resolution its physical device actually accepts, with `step`. It drives the `+`/`-` buttons of the setpoint
611+
widget in the dashboard: a unit steppable by half a degree gets `step: 0.5`, one that only takes whole degrees
612+
`step: 1`.
613+
614+
```js
615+
{
616+
name: 'Target temperature',
617+
external_id: ids.feature('target-temperature'),
618+
category: DEVICE_FEATURE_CATEGORIES.AIR_CONDITIONING,
619+
type: DEVICE_FEATURE_TYPES.AIR_CONDITIONING.TARGET_TEMPERATURE,
620+
unit: DEVICE_FEATURE_UNITS.CELSIUS,
621+
min: 16,
622+
max: 31,
623+
step: 0.5, // the unit accepts half degrees — Mitsubishi, Daikin…
624+
read_only: false,
625+
has_feedback: true,
626+
}
627+
```
628+
629+
`step` must be a strictly positive number; publishing anything else is a `400`. It is optional: omit it and Gladys
630+
falls back to its per-category default (a whole degree for air conditioning, half a degree for a thermostat) —
631+
declare it only when you know what the device supports, rather than guessing 1. Requires a Gladys that carries the
632+
per-feature step (check the `gladys_version` range of your manifest); an older Gladys ignores the field and keeps
633+
its category default.
634+
607635
### Device constants
608636

609637
The SDK exports the canonical category / type / unit strings understood by Gladys — a verbatim mirror of

index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export interface DeviceFeature {
3838
unit?: string;
3939
min?: number;
4040
max?: number;
41+
/**
42+
* Resolution the physical device accepts for a setpoint, e.g. `0.5` for an
43+
* air conditioner steppable by half a degree. Drives the +/- buttons of the
44+
* setpoint widget; omit it to let Gladys pick its per-category default.
45+
*/
46+
step?: number;
4147
read_only?: boolean;
4248
has_feedback?: boolean;
4349
keep_history?: boolean;

test/types/api.test-d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ const main = async (): Promise<void> => {
108108
await gladys.connect();
109109

110110
const devices: Device[] = await gladys.getDevices();
111+
const setpoint: DeviceFeature = {
112+
name: 'Target temperature',
113+
external_id: gladys.externalId('ac:target-temperature'),
114+
category: DEVICE_FEATURE_CATEGORIES.AIR_CONDITIONING,
115+
type: DEVICE_FEATURE_TYPES.AIR_CONDITIONING.TARGET_TEMPERATURE,
116+
unit: DEVICE_FEATURE_UNITS.CELSIUS,
117+
min: 16,
118+
max: 31,
119+
step: 0.5,
120+
};
121+
const setpointStep: number | undefined = setpoint.step;
111122
const config: IntegrationConfig = await gladys.getConfig();
112123
const status = await gladys.getStatus();
113124
const version: string = status.gladys_version;

0 commit comments

Comments
 (0)