@camera.ui/sdk 0.0.22 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,13 @@
1
1
  import { Sensor, SensorCategory, SensorType } from './base.js';
2
+ import { defineSensor } from './meta.js';
2
3
  /** Optional capabilities for PTZ controls. Add to `capabilities` to enable features. */
3
4
  export var PTZCapability;
4
5
  (function (PTZCapability) {
6
+ /** Camera supports panning (horizontal movement) */
5
7
  PTZCapability["Pan"] = "pan";
8
+ /** Camera supports tilting (vertical movement) */
6
9
  PTZCapability["Tilt"] = "tilt";
10
+ /** Camera supports zoom */
7
11
  PTZCapability["Zoom"] = "zoom";
8
12
  /** Camera supports named position presets */
9
13
  PTZCapability["Presets"] = "presets";
@@ -35,6 +39,8 @@ export var PTZProperty;
35
39
  PTZProperty["TargetPreset"] = "targetPreset";
36
40
  /** Relative displacement move command (write-only) */
37
41
  PTZProperty["RelativeMove"] = "relativeMove";
42
+ /** Move to the home position (write-only command, carries no state) */
43
+ PTZProperty["Home"] = "home";
38
44
  })(PTZProperty || (PTZProperty = {}));
39
45
  /**
40
46
  * Pan-tilt-zoom camera control. Override `setPosition()` / `setVelocity()` /
@@ -175,7 +181,7 @@ export class PTZControl extends Sensor {
175
181
  * Cross-process consumer entry point. Dispatches writable properties
176
182
  * to semantic methods so plugin overrides (hardware actions) are honored.
177
183
  * `moving` and `presets` are observed/discovered state and not externally writable;
178
- * only `Position`, `Velocity`, `TargetPreset`, and `RelativeMove` may be set.
184
+ * only `Position`, `Velocity`, `TargetPreset`, `RelativeMove` and `Home` may be set.
179
185
  *
180
186
  * @param property - Property name to write.
181
187
  *
@@ -197,7 +203,20 @@ export class PTZControl extends Sensor {
197
203
  case PTZProperty.RelativeMove:
198
204
  await this.setRelativeMove(value);
199
205
  return;
206
+ case PTZProperty.Home:
207
+ await this.goHome();
208
+ return;
200
209
  }
201
210
  // Unknown / non-writable property (incl. moving, presets) — ignored.
202
211
  }
203
212
  }
213
+ /** Registry metadata for {@link PTZControl}. */
214
+ export const ptzMeta = defineSensor({
215
+ type: SensorType.PTZ,
216
+ category: SensorCategory.Control,
217
+ assignmentKey: 'ptz',
218
+ multiProvider: false,
219
+ isDetectionType: false,
220
+ properties: Object.values(PTZProperty),
221
+ semantics: null,
222
+ });
@@ -0,0 +1,64 @@
1
+ import { audioMeta } from './audio.js';
2
+ import { batteryMeta } from './battery.js';
3
+ import { classifierMeta } from './classifier.js';
4
+ import { clipMeta } from './clip.js';
5
+ import { contactMeta } from './contact.js';
6
+ import { doorbellMeta } from './doorbell.js';
7
+ import { faceMeta } from './face.js';
8
+ import { garageMeta } from './garage.js';
9
+ import { humidityMeta } from './humidity.js';
10
+ import { leakMeta } from './leak.js';
11
+ import { licensePlateMeta } from './licensePlate.js';
12
+ import { lightMeta } from './light.js';
13
+ import { lockMeta } from './lock.js';
14
+ import { motionMeta } from './motion.js';
15
+ import { objectMeta } from './object.js';
16
+ import { occupancyMeta } from './occupancy.js';
17
+ import { ptzMeta } from './ptz.js';
18
+ import { securitySystemMeta } from './securitySystem.js';
19
+ import { sirenMeta } from './siren.js';
20
+ import { smokeMeta } from './smoke.js';
21
+ import { switchMeta } from './switch.js';
22
+ import { temperatureMeta } from './temperature.js';
23
+ /** Every sensor's metadata. A new sensor type adds its meta here. */
24
+ export const SENSOR_META = [
25
+ audioMeta,
26
+ batteryMeta,
27
+ classifierMeta,
28
+ clipMeta,
29
+ contactMeta,
30
+ doorbellMeta,
31
+ faceMeta,
32
+ garageMeta,
33
+ humidityMeta,
34
+ leakMeta,
35
+ licensePlateMeta,
36
+ lightMeta,
37
+ lockMeta,
38
+ motionMeta,
39
+ objectMeta,
40
+ occupancyMeta,
41
+ ptzMeta,
42
+ securitySystemMeta,
43
+ sirenMeta,
44
+ smokeMeta,
45
+ switchMeta,
46
+ temperatureMeta,
47
+ ];
48
+ const _everySensorHasMeta = true;
49
+ void _everySensorHasMeta;
50
+ /**
51
+ * Looks up a sensor's metadata by its type.
52
+ *
53
+ * @param type - The sensor type value.
54
+ *
55
+ * @returns The metadata, or `undefined` if no sensor declares that type.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const meta = sensorMeta(SensorType.Light);
60
+ * ```
61
+ */
62
+ export function sensorMeta(type) {
63
+ return SENSOR_META.find((meta) => meta.type === type);
64
+ }
@@ -1,4 +1,5 @@
1
1
  import { Sensor, SensorType, SensorCategory } from './base.js';
2
+ import { defineSensor, SensorDomain } from './meta.js';
2
3
  /** Security system arm/disarm states (HomeKit-compatible values) */
3
4
  export var SecuritySystemState;
4
5
  (function (SecuritySystemState) {
@@ -101,3 +102,27 @@ export class SecuritySystem extends Sensor {
101
102
  // Unknown / non-writable property (incl. currentState) — ignored.
102
103
  }
103
104
  }
105
+ /** Registry metadata for {@link SecuritySystem}. */
106
+ export const securitySystemMeta = defineSensor({
107
+ type: SensorType.SecuritySystem,
108
+ category: SensorCategory.Control,
109
+ assignmentKey: 'securitySystem',
110
+ multiProvider: true,
111
+ isDetectionType: false,
112
+ properties: Object.values(SecuritySystemProperty),
113
+ shortcutable: true,
114
+ cascadeTrigger: { property: SecuritySystemProperty.CurrentState, value: 4, sustained: true },
115
+ virtual: { properties: { [SecuritySystemProperty.CurrentState]: 3, [SecuritySystemProperty.TargetState]: 3 } },
116
+ semantics: {
117
+ domain: SensorDomain.Alarm,
118
+ stateProperty: SecuritySystemProperty.CurrentState,
119
+ commandProperty: SecuritySystemProperty.TargetState,
120
+ states: {
121
+ armed_home: SecuritySystemState.StayArm,
122
+ armed_away: SecuritySystemState.AwayArm,
123
+ armed_night: SecuritySystemState.NightArm,
124
+ disarmed: SecuritySystemState.Disarmed,
125
+ triggered: SecuritySystemState.AlarmTriggered,
126
+ },
127
+ },
128
+ });
@@ -1,8 +1,9 @@
1
1
  import { Sensor, SensorType, SensorCategory } from './base.js';
2
+ import { defineSensor, SensorDomain } from './meta.js';
2
3
  /** Optional capabilities for siren controls */
3
4
  export var SirenCapability;
4
5
  (function (SirenCapability) {
5
- /** Siren supports volume adjustment (0100) */
6
+ /** Siren supports volume adjustment (0-100) */
6
7
  SirenCapability["Volume"] = "volume";
7
8
  })(SirenCapability || (SirenCapability = {}));
8
9
  /**
@@ -14,7 +15,7 @@ export var SirenProperty;
14
15
  (function (SirenProperty) {
15
16
  /** Whether the siren is currently active */
16
17
  SirenProperty["Active"] = "active";
17
- /** Volume level (0100) */
18
+ /** Volume level (0-100) */
18
19
  SirenProperty["Volume"] = "volume";
19
20
  })(SirenProperty || (SirenProperty = {}));
20
21
  /**
@@ -67,7 +68,7 @@ export class SirenControl extends Sensor {
67
68
  * Set volume. Override to drive hardware and call `await super.setVolume(value)`
68
69
  * after success. The default implementation clamps the value to [0, 100].
69
70
  *
70
- * @param value - Volume level in the range 0100.
71
+ * @param value - Volume level in the range 0-100.
71
72
  *
72
73
  * @example
73
74
  * ```ts
@@ -103,3 +104,21 @@ export class SirenControl extends Sensor {
103
104
  // Unknown / non-writable property — ignored.
104
105
  }
105
106
  }
107
+ /** Registry metadata for {@link SirenControl}. */
108
+ export const sirenMeta = defineSensor({
109
+ type: SensorType.Siren,
110
+ category: SensorCategory.Control,
111
+ assignmentKey: 'siren',
112
+ multiProvider: true,
113
+ isDetectionType: false,
114
+ properties: Object.values(SirenProperty),
115
+ shortcutable: true,
116
+ cascadeTrigger: { property: SirenProperty.Active, value: true, sustained: true },
117
+ propertyCapabilities: { [SirenProperty.Volume]: SirenCapability.Volume },
118
+ virtual: { properties: { [SirenProperty.Active]: false, [SirenProperty.Volume]: 100 }, capabilities: [SirenCapability.Volume] },
119
+ semantics: {
120
+ domain: SensorDomain.Siren,
121
+ stateProperty: SirenProperty.Active,
122
+ commandProperty: SirenProperty.Active,
123
+ },
124
+ });
@@ -1,4 +1,5 @@
1
1
  import { Sensor, SensorType, SensorCategory } from './base.js';
2
+ import { defineSensor, SensorDomain } from './meta.js';
2
3
  /**
3
4
  * Properties for smoke sensors
4
5
  *
@@ -50,3 +51,21 @@ export class SmokeSensor extends Sensor {
50
51
  // No-op — smoke state is reported by the plugin, not set externally.
51
52
  }
52
53
  }
54
+ /** Registry metadata for {@link SmokeSensor}. */
55
+ export const smokeMeta = defineSensor({
56
+ type: SensorType.Smoke,
57
+ category: SensorCategory.Sensor,
58
+ assignmentKey: 'smoke',
59
+ multiProvider: true,
60
+ isDetectionType: false,
61
+ properties: Object.values(SmokeProperty),
62
+ shortcutable: true,
63
+ cascadeTrigger: { property: SmokeProperty.Detected, value: true, sustained: true },
64
+ virtual: { properties: { [SmokeProperty.Detected]: false } },
65
+ semantics: {
66
+ domain: SensorDomain.Binary,
67
+ stateProperty: SmokeProperty.Detected,
68
+ commandProperty: SmokeProperty.Detected,
69
+ deviceClass: 'smoke',
70
+ },
71
+ });
@@ -1,4 +1,5 @@
1
1
  import { Sensor, SensorType, SensorCategory } from './base.js';
2
+ import { defineSensor, SensorDomain } from './meta.js';
2
3
  /**
3
4
  * Properties for switch controls
4
5
  *
@@ -70,3 +71,20 @@ export class SwitchControl extends Sensor {
70
71
  // Unknown / non-writable property — ignored.
71
72
  }
72
73
  }
74
+ /** Registry metadata for {@link SwitchControl}. */
75
+ export const switchMeta = defineSensor({
76
+ type: SensorType.Switch,
77
+ category: SensorCategory.Control,
78
+ assignmentKey: 'switch',
79
+ multiProvider: true,
80
+ isDetectionType: false,
81
+ properties: Object.values(SwitchProperty),
82
+ shortcutable: true,
83
+ cascadeTrigger: { property: SwitchProperty.On, value: true, sustained: true },
84
+ virtual: { properties: { [SwitchProperty.On]: false } },
85
+ semantics: {
86
+ domain: SensorDomain.Switch,
87
+ stateProperty: SwitchProperty.On,
88
+ commandProperty: SwitchProperty.On,
89
+ },
90
+ });
@@ -1,4 +1,5 @@
1
1
  import { Sensor, SensorType, SensorCategory } from './base.js';
2
+ import { defineSensor, SensorDomain } from './meta.js';
2
3
  /**
3
4
  * Properties for temperature sensors
4
5
  *
@@ -50,3 +51,21 @@ export class TemperatureInfo extends Sensor {
50
51
  // No-op — temperature is reported by the plugin, not set externally.
51
52
  }
52
53
  }
54
+ /** Registry metadata for {@link TemperatureInfo}. */
55
+ export const temperatureMeta = defineSensor({
56
+ type: SensorType.Temperature,
57
+ category: SensorCategory.Info,
58
+ assignmentKey: 'temperature',
59
+ multiProvider: true,
60
+ isDetectionType: false,
61
+ properties: Object.values(TemperatureProperty),
62
+ shortcutable: true,
63
+ virtual: { properties: { [TemperatureProperty.Current]: 20 } },
64
+ semantics: {
65
+ domain: SensorDomain.Measurement,
66
+ stateProperty: TemperatureProperty.Current,
67
+ commandProperty: TemperatureProperty.Current,
68
+ deviceClass: 'temperature',
69
+ unit: '°C',
70
+ },
71
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camera.ui/sdk",
3
- "version": "0.0.22",
3
+ "version": "0.0.25",
4
4
  "description": "camera.ui sdk",
5
5
  "exports": {
6
6
  ".": {