HMCharacteristicWriteAction what to pass for targetValue



In HomeKit 我的代码是

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

HMCharacteristicWriteAction具有方法initWithCharacterstic,该方法需要两个参数

1)对于需要通过的初始化特征,HMService对象。

2)对于目标值,我需要为目标值传递什么?

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

目标值取决于您正在编写的特征。 灯泡可能支持以下特性:

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

您几乎可以保证灯泡将支持HMCharacteristicTypePowerState 。 其他人可能不是。 灯泡还可以支持制造商定义的其他特性 - 例如,频闪灯可能支持"闪烁率"特性。

最新更新