1

在 HomeKit 我的代码是

HMAction *myAction = [[HMCharacteristicWriteAction alloc] 
initWithCharacteristic:[[lightBulbService characteristics] objectAtIndex:0] targetValue:characteristicValue];

HMCharacteristicWriteAction 有方法 initWithCharacterstic 需要两个参数

1)对于需要传递的initWithCharacteristic,HMService对象。

2)对于targetValue,我需要为targetValue传递什么?

我需要知道特征的目标值是什么?

4

1 回答 1

4

目标值取决于您正在编写的特征。灯泡可能支持诸如

  • HMCharacteristicTypeHue- 整数 0-360(度)
  • HMCharacteristicTypeSaturation- 整数 0 - 100(百分比)
  • HMCharacteristicTypeBrightness- 整数 0 - 100(百分比)。
  • HMCharacteristicTypePowerState- 布尔开或关。

您几乎可以保证灯泡将支持HMCharacteristicTypePowerState. 其他的可能没有。灯泡还可以支持制造商定义的其他特性——例如,闪光灯可能支持“闪烁率”特性。

于 2014-11-27T06:50:12.613 回答