younghyunjo / esp32-homekit

ESP-32 implementation of Apple Homekit Accessory Protocol(HAP)
Apache License 2.0
445 stars 124 forks source link

Thermostat accessory can't be adde. #31

Open CMGeorge opened 6 years ago

CMGeorge commented 6 years ago

I tried to set up a Thermostat accessory but it failed.

The debug display the following json fot adding the accessorie:

{"accessories":[{"aid":1,"services":[{"type":"0000004A-0000-1000-8000-0026BB765291","iid":1,"characteristics":[{"type":"0000000F-0000-1000-8000-0026BB765291","iid":2,"perms":["pr","ev"],"format":"uint8","value":0},{"type":"00000033-0000-1000-8000-0026BB765291","iid":3,"p erms":["pr","pw","ev"],"format":"uint8","value":0},{"type":"00000011-0000-1000-8000-0026BB765291","iid":4,"perms":["pr","ev"],"format":"float","value":0},{"type":"00000035-0000-1000-8000-0026BB765291","iid":5,"perms":["pr","pw","ev"],"format":"float","value":15},{"type": "00000036-0000-1000-8000-0026BB765291","iid":6,"perms":["pr","pw","ev"],"format":"uint8","value":0},{"type":"00000010-0000-1000-8000-0026BB765291","iid":7,"perms":["pr","ev"],"format":"float","value":50},{"type":"00000034-0000-1000-8000-0026BB765291","iid":8,"perms":["pr ","pw","ev"],"format":"float","value":50},{"type":"00000023-0000-1000-8000-0026BB765291","iid":9,"perms":["pr"],"format":"string","value":"New Thermostat"}]}]}]}

As code example I use: on HAP preparation: a = hap_accessory_register((char)BRIDGE_NAME, accessory_id, (char)"053-58-197", (char*)MANUFACTURER_NAME, // HAP_ACCESSORY_CATEGORY_SWITCH, HAP_ACCESSORY_CATEGORY_BRIDGE, 811, 1, NULL, &callback);

On callback

void* accessory_object = hap_accessory_add(hap_support_bridge);

struct hap_characteristic thermostat[] = { {HAP_CHARACTER_CURRENT_HEATING_COOLING_STATE, (void)thermostat_support_current_heating_cooling_state, NULL, thermostat_support_current_heating_cooling_state_read, NULL, thermostat_support_current_heating_cooling_state_notify }, {HAP_CHARACTER_TARGET_HEATING_COOLING_STATE, (void)thermostat_support_target_heating_cooling_state, NULL, thermostat_support_target_heating_cooling_state_read, thermostat_support_target_heating_cooling_state_write, thermostat_support_target_heating_cooling_state_notify }, {HAP_CHARACTER_CURRENT_TEMPERATURE, (void)thermostat_support_current_temperature, NULL, thermostat_support_current_temperature_read, NULL, thermostat_support_current_temperature_notify }, {HAP_CHARACTER_TARGET_TEMPERATURE, (void)thermostat_support_target_temperature, NULL, thermostat_support_target_temperature_read, NULL, thermostat_support_target_temperature_notify }, {HAP_CHARACTER_TEMPERATURE_DISPLAY_UNITS, (void)thermostat_support_temperature_display_unit, NULL, thermostat_support_temperature_display_unit_read, thermostat_support_temperature_display_unit_write, thermostat_support_temperature_display_unit_notify }, // {HAP_CHARACTER_COOLING_THRESHOLD_TEMPERATURE, // NULL , // NULL, // NULL, // NULL, // NULL // }, {HAP_CHARACTER_CURRENT_RELATIVE_HUMIDITY, (void)5000 , NULL, NULL, NULL, NULL }, // {HAP_CHARACTER_HEATING_THRESHOLD_TEMPERATURE, // NULL , // NULL, // NULL, // NULL, // NULL // }, {HAP_CHARACTER_TARGET_RELATIVE_HUMIDITY, (void*)5000 , NULL, NULL, NULL, NULL },

        //          {HAP_CHARACTER_ON, (void*)led2, NULL, led_read2, led_write2, led_notify2},
        {HAP_CHARACTER_NAME,
                (void*)ACCESSORY_THERMOSTAT_NAME ,
                NULL,
                NULL,
                NULL,
                NULL
        },

};
hap_service_and_characteristics_add(a,
        accessory_object,
        HAP_SERVICE_THERMOSTAT,
        thermostat,
        ARRAY_SIZE(thermostat));