使用 homekit 设置颜色的特性

characteristics for setting color with homekit

我正在使用 https://github.com/etwmc/Personal-HomeKit-HAP- 模拟 homekit 兼容设备。 Siri 不会接受颜色命令,例如 "change my lamps to blue",在没有请求的情况下以 "your lights are not responding" 响应。我认为是因为我的特征不符合 Siri 的期望,但哪些是正确的?

printf("Initial Accessory\n");
accSet = &AccessorySet::getInstance();
Accessory *lightAcc = new Accessory();
addInfoServiceToAccessory(lightAcc, "Light 1", "ET", "Light", "12345678", &lightIdentify);
accSet->addAccessory(lightAcc);

Service *lightService = new Service(charType_lightBulb);
lightAcc->addService(lightService);

stringCharacteristics *lightServiceName = new stringCharacteristics(charType_serviceName, premission_read, 0);
lightServiceName->setValue("Light");
lightAcc->addCharacteristics(lightService, lightServiceName);

boolCharacteristics *powerState = new boolCharacteristics(charType_on, premission_read|premission_write|premission_notify);
powerState->setValue("true");
powerState->valueChangeFunctionCall = &changeLightState;
lightAcc->addCharacteristics(lightService, powerState);

intCharacteristics *brightnessState = new intCharacteristics(charType_brightness, premission_read|premission_write|premission_notify, 0, 100, 1, unit_percentage);
brightnessState->setValue("50");
brightnessState->valueChangeFunctionCall = &changeLightIntensity;
lightAcc->addCharacteristics(lightService, brightnessState);

intCharacteristics *saturationState= new intCharacteristics(charType_saturation, premission_read|premission_write|premission_notify, 0, 100, 1, unit_percentage);
saturationState->setValue("100");
saturationState->valueChangeFunctionCall = &changeLightSat;
lightAcc->addCharacteristics(lightService, saturationState);

intCharacteristics *hueState= new intCharacteristics(charType_hue, premission_read|premission_write|premission_notify, 0, 360, 1, unit_arcDegree);
hueState->setValue("0");
hueState->valueChangeFunctionCall = &changeLightColor;

Homekit 数据库是共享的,设备中安装的所有启用 homekit 的应用程序以及 Siri 都可以访问它,但 siri 只能理解您为主页、附件、 trigger, scene 和 by services 和其他 homekit 对象的特性。

现在如果你想改变任何配件(光)的颜色,很可能它会有饱和度亮度Hue 特性。 这 3 个特征的组合将创造出一种颜色。

所以你可以告诉 siri 改变饱和度、亮度和色调,

赞 Siri, set desk lamp Hue in Main Hall to 220 (Hue can be 0 to 360)

这里Main Hall是房间的名字(可以自己改), desk lamp 是配件名称 Huedesk lamp 的 轻型服务的特征。

220是特征值。 色调 是实际颜色或阴影。