Repository navigation
sdk/homekit/unifi-protect: add USL-Smoke smoke and carbon monoxide alarms - #2233
stalinCCCP415 wants to merge 2 commits into
Conversation
…arms Add SmokeSensor and CarbonMonoxideSensor interfaces to the SDK and map them to the HAP smoke and carbon monoxide sensor services. The UniFi Protect plugin identifies the USL-Smoke by model, exposes the alarm types it advertises, and sets their state from smokeStatus.
|
I think these interfaces already exist? did you check? I swear I added these at some point. |
|
The two interfaces do not appear to exist in the current Scrypted SDK. I checked sdk/types/src/types.input.ts, the ScryptedInterface enumeration, the generated Python SDK definitions, and the published SDK documentation. None currently defines SmokeSensor or CarbonMonoxideSensor. I believe the confusion may be with the existing HAP-NodeJS HomeKit services, Service.SmokeSensor and Service.CarbonMonoxideSensor. Those services already exist, but Scrypted does not currently expose corresponding device interfaces. The purpose of this PR is to add those missing Scrypted interfaces and map them to the existing HomeKit services. |
|
PM10Sensor = "PM10Sensor", I found these, and am remembering that I then added this: export interface Sensors { I think Sensors may work. can implement that and set the relevant state in sensors dict, and HomeKit can check that to see which sensors are implemented. I want to avoid adding more interfaces to the sdk. just need to settle on standard key/values so like sensors = { etc. |
|
Thank you for the feedback. Anything you'd prefer I change or update, or are you planning to take it from here? |
propose some Sensors keys, and wire those into HomeKit instead. |
… new SDK interfaces Per review feedback, drop the SmokeSensor and CarbonMonoxideSensor SDK interfaces and use the existing generic Sensors interface with standard keys: `smoke` and `co`, value 1 when the alarm is active and 0 otherwise. - unifi-protect: the USL-Smoke implements Sensors and populates the keys from featureFlags.alarmTypes, so they exist before the first smokeStatus arrives. The last known value is kept while smokeStatus is null. - homekit: map the smoke and co keys to the HAP SmokeSensor and CarbonMonoxideSensor services, and skip devices whose only supported interface is Sensors with no keys HomeKit understands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WiS3A3J6W395CwrVv8AXs7
Why
The USL-Smoke (UniFi SuperLink smoke and carbon monoxide detector) is reported by Protect as a sensor. Today the plugin discovers it as a generic sensor (contact, alarm sound, motion, temperature, humidity, leak) and never reads its alarm state, so it cannot raise a smoke or carbon monoxide alarm in HomeKit. Scrypted also has no interface to carry that state.
What
SmokeSensor(smokeDetected) andCarbonMonoxideSensor(carbonMonoxideDetected) next toFloodSensor. Python types are regenerated; no version bump.SmokeSensorandCarbonMonoxideSensorservices on sensor accessories.marketNameofUSL Smoke, or atypestarting withUSL-Smoke-). The UP Sense advertises the same alarm types and reports an idlesmokeStatus, so the model is the only reliable signal.SmokeSensorandCarbonMonoxideSensoraccording tofeatureFlags.alarmTypes(smoke,CO), instead of the generic sensor interfaces.smokeStatus.smokeAlarmandsmokeStatus.coAlarm. WhilesmokeStatusis null the last known state is kept, so a dropout cannot clear an active alarm.The model rule and field names follow the USL Smoke support in hjdhjd/homebridge-unifi-protect. The plugin stays on
unifi-protect@4.27.5, whose typings lack these fields, so they are read through a small local type.Not included
Detector fault and end-of-life flags, battery and tamper status.
Testing
npm run buildinplugins/unifi-protectsucceeds.@homebridge/hap-nodejs2.3.0 instead: no errors insrc/types/sensor.ts.