HMCharacteristic PRO

HMCharacteristic is a single readable / writable / observable value on an HMService. It exposes its current value, allowed range/format via metadata, and an event-subscription API.


Properties

PropertyTypeDescription
uuidstringStable HomeKit UUID.
serviceUUIDstringUUID of the parent service.
characteristicTypeHMCharacteristicTypeSemantic role ('powerState', 'currentTemperature', ...).
propertiesHMCharacteristicProperty[]'readable' | 'writable' | 'supportsEvent' | 'hidden'.
metadataHMCharacteristicMetadata | nullFormat / units / min / max / validValues.
valueHMCharacteristicValue | nullLast cached value (use readValue() to refresh).

Read & write

const v = await ch.readValue()                   // hits the accessory
await ch.writeValue(true)                        // coerced & range-checked vs metadata

writeValue rejects with an Error when the value violates metadata.minimumValue / metadata.maximumValue / metadata.validValues / metadata.maxLength.


Subscribe to value changes

await ch.subscribe((err, value) => {
  if (err) return console.error(err)
  console.log("update:", value)
})

// later
await ch.unsubscribe()

HomeKit notification delivery is best-effort. For mission-critical observation, also poll readValue() periodically.