Skip to content

@camera.ui/sdk / sensor / GarageControl

Class: GarageControl<TStorage>

Defined in: sensor/garage.ts:65

Garage door control. Override setTargetState() to drive hardware and call await super.setTargetState(value) once the hardware confirms: the base implementation updates both targetState and currentState.

For long-running transitions (Opening/Closing intermediate states), override setTargetState and write currentState separately as the door moves.

Extends

  • Sensor<GarageControlProperties, TStorage, string>

Type Parameters

TStorage

TStorage extends object = Record<string, any>

Constructors

Constructor

new GarageControl<TStorage>(name?, options?): GarageControl<TStorage>

Defined in: sensor/garage.ts:69

Parameters

name?

string = 'Garage'

options?

SensorOptions

Returns

GarageControl<TStorage>

Overrides

Sensor.constructor

Properties

category

readonly category: Control = SensorCategory.Control

Defined in: sensor/garage.ts:67

Overrides

Sensor.category


name

readonly name: string

Defined in: sensor/base.ts:223

Inherited from

Sensor.name


onAssignmentChanged

readonly onAssignmentChanged: Observable<readonly string[]>

Defined in: sensor/base.ts:250

Inherited from

Sensor.onAssignmentChanged


onCapabilitiesChanged

readonly onCapabilitiesChanged: Observable<string[]>

Defined in: sensor/base.ts:242

Inherited from

Sensor.onCapabilitiesChanged


onConnectedChanged

readonly onConnectedChanged: Observable<boolean>

Defined in: sensor/base.ts:252

Inherited from

Sensor.onConnectedChanged


onPropertyChanged

readonly onPropertyChanged: Observable<PropertyChangeOf<GarageControlProperties>>

Defined in: sensor/base.ts:240

Inherited from

Sensor.onPropertyChanged


type

readonly type: Garage = SensorType.Garage

Defined in: sensor/garage.ts:66

Overrides

Sensor.type

Accessors

assignedCameraIds

Get Signature

get assignedCameraIds(): readonly string[]

Defined in: sensor/base.ts:293

Returns

readonly string[]

Inherited from

Sensor.assignedCameraIds


assignmentLocked

Get Signature

get assignmentLocked(): boolean

Defined in: sensor/base.ts:297

Returns

boolean

Inherited from

Sensor.assignmentLocked


capabilities

Get Signature

get capabilities(): TCapability[]

Defined in: sensor/base.ts:316

Returns

TCapability[]

Set Signature

set capabilities(value): void

Defined in: sensor/base.ts:321

Set capabilities, deduplicated, and notify backend plus local listeners.

Parameters
value

TCapability[]

Returns

void

Inherited from

Sensor.capabilities


connected

Get Signature

get connected(): boolean

Defined in: sensor/base.ts:289

Returns

boolean

Inherited from

Sensor.connected


currentState

Get Signature

get currentState(): GarageState

Defined in: sensor/garage.ts:79

Returns

GarageState


displayName

Get Signature

get displayName(): string

Defined in: sensor/base.ts:281

Returns

string

Inherited from

Sensor.displayName


id

Get Signature

get id(): string

Defined in: sensor/base.ts:269

Returns

string

Inherited from

Sensor.id


isAssigned

Get Signature

get isAssigned(): boolean

Defined in: sensor/base.ts:285

Returns

boolean

Inherited from

VibrationSensor.isAssigned


nativeId

Get Signature

get nativeId(): string | undefined

Defined in: sensor/base.ts:273

Returns

string | undefined

Inherited from

Sensor.nativeId


obstructionDetected

Get Signature

get obstructionDetected(): boolean

Defined in: sensor/garage.ts:87

Returns

boolean


origin

Get Signature

get origin(): string | undefined

Defined in: sensor/base.ts:277

Returns

string | undefined

Inherited from

VibrationSensor.origin


pluginId

Get Signature

get pluginId(): string | undefined

Defined in: sensor/base.ts:301

Returns

string | undefined

Inherited from

Sensor.pluginId


props

Get Signature

get protected props(): Readonly<TProperties>

Defined in: sensor/base.ts:546

Returns

Readonly<TProperties>

Inherited from

Sensor.props


storage

Get Signature

get storage(): DeviceStorage<TStorage>

Defined in: sensor/base.ts:305

Returns

DeviceStorage<TStorage>

Inherited from

Sensor.storage


storageSchema

Get Signature

get storageSchema(): JsonSchema[]

Defined in: sensor/base.ts:312

Returns

JsonSchema[]

Inherited from

VibrationSensor.storageSchema


targetState

Get Signature

get targetState(): GarageState

Defined in: sensor/garage.ts:83

Returns

GarageState

Methods

getValue()

Call Signature

getValue<K>(property): GarageControlProperties[K] | undefined

Defined in: sensor/base.ts:345

Get the current value of a sensor property. Calling the generic overload with a property enum value gives a properly typed result.

Type Parameters
K

K extends keyof GarageControlProperties

Parameters
property

K

Returns

GarageControlProperties[K] | undefined

Inherited from

Sensor.getValue

Call Signature

getValue(property): unknown

Defined in: sensor/base.ts:346

Get the current value of a sensor property. Calling the generic overload with a property enum value gives a properly typed result.

Parameters
property

string

Returns

unknown

Inherited from

Sensor.getValue


getValues()

getValues(): Readonly<TProperties>

Defined in: sensor/base.ts:362

Get a read-only snapshot of all property values.

Returns

Readonly<TProperties>

Shallow copy of every property currently held by the sensor.

Example

ts
const snapshot = sensor.getValues();
console.log(snapshot);

Inherited from

Sensor.getValues


hasCapability()

hasCapability(capability): boolean

Defined in: sensor/base.ts:388

Check whether the sensor advertises a capability.

Parameters

capability

string

Capability flag to look for.

Returns

boolean

True if the sensor currently advertises it.

Example

ts
const dimmable = sensor.hasCapability('brightness');

Inherited from

Sensor.hasCapability


onStart()

protected onStart(): void | Promise<void>

Defined in: sensor/base.ts:651

Lifecycle hook, called once the sensor is registered and live (storage and RPC are wired up). Override it to start work whose lifetime matches the sensor's: polling loops, event subscriptions, timers.

Errors thrown here are swallowed, not logged. Handle failures inside the override. Paired 1:1 with onStop, which runs on removal, plugin shutdown or cleanup.

Returns

void | Promise<void>

Example

ts
protected override onStart(): void {
  this._timer = setInterval(() => this.poll(), 5_000);
}

Inherited from

Sensor.onStart


onStop()

protected onStop(): void | Promise<void>

Defined in: sensor/base.ts:664

Counterpart of onStart: tear down whatever it started, such as timers, subscriptions and external resources.

Returns

void | Promise<void>

Example

ts
protected override onStop(): void {
  if (this._timer) clearInterval(this._timer);
}

Inherited from

Sensor.onStop


setCurrentState()

setCurrentState(value): void

Defined in: sensor/garage.ts:124

Publish the actual door state. Use this to drive long-running transitions (Open, then Closing, then Closed) independently of the user-requested target state. Read-only from cross-process consumers (updateValue ignores it).

Parameters

value

GarageState

Current physical door state from the GarageState enum.

Returns

void

Example

ts
import { GarageState } from '@camera.ui/sdk';
garage.setCurrentState(GarageState.Closing);

setDisplayName()

setDisplayName(value): void

Defined in: sensor/base.ts:337

Set the display name (the only mutable identifier on a sensor).

Parameters

value

string

Human-readable label shown in the UI.

Returns

void

Example

ts
sensor.setDisplayName('Front Door Motion');

Inherited from

Sensor.setDisplayName


setObstructionDetected()

setObstructionDetected(value): void

Defined in: sensor/garage.ts:140

Publish the obstruction-detected state. Read-only from the consumer side (updateValue ignores it), plugin code calls this when its hardware reports an obstruction sensor change.

Parameters

value

boolean

True when an obstruction is currently detected.

Returns

void

Example

ts
garage.setObstructionDetected(true);

setTargetState()

setTargetState(value): Promise<void>

Defined in: sensor/garage.ts:104

Set the target state. Override to drive hardware and call await super.setTargetState(value) after success: the base implementation syncs both targetState and currentState to the new value.

Parameters

value

GarageState

Desired target state from the GarageState enum.

Returns

Promise<void>

Example

ts
import { GarageState } from '@camera.ui/sdk';
await garage.setTargetState(GarageState.Open);

updateModelSpec()

updateModelSpec(): void

Defined in: sensor/base.ts:565

Re-announces the model spec, e.g. once the models finished loading.

The spec a detector reports at registration is what it knows at that moment: models that load in the background are missing from it. Call this after loading, the server replaces its copy.

Returns

void

Example

typescript
async onStart(): Promise<void> {
  await this.loadModel();
  this.updateModelSpec();
}

Inherited from

Sensor.updateModelSpec