Closed maccoylton closed 6 years ago
This is usually an indication that you have incorrect data in your accessory definitions and controller when detects that unpairs itself automatically. I quick skim through your payload shows error in "Current Heating Cooling State" where it has value 3, although valid values are 0, 1 and 2.
I'm currently working on Thermostat example too and here is how my definition looks like:
homekit_characteristic_t current_temperature = HOMEKIT_CHARACTERISTIC_( CURRENT_TEMPERATURE, 0 );
homekit_characteristic_t target_temperature = HOMEKIT_CHARACTERISTIC_( TARGET_TEMPERATURE, 0 );
homekit_characteristic_t units = HOMEKIT_CHARACTERISTIC_( TEMPERATURE_DISPLAY_UNITS, 0 );
homekit_characteristic_t current_state = HOMEKIT_CHARACTERISTIC_( CURRENT_HEATING_COOLING_STATE, 0 );
homekit_characteristic_t target_state = HOMEKIT_CHARACTERISTIC_( TARGET_HEATING_COOLING_STATE, 0 );
homekit_characteristic_t cooling_threshold = HOMEKIT_CHARACTERISTIC_( COOLING_THRESHOLD_TEMPERATURE, 0 );
homekit_characteristic_t heating_threshold = HOMEKIT_CHARACTERISTIC_( HEATING_THRESHOLD_TEMPERATURE, 0 );
homekit_characteristic_t current_humidity = HOMEKIT_CHARACTERISTIC_( CURRENT_RELATIVE_HUMIDITY, 0 );
homekit_accessory_t *accessories[] = {
HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_thermostat, .services=(homekit_service_t*[]) {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
HOMEKIT_CHARACTERISTIC(NAME, "Thermostat"),
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "HaPK"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "001"),
HOMEKIT_CHARACTERISTIC(MODEL, "MyThermostat"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "0.1"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, thermostat_identify),
NULL
}),
HOMEKIT_SERVICE(THERMOSTAT, .primary=true, .characteristics=(homekit_characteristic_t*[]) {
HOMEKIT_CHARACTERISTIC(NAME, "Thermostat"),
¤t_temperature,
&target_temperature,
¤t_state,
&target_state,
&cooling_threshold,
&heating_threshold,
&units,
¤t_humidity,
NULL
}),
NULL
}),
NULL
};
If you haven't updated to latest version of esp-homekit, I bet this should convince you to do that. Accessory definition macros are not backward compatible, but it should be a straightforward localized change.
Thanks,that fixed it. I have the latest code, which is a useful improvement. BTW I notice in your example you have target temperature defaulted to 0, the range for that is normally defined as 10 to 38, so you may want to change that for the same reason that tripped me up ;-)
@maximkulkin Same issue here. I'm trying to get a garage door remote working. Where might I find specs from Apple for which characteristics I need and what they need in them? I'm currently using CURRENT_DOOR_STATE and TARGET_DOOR_STATE.
@brianc118 you can find the specs here, they will tell you the required characteristics, optional characteristics, and their values: https://developer.apple.com/homekit/specification/.
You do need a free developer account to access it.
PS. if downloading redirects you to https://developer.apple.com, remove the extra slash before homekit in the URL.
I get all my info about which services use which characteristics (required or optional) from here: https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js
@michaeljanich I think using official specification that renssies mentioned would be better
Yep it's working after following the official specs
Having successfully built and flashed a couple of examples, I am now having some issue with pairing. Seems immediately after the verification step is complete, and the get accessories is called, I then get a remove pairing event, summary and detailed traces below, any ideas?
Detailed trace:-
{"accessories":[{"aid":1,"services":[{"iid":1,"type":"3E","hidden":false,"primary":false,"characteristics":[{"aid":1,"iid":2,"type":"23","perms":["pr"],"description":"Name","format":"string","value":"Thermostat"},{"aid":1,"iid":3,"type":"20","perms":["pr"],"description":"Manufacturer","format":"string","value":"HaPK"},{"aid":1,"iid":4,"type":"30","perms":["pr"],"description":"Serial Number","format":"string","value":"0012345"},{"aid":1,"iid":5,"type":"21","perms":["pr"],"description":"Model","format":"string","value":"MyThermostat"},{"aid":1,"iid":6,"type":"52","perms":["pr"],"description":"Firmware Revision","format":"string","value":"0.1"},{"aid":1,"iid":7,"type":"14","perms":["pw"],"description":"Identify","format":"bool"}]},{"iid":8,"type":"4A","hidden":false,"primary":true,"characteristics":[{"aid":1,"iid":9,"type":"23","perms":["pr"],"description":"Name","format":"string","value":"Thermostat"},{"aid":1,"iid":10,"type":"F","perms":["pr","ev"],"ev":false,"description":"Current Heating Cooling State","format":"uint8","minValue":0,"maxValue":2,"minStep":1,"valid-values":[0,1,2],"value":3},{"aid":1,"iid":11,"type":"33","perms":["pr","pw","ev"],"ev":false,"description":"Target Heating Cooling State","format":"uint8","minValue":0,"maxValue":3,"minStep":1,"valid-values":[0,1,2,3],"value":3},{"aid":1,"iid":12,"type":"11","perms":["pr","ev"],"ev":false,"description":"Current Temperature","format":"float","unit":"celsius","minValue":0,"maxValue":100,"minStep":0.10000000149011612,"value":20.100000381469727},{"aid":1,"iid":13,"type":"35","perms":["pr","pw","ev"],"ev":false,"description":"Target Temperature","format":"float","unit":"celsius","minValue":10,"maxValue":38,"minStep":0.10000000149011612,"value":21},{"aid":1,"iid":14,"type":"36","perms":["pr","pw","ev"],"ev":false,"description":"Temperature Display Units","format":"uint8","minValue":0,"maxValue":1,"minStep":1,"valid-values":[0,1],"value":0}]},{"iid":15,"type":"82","hidden":false,"primary":false,"characteristics":[{"aid":1,"iid":16,"type":"23","perms":["pr"],"description":"Name","format":"string","value":"Humidity Sensor"},{"aid":1,"iid":17,"type":"10","perms":["pr","ev"],"ev":false,"description":"Current Relative Humidity","format":"float","unit":"percentage","minValue":0,"maxValue":100,"minStep":1,"value":58.099998474121094}]}]}]}