-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I can't name the switch with different name in same accessory #217
Comments
It looks like it should work, but I have a question: is this code - a simplification or it is an original code as is? Because I have noticed that ACCESSORY_INFORMATION service is missing some required characteristics (e.g. MANUFACTURER, SERIAL_NUMBER, MODEL, FIRMWARE_REVISION). Take a look at this example, it defines a number of same type services with different names. |
(reedit to make the code much visible) This is my all code to define accessory #include "homekit/types.h"
#include <homekit/homekit.h>
#include <homekit/characteristics.h>
void my_accessory_identify(homekit_value_t _value) {
printf("accessory identify\n");
}
homekit_characteristic_t fan_name = HOMEKIT_CHARACTERISTIC_(NAME, "FAN");
homekit_characteristic_t cold_fan_active = HOMEKIT_CHARACTERISTIC_(ACTIVE, 0);
homekit_characteristic_t cold_fan_rotation_speed = HOMEKIT_CHARACTERISTIC_(ROTATION_SPEED, 100);
homekit_characteristic_t cold_fan_swing_mode = HOMEKIT_CHARACTERISTIC_(SWING_MODE, 1);
homekit_characteristic_t cold_fan_name = HOMEKIT_CHARACTERISTIC_(NAME, "COLD FAN");
homekit_characteristic_t hot_fan_active = HOMEKIT_CHARACTERISTIC_(ACTIVE, 0);
homekit_characteristic_t hot_fan_rotation_speed = HOMEKIT_CHARACTERISTIC_(ROTATION_SPEED, 100);
homekit_characteristic_t hot_fan_swing_mode = HOMEKIT_CHARACTERISTIC_(SWING_MODE, 1);
homekit_characteristic_t hot_fan_name = HOMEKIT_CHARACTERISTIC_(NAME, "HOT FAN");
homekit_characteristic_t change_fan_active = HOMEKIT_CHARACTERISTIC_(ACTIVE, 0);
homekit_characteristic_t change_fan_rotation_speed = HOMEKIT_CHARACTERISTIC_(ROTATION_SPEED, 100);
homekit_characteristic_t change_fan_name = HOMEKIT_CHARACTERISTIC_(NAME, "CHANGE FAN");
homekit_characteristic_t dehumidity_name = HOMEKIT_CHARACTERISTIC_(NAME, "DEHUMIDIFIER");
homekit_characteristic_t cold_dehumidity_active = HOMEKIT_CHARACTERISTIC_(ACTIVE, 0);
homekit_characteristic_t cold_dehumidity = HOMEKIT_CHARACTERISTIC_(CURRENT_RELATIVE_HUMIDITY, 0);
homekit_characteristic_t cold_dehumidity_current = HOMEKIT_CHARACTERISTIC_(CURRENT_HUMIDIFIER_DEHUMIDIFIER_STATE, 0, .valid_values = {.count=1, .values = (uint8_t[]) {0}}); // 0, 1, 2, 3
homekit_characteristic_t cold_dehumidity_target = HOMEKIT_CHARACTERISTIC_(TARGET_HUMIDIFIER_DEHUMIDIFIER_STATE, 2, .valid_values={.count=1, .values = (uint8_t[]) {2}}); // 0, 1, 2);
homekit_characteristic_t cold_dehumidity_relative = HOMEKIT_CHARACTERISTIC_(RELATIVE_HUMIDITY_DEHUMIDIFIER_THRESHOLD, 40);
homekit_characteristic_t cold_dehumidity_swing_mode = HOMEKIT_CHARACTERISTIC_(SWING_MODE, 1);
homekit_characteristic_t cold_dehumidity_name = HOMEKIT_CHARACTERISTIC_(NAME, "COLD DRY");
homekit_characteristic_t hot_dehumidity_active = HOMEKIT_CHARACTERISTIC_(ACTIVE, 0);
homekit_characteristic_t hot_dehumidity = HOMEKIT_CHARACTERISTIC_(CURRENT_RELATIVE_HUMIDITY, 0);
homekit_characteristic_t hot_dehumidity_current = HOMEKIT_CHARACTERISTIC_(CURRENT_HUMIDIFIER_DEHUMIDIFIER_STATE, 0, .valid_values = {.count=1, .values = (uint8_t[]) {0}}); // 0, 1, 2, 3
homekit_characteristic_t hot_dehumidity_target = HOMEKIT_CHARACTERISTIC_(TARGET_HUMIDIFIER_DEHUMIDIFIER_STATE, 2, .valid_values={.count=1, .values = (uint8_t[]) {2}}); // 0, 1, 2);
homekit_characteristic_t hot_dehumidity_relative = HOMEKIT_CHARACTERISTIC_(RELATIVE_HUMIDITY_DEHUMIDIFIER_THRESHOLD, 40);
homekit_characteristic_t hot_dehumidity_swing_mode = HOMEKIT_CHARACTERISTIC_(SWING_MODE, 1);
homekit_characteristic_t hot_dehumidity_name = HOMEKIT_CHARACTERISTIC_(NAME, "HOT DRY");
homekit_characteristic_t function_name = HOMEKIT_CHARACTERISTIC_(NAME, "Function");
// format: float; min 0.0001, max 100000
homekit_characteristic_t cha_light_sensor = HOMEKIT_CHARACTERISTIC_(CURRENT_AMBIENT_LIGHT_LEVEL, 1);
homekit_characteristic_t cha_auto_light_on = HOMEKIT_CHARACTERISTIC_(ON, true);
homekit_characteristic_t cha_auto_change_on = HOMEKIT_CHARACTERISTIC_(ON, true);
homekit_characteristic_t cha_auto_change_on_name = HOMEKIT_CHARACTERISTIC_(NAME, "Auto change");
homekit_characteristic_t all_swing = HOMEKIT_CHARACTERISTIC_(ON, true);
homekit_characteristic_t all_swing_name = HOMEKIT_CHARACTERISTIC_(NAME, "SWING");
homekit_accessory_t *accessories[] = {
HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_bridge, .services=(homekit_service_t*[]) {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
HOMEKIT_CHARACTERISTIC(NAME, "DELTA 400"),
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "delta test"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "00000001"),
HOMEKIT_CHARACTERISTIC(MODEL, "8266 test"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
NULL
}),
NULL
}),
HOMEKIT_ACCESSORY(.id=2, .category=homekit_accessory_category_fan, .services=(homekit_service_t*[]) {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "fan"),
&fan_name,
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "delta test"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "00000001"),
HOMEKIT_CHARACTERISTIC(MODEL, "8266 test"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
NULL
}),
HOMEKIT_SERVICE(FAN2, .primary=false, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "cold fan"),
&cold_fan_name,
&cold_fan_active,
&cold_fan_rotation_speed,
&cold_fan_swing_mode,
NULL
}),
HOMEKIT_SERVICE(FAN2, .primary=false, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "HOT fan"),
&hot_fan_name,
&hot_fan_active,
&hot_fan_rotation_speed,
&hot_fan_swing_mode,
NULL
}),
HOMEKIT_SERVICE(FAN2, .primary=false, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "Change fan"),
&change_fan_name,
&change_fan_active,
&change_fan_rotation_speed,
NULL
}),
NULL
}),
HOMEKIT_ACCESSORY(.id=3, .category=homekit_accessory_category_dehumidifier, .services=(homekit_service_t*[]) {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "Dehumidifiers"),
&dehumidity_name,
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "delta test"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "00000001"),
HOMEKIT_CHARACTERISTIC(MODEL, "8266 test"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
NULL
}),
HOMEKIT_SERVICE(HUMIDIFIER_DEHUMIDIFIER, .primary=false, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "COLD DRY"),
&cold_dehumidity_name,
&cold_dehumidity_active,
&cold_dehumidity,
&cold_dehumidity_current,
&cold_dehumidity_target,
//&cold_dehumidity_relative,
&cold_dehumidity_swing_mode,
NULL
}),
HOMEKIT_SERVICE(HUMIDIFIER_DEHUMIDIFIER, .primary=false, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "HOT DRY"),
&hot_dehumidity_name,
&hot_dehumidity_active,
&hot_dehumidity,
&hot_dehumidity_current,
&hot_dehumidity_target,
//&hot_dehumidity_relative,
&hot_dehumidity_swing_mode,
NULL
}),
NULL
}),
HOMEKIT_ACCESSORY(.id=4, .category=homekit_accessory_category_sensor, .services=(homekit_service_t*[]) {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
HOMEKIT_CHARACTERISTIC(NAME, "Light Sensor"),
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "delta test"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "00000001"),
HOMEKIT_CHARACTERISTIC(MODEL, "8266 test"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
NULL
}),
HOMEKIT_SERVICE(LIGHT_SENSOR, .primary=true, .characteristics=(homekit_characteristic_t*[]) {
&cha_light_sensor,
NULL
}),
NULL
}),
HOMEKIT_ACCESSORY(.id=5, .category=homekit_accessory_category_lightbulb, .services=(homekit_service_t*[]) {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
HOMEKIT_CHARACTERISTIC(NAME, "Auto Night LED"),
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "delta test"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "00000001"),
HOMEKIT_CHARACTERISTIC(MODEL, "8266 test"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
NULL
}),
HOMEKIT_SERVICE(LIGHTBULB, .primary=true, .characteristics=(homekit_characteristic_t*[]) {
&cha_auto_light_on,
NULL
}),
NULL
}),
HOMEKIT_ACCESSORY(.id=6, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "FUNCTION"),
&function_name,
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "delta test"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "00000001"),
HOMEKIT_CHARACTERISTIC(MODEL, "8266 test"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "1.0"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
NULL
}),
HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "Auto change"),
&cha_auto_change_on_name,
&cha_auto_change_on,
NULL
}),
HOMEKIT_SERVICE(SWITCH,. primary=false, .characteristics=(homekit_characteristic_t*[]) {
//HOMEKIT_CHARACTERISTIC(NAME, "SWING"),
&all_swing_name,
&all_swing,
NULL
}),
NULL
}),
NULL
};
homekit_server_config_t config = {
.accessories = accessories,
.password = "111-11-111"
}; |
This is part of my accessory code
If I don't finish the whole setup it will show as the picture above.
Going throw all the pairing process the SWITCH will name at SWITCH1 and SWITCH2
I always get the same result and I can't figure why.
sometimes the name predefine will show as recommend in gray word if I delete the default name.
The text was updated successfully, but these errors were encountered: