HMCharacteristicWriteAction what to pass for targetValue

370 views Asked by At

In HomeKit My code is

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

HMCharacteristicWriteAction have method initWithCharacterstic which requried two parameter

1) For initWithCharacteristic need to pass, HMService object.

2) For targetValue, What i need to Pass for targetValue ?

i need to know what is, target value for the characteristic ?

1

There are 1 answers

3
Paulw11 On BEST ANSWER

The target value depends on the characteristic you are writing. A lightbulb may support characteristics such as

  • HMCharacteristicTypeHue - Integer 0-360 (degrees)
  • HMCharacteristicTypeSaturation - Integer 0 - 100 (percentage)
  • HMCharacteristicTypeBrightness - Integer 0 - 100 (percentage).
  • HMCharacteristicTypePowerState - Boolean on or off.

You can pretty much guarantee that a lightbulb will support HMCharacteristicTypePowerState. The others maybe not. A lightbulb can also support additional characteristics, defined by the manufacturer - A strobe might support a 'blink rate' characteristic for example.