Optional
subtypeRest
...args: any[]Rest
...constructorArgs: any[]Adds a new link to the specified service. The service MUST be already added to the SAME accessory.
The service this service should link to
Removes a link to the specified service which was previously added with addLinkedService
Previously linked service
This updates the value by calling the CharacteristicEventTypes.SET event handler associated with the characteristic.
This acts the same way as when a HomeKit controller sends a /characteristics
request to update the characteristic.
An event notification will be sent to all connected HomeKit controllers which are registered
to receive event notifications for this characteristic.
This method behaves like a Characteristic.updateValue call with the addition that the own CharacteristicEventTypes.SET event handler is called.
The name or the constructor of the desired Characteristic.
The updated value.
Note: If you don't want the CharacteristicEventTypes.SET to be called, refer to updateCharacteristic.
Sets the state of the characteristic to an errored state.
If a Characteristic.onGet or CharacteristicEventTypes.GET handler is set up, the errored state will be ignored and the characteristic will always query the latest state by calling the provided handler.
If a generic error object is supplied, the characteristic tries to extract a HAPStatus code from the error message string. If not possible a generic HAPStatus.SERVICE_COMMUNICATION_FAILURE will be used. If the supplied error object is an instance of HapStatusError the corresponding status will be used.
This doesn't call any registered Characteristic.onSet or CharacteristicEventTypes.SET handlers.
Have a look at the Presenting Erroneous Accessory State to the User guide for more information on how to present erroneous state to the user.
The name or the constructor of the desired Characteristic.
The error object
Note: Erroneous state is never pushed to the client side. Only, if the HomeKit client requests the current state of the Characteristic, the corresponding HapStatusError is returned. As described above, any Characteristic.onGet or CharacteristicEventTypes.GET handlers have preference.
Sets this service as the new primary service. Any currently active primary service will be reset to be not primary. This will happen immediately, if the service was already added to an accessory, or later when the service gets added to an accessory.
optional boolean (default true) if the service should be the primary service
This updates the value of the characteristic. If the value changed, an event notification will be sent to all connected HomeKit controllers which are registered to receive event notifications for this characteristic.
The name or the constructor of the desired Characteristic.
The new value.
Sets the state of the characteristic to an errored state. If a Characteristic.onGet or CharacteristicEventTypes.GET handler is set up, the errored state will be ignored and the characteristic will always query the latest state by calling the provided handler.
If a generic error object is supplied, the characteristic tries to extract a HAPStatus code from the error message string. If not possible a generic HAPStatus.SERVICE_COMMUNICATION_FAILURE will be used. If the supplied error object is an instance of HapStatusError the corresponding status will be used.
The name or the constructor of the desired Characteristic.
The error object
Have a look at the Presenting Erroneous Accessory State to the User guide for more information on how to present erroneous state to the user.
Note: Erroneous state is never pushed to the client side. Only, if the HomeKit client requests the current state of the Characteristic, the corresponding HapStatusError is returned. As described above, any Characteristic.onGet or CharacteristicEventTypes.GET handlers have precedence.
Static
AccessStatic
AccessStatic
AccessoryStatic
AccessoryStatic
AccessoryStatic
AirStatic
AirStatic
AssetStatic
AssistantStatic
AudioStatic
BatteryStatic
CameraStatic
CameraStatic
CameraRTPStreamStatic
CarbonStatic
CarbonStatic
CloudStatic
ContactStatic
DataStatic
DiagnosticsStatic
DoorStatic
DoorbellStatic
FanStatic
Fanv2Static
FaucetStatic
FilterStatic
FirmwareStatic
GarageStatic
HeaterStatic
HumidifierStatic
HumidityStatic
InputStatic
IrrigationStatic
LeakStatic
LightbulbStatic
LightStatic
LockStatic
LockStatic
MicrophoneStatic
MotionStatic
NFCAccessStatic
OccupancyStatic
OutletStatic
PairingStatic
PowerStatic
ProtocolStatic
SecurityStatic
ServiceStatic
SiriStatic
SiriStatic
SlatsStatic
SmartStatic
SmokeStatic
SpeakerStatic
StatefulStatic
StatelessStatic
SwitchStatic
TapStatic
TargetStatic
TargetStatic
TelevisionStatic
TelevisionStatic
TemperatureStatic
ThermostatStatic
ThreadStatic
TransferStatic
TunnelStatic
ValveStatic
WiStatic
WiStatic
WiStatic
WindowStatic
Window
Service represents a set of grouped values necessary to provide a logical function. For instance, a "Door Lock Mechanism" service might contain two values, one for the "desired lock state" and one for the "current lock state". A particular Service is distinguished from others by its "type", which is a UUID. HomeKit provides a set of known Service UUIDs defined in HomeKit.ts along with a corresponding concrete subclass that you can instantiate directly to set up the necessary values. These natively-supported Services are expected to contain a particular set of Characteristics.
Unlike Characteristics, where you cannot have two Characteristics with the same UUID in the same Service, you can actually have multiple Services with the same UUID in a single Accessory. For instance, imagine a Garage Door Opener with both a "security light" and a "backlight" for the display. Each light could be a "Lightbulb" Service with the same UUID. To account for this situation, we define an extra "subtype" property on Service, that can be a string or other string-convertible object that uniquely identifies the Service among its peers in an Accessory. For instance, you might have
service1.subtype = 'security_light'
for one andservice2.subtype = 'backlight'
for the other.You can also define custom Services by providing your own UUID for the type that you generate yourself. Custom Services can contain an arbitrary set of Characteristics, but Siri will likely not be able to work with these.