@camera.ui/sdk / sensor / LightControl
Class: LightControl<TStorage>
Defined in: sensor/light.ts:57
Light control sensor. Override setOn()/setOff() to drive your hardware, then await super.setOn() / await super.setOff() to sync the SDK state.
Plugins with no hardware-action use case can leave the methods unoverridden, the base implementation just updates the state.
For hardware-pushed updates (someone manually flipped the switch), call super.setOn() / super.setOff() from your event handler. That bypasses any plugin override and only syncs state.
Extends
Sensor<LightControlProperties,TStorage,LightCapability>
Type Parameters
TStorage
TStorage extends object = Record<string, any>
Constructors
Constructor
new LightControl<
TStorage>(name?,options?):LightControl<TStorage>
Defined in: sensor/light.ts:61
Parameters
name?
string = 'Light'
options?
Returns
LightControl<TStorage>
Overrides
Properties
category
readonlycategory:Control=SensorCategory.Control
Defined in: sensor/light.ts:59
Overrides
name
readonlyname:string
Defined in: sensor/base.ts:223
Inherited from
onAssignmentChanged
readonlyonAssignmentChanged:Observable<readonlystring[]>
Defined in: sensor/base.ts:250
Inherited from
onCapabilitiesChanged
readonlyonCapabilitiesChanged:Observable<Brightness[]>
Defined in: sensor/base.ts:242
Inherited from
onConnectedChanged
readonlyonConnectedChanged:Observable<boolean>
Defined in: sensor/base.ts:252
Inherited from
onPropertyChanged
readonlyonPropertyChanged:Observable<PropertyChangeOf<LightControlProperties>>
Defined in: sensor/base.ts:240
Inherited from
type
readonlytype:Light=SensorType.Light
Defined in: sensor/light.ts:58
Overrides
Accessors
assignedCameraIds
Get Signature
get assignedCameraIds(): readonly
string[]
Defined in: sensor/base.ts:293
Returns
readonly string[]
Inherited from
assignmentLocked
Get Signature
get assignmentLocked():
boolean
Defined in: sensor/base.ts:297
Returns
boolean
Inherited from
brightness
Get Signature
get brightness():
number
Defined in: sensor/light.ts:74
Returns
number
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
connected
Get Signature
get connected():
boolean
Defined in: sensor/base.ts:289
Returns
boolean
Inherited from
displayName
Get Signature
get displayName():
string
Defined in: sensor/base.ts:281
Returns
string
Inherited from
id
Get Signature
get id():
string
Defined in: sensor/base.ts:269
Returns
string
Inherited from
isAssigned
Get Signature
get isAssigned():
boolean
Defined in: sensor/base.ts:285
Returns
boolean
Inherited from
nativeId
Get Signature
get nativeId():
string|undefined
Defined in: sensor/base.ts:273
Returns
string | undefined
Inherited from
on
Get Signature
get on():
boolean
Defined in: sensor/light.ts:70
Returns
boolean
origin
Get Signature
get origin():
string|undefined
Defined in: sensor/base.ts:277
Returns
string | undefined
Inherited from
pluginId
Get Signature
get pluginId():
string|undefined
Defined in: sensor/base.ts:301
Returns
string | undefined
Inherited from
props
Get Signature
get
protectedprops():Readonly<TProperties>
Defined in: sensor/base.ts:546
Returns
Readonly<TProperties>
Inherited from
storage
Get Signature
get storage():
DeviceStorage<TStorage>
Defined in: sensor/base.ts:305
Returns
DeviceStorage<TStorage>
Inherited from
storageSchema
Get Signature
get storageSchema():
JsonSchema[]
Defined in: sensor/base.ts:312
Returns
Inherited from
Methods
getValue()
Call Signature
getValue<
K>(property):LightControlProperties[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 LightControlProperties
Parameters
property
K
Returns
LightControlProperties[K] | undefined
Inherited from
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
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
const snapshot = sensor.getValues();
console.log(snapshot);Inherited from
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
const dimmable = sensor.hasCapability('brightness');Inherited from
onStart()
protectedonStart():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
protected override onStart(): void {
this._timer = setInterval(() => this.poll(), 5_000);
}Inherited from
onStop()
protectedonStop():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
protected override onStop(): void {
if (this._timer) clearInterval(this._timer);
}Inherited from
setBrightness()
setBrightness(
value):Promise<void>
Defined in: sensor/light.ts:115
Set brightness. Override to drive hardware and call await super.setBrightness(value) after the hardware call succeeds. The default implementation clamps the value to [0, 100].
Parameters
value
number
Brightness level in the range 0-100.
Returns
Promise<void>
Example
await light.setBrightness(75);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
sensor.setDisplayName('Front Door Motion');Inherited from
setOff()
setOff():
Promise<void>
Defined in: sensor/light.ts:100
Turn the light off. Override to drive hardware and call await super.setOff() after the hardware call succeeds to sync the SDK state.
Returns
Promise<void>
Example
await light.setOff();setOn()
setOn():
Promise<void>
Defined in: sensor/light.ts:87
Turn the light on. Override to drive hardware and call await super.setOn() after the hardware call succeeds to sync the SDK state.
Returns
Promise<void>
Example
await light.setOn();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
async onStart(): Promise<void> {
await this.loadModel();
this.updateModelSpec();
}