Skip to content

hap-fluent

AccessoryHandler

NameDescription
AccessoryHandlerClass-based wrapper around a Homebridge PlatformAccessory that manages its fluent service helpers and exposes a typed services map.
FluentAccessoryA Homebridge PlatformAccessory augmented with strongly-typed FluentService properties for each declared service.
ServicesObjectA record mapping camelCase service names to their corresponding FluentService instances.
ServicesStateObjectPartial characteristic-value map for initializing an accessory's services.
createServicesObjectBuild a strongly-typed service map by wrapping an array of service instances.
initializeAccessoryInitialize a PlatformAccessory with fluent service wrappers and apply initial characteristic values in a single call.

Errors

ClassDescription
ConfigurationErrorError thrown when logger or plugin configuration is invalid or incomplete.
FluentCharacteristicErrorError thrown when a characteristic get, set, or update operation fails.
FluentErrorBase class for all HAP Fluent errors.
FluentServiceErrorError thrown when a service-level operation fails (e.g., wrapping an invalid service).
ValidationErrorError thrown when input validation fails (e.g., an invalid service or characteristic value is passed to a hap-fluent function).

FluentCharacteristic

ClassDescription
FluentCharacteristicType-safe, chainable wrapper around a single HAP-NodeJS Characteristic.

FluentService

NameDescription
FluentServiceStrongly-typed, fluent view of a HAP service and all its characteristics.
getOrAddServiceRetrieve an existing service from an accessory, or create and attach a new one, then wrap it with the fluent helper interface.
wrapServiceWrap an existing HAP Service instance with the fluent helper interface.

Logger

NameDescription
LoggerOptionsConfiguration options for the global hap-fluent logger.
LogLevelValid Pino log level identifiers.
configureLoggerConfigure the global hap-fluent logger instance.
createChildLoggerCreate a child Pino logger with additional bound context fields.
getLoggerGet the current global logger instance.

Other

NameDescription
Enums-
AccessCode-
AccessControl-
AccessoryInformation-
AccessoryMetrics-
AccessoryRuntimeInformation-
AirPurifier-
AirQualitySensor-
AssetUpdate-
Assistant-
AudioStreamManagement-
Battery-
CameraOperatingMode-
CameraRecordingManagement-
CameraRTPStreamManagement-
CarbonDioxideSensor-
CarbonMonoxideSensor-
CloudRelay-
ContactSensor-
DataStreamTransportManagement-
Diagnostics-
Door-
Doorbell-
Fan-
Fanv2-
Faucet-
FilterMaintenance-
FirmwareUpdate-
GarageDoorOpener-
HeaterCooler-
HumidifierDehumidifier-
HumiditySensor-
InputSource-
IrrigationSystem-
LeakSensor-
Lightbulb-
LightSensor-
LockManagement-
LockMechanism-
Microphone-
MotionSensor-
NFCAccess-
OccupancySensor-
Outlet-
Pairing-
PowerManagement-
ProtocolInformation-
SecuritySystem-
ServiceLabel-
Siri-
SiriEndpoint-
Slats-
SmartSpeaker-
SmokeSensor-
Speaker-
StatefulProgrammableSwitch-
StatelessProgrammableSwitch-
Switch-
TapManagement-
TargetControl-
TargetControlManagement-
Television-
TelevisionSpeaker-
TemperatureSensor-
Thermostat-
ThreadTransport-
TransferTransportManagement-
Tunnel-
Valve-
WiFiRouter-
WiFiSatellite-
WiFiTransport-
Window-
WindowCovering-
WithTypedUUIDUtility interface for services with typed UUIDs This is kept for backward compatibility but is no longer needed with the new generic type mapping approach
CharacteristicNamesOf-
InterfaceForService-
InterfaceMap-
Interfaces-
InternalServicesStateObject-
ServiceForInterface-
ServiceMap-
Services-
isMultiServiceDetermine if the provided state object represents multiple service instances.
resetLoggerReset the logger instance (primarily for testing)

TypeGuards

NameDescription
CharacteristicValueUnion of all valid HAP characteristic value types per the HAP specification.
isBooleanDetermine whether value is a boolean.
isCharacteristicDetermine whether obj is a valid hap-nodejs Characteristic instance.
isCharacteristicValueDetermine whether value is a valid HAP CharacteristicValue.
isNumberDetermine whether value is a finite number (excludes NaN).
isServiceDetermine whether obj is a valid hap-nodejs Service instance.
isStringDetermine whether value is a string.

TypeUtils

NameDescription
CharacteristicNamesExtract the camelCase characteristic name union from a FluentService type.
CharacteristicTypeExtract the FluentCharacteristic<T> type for a named characteristic on a service.
OptionalPropertiesMake a subset of properties on T optional while leaving others unchanged.
PartialServiceStateA partial ServiceState for incremental characteristic updates.
RequirePropertiesMake a subset of properties on T required while leaving others unchanged.
ServiceStateA flat record mapping characteristic names to their current HAP values.
ValuePredicateA predicate function for characteristic values.
ValueTransformerA function that transforms a characteristic value from one type/shape to another.
createClampTransformerCreate a ValueTransformer that clamps a numeric value to [min, max].
createRangePredicateCreate a ValuePredicate that validates whether a number falls within [min, max].
createScaleTransformerCreate a ValueTransformer that linearly maps a value from one numeric range to another.
isFluentCharacteristicDetermine whether value is a FluentCharacteristic instance.

Released under the Apache-2.0 License.