tuya / tuya-homebridge

Homebridge custom plugin for controlling Powered by Tuya (PBT) devices in HomeKit. This plugin is officially maintained by the Tuya Developer Team.
MIT License
332 stars 168 forks source link

Support for multifunctional alarms as Security System #344

Closed bFollon closed 1 year ago

bFollon commented 1 year ago

This PR adds support for the Security System accessory on homebridge.

Please note lines 187 to 197 on index.js I've had to add this try - catch block since some Tuya alarms are not properly configured and may not have functions properly assigned, resulting in a useless accessory being added to homebridge.

To prevent home app cluttering, I've added this try - catch in addition to the checkAccessoryFunctions function in lib/security_system_accessory.js lines 183 to 188.

The rest is a pretty simple and basic implementation following homebridge documentation and tuya documentation. It doesn't manage all the states of a multifunctional alarm because it doesn't need to since the SecuritySystem accessory API is pretty simple.

I've tested this for quite a long time with some home security devices I have personally and also with some virtual devices I created at tuya iot platform and it works great.

Please provide feedback, ask any question and consider merging this PR to add official support.