Closed roscoe81 closed 4 years ago
Hi,
In debug mode
homebridge -D
I got this warning:
HAP Warning: Characteristic 000000C6-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 0000008D-0000-1000-8000-0026BB765291. Adding anyway.
Could you please post how you add the accessory and how you set the PM2.5Density value.
Many thanks for your prompt response.
I'm sending .... topic: homebridge/to/add payload: { "name": "Living Air Quality", "service_name": "Living Air Quality", "service": "AirQualitySensor", "PM2_5Density": "default", "VOCDensity": "default" } The Accessory appears in the Apple Home App with Air Quality and VOC characteristics but no PM2.5 characteristic. I haven't tried to subsequently set the PM2.5 value because the relevant field doesn't appear in the app.
If I send the following, the Accessory appears in the Apple Home App with Air Quality, PM10 and VOC characteristics. topic: homebridge/to/add payload: { "name": "Living Air Quality", "service_name": "Living Air Quality", "service": "AirQualitySensor", "PM10Density": "default", "VOCDensity": "default" }
In fact, that's been my workaround to date. I've been sending the data as a PM10 reading, even though the sensor is a PM2.5 sensor. However, according to the HAP spec, PM2.5Density should work as an optional characteristic for the AirQualitySensor service.
I think something is odd in homebridge or HAP. Try this workaround for now:
Add these lines inaccessory.js
> Accessory.prototype.configureOptionalCharacteristics
after line 167
if (c === "PM2.5Density") {
c = "PM2_5Density";
this.log("optional c = %s", c);
}
Many thanks for the workaround. It successfully allowed me to add the PM2_5Density characteristic and it appeared as it should in the Home app. However, the resulting cachedAccessories file could not be successfully read when restarting homebridge. I could only successfully restart homebridge by reverting to the old cachedAccessories(with PM10).
I received the following homebridge error log when restarting homebridge with the updated cachedAccessories:
Jan 12 06:59:16 studypi homebridge[17975]: [2020-1-12 06:59:16] TypeError: Cannot read property 'on' of undefined
Jan 12 06:59:16 studypi homebridge[17975]: at Accessory.allocate (/usr/lib/node_modules/homebridge-mqtt/lib/accessory.js:192:6)
Jan 12 06:59:16 studypi homebridge[17975]: at Accessory.configureCharacteristics (/usr/lib/node_modules/homebridge-mqtt/lib/accessory.js:147:12)
Jan 12 06:59:16 studypi homebridge[17975]: at Accessory.configureAccessory (/usr/lib/node_modules/homebridge-mqtt/lib/accessory.js:116:14)
Jan 12 06:59:16 studypi homebridge[17975]: at Controller.configureAccessory (/usr/lib/node_modules/homebridge-mqtt/lib/controller.js:188:15)
Jan 12 06:59:16 studypi homebridge[17975]: at PluginPlatform.configureAccessory (/usr/lib/node_modules/homebridge-mqtt/index.js:81:21)
Jan 12 06:59:16 studypi homebridge[17975]: at Server._configCachedPlatformAccessories (/usr/lib/node_modules/homebridge/lib/server.js:386:24)
Jan 12 06:59:16 studypi homebridge[17975]: at Server.run (/usr/lib/node_modules/homebridge/lib/server.js:93:8)
Jan 12 06:59:16 studypi homebridge[17975]: at module.exports (/usr/lib/node_modules/homebridge/lib/cli.js:59:10)
Jan 12 06:59:16 studypi homebridge[17975]: at Object.
Hi, it‘s 10:50 pm in Switzerland. I‘ll have a look tomorrow.
Trust that you had a good sleep and I think that I've solved the problem. As well as adding your workaround after line 167, I added it after line 142 to capture the case where optional characteristics are restored from cached accessories. After that, the cachedAccessories file was successfully read and homebridge restarted without errors. It appears that the root cause of the issue is that HomeKitTypes.js references "PM2.5 Density" instead of "PM2_5 Density" in line 1500 and that results in an incorrect displayName.
Thanks for your feedback. I've modified accessory.js > commid 115
Thanks @cflurin all good now. Do you plan to put the update on NPM?
V0.6.2 published
I've been unable to enable the PM2_5 Density optional characteristic for the AirQualitySensor Service. I've successfully enabled "PM10Density" but not "PM2_5Density". I can see the "PM25Density" characteristic in HomeKitTypes.js, so it should be valid. Could it be the presence of the "" character that triggers an error in homebridge-mqtt? I've spent many hours trying to get to the root cause of the problem, all to no avail. Does anyone have a suggestion?