HMAccessory PRO

HMAccessory is a single HomeKit accessory — a light, sensor, lock, thermostat, etc. — and its services.


Read-only properties

PropertyTypeDescription
uuidstringStable HomeKit UUID.
namestringUser-assigned name.
roomHMRoom | nullThe room this accessory belongs to.
categoryHMAccessoryCategoryHigh-level category ('lightbulb', 'thermostat', ...).
manufacturerstring | null
modelstring | null
firmwareVersionstring | null
isReachablebooleanWhether HomeKit can talk to it right now.
isBlockedboolean
isBridgedbooleanTrue if this accessory is exposed via a HomeKit bridge.
bridgedAccessoryUUIDsstring[] | nullChildren if this is a bridge.
servicesHMService[]Cluster of typed characteristics.

Operations

await accessory.rename("Living Room Lamp")
await accessory.identify()                       // ask the accessory to physically identify (e.g. blink)

Events

accessory.onReachabilityChanged    = ok => { /* ... */ }
accessory.onNameChanged            = name => { /* ... */ }
accessory.onServicesChanged        = list => { /* ... */ }
accessory.onFirmwareVersionChanged = v => { /* ... */ }

Example: turn a light on

const home = await HMHomeManager.primaryHome
const light = home?.accessories.find(a => a.category === 'lightbulb')
const power = light?.services
  .find(s => s.serviceType === 'lightbulb')
  ?.characteristics.find(c => c.characteristicType === 'powerState')

await power?.writeValue(true)