MiguelRipoll23 / homebridge-securitysystem

Homebridge plugin that creates a security system accessory that can be triggered by HomeKit sensors.
https://www.npmjs.com/package/homebridge-securitysystem
MIT License
151 stars 13 forks source link

Trigger Alarm When any Sensor is Triggered #79

Closed ahmadnazirafiq closed 3 years ago

ahmadnazirafiq commented 3 years ago

Hi, is it possible for me to trigger alarm when any sensor was triggered at a specific time? Eg: if I set the mode to Night and have the door sensor assigned to it. If the door was opened during Night mode, the alarm will trigger. Was it possible with your plugin? I just don’t see the option using A Sensor Detects Something in Home app.

I have an Aqara G2H camera which does not expose security alarm to HomeKit, but their alert system works just like what I described. I wanted to replicate the same functionality with HomeKit.

1A78F8F1-CDD9-427C-A4A5-9620F4B0FBE9

MiguelRipoll23 commented 3 years ago

Hello!

There are two ways to do what you want to accomplish, the simple and the advanced one.

You can enable the Show Siren Mode Switches option that you can find in the advanced section and then multiple switches that will only trigger if the their mode is selected will appear.

Example: If door opens, turn on Siren Night

Also, if you have installed Eve or a similar HomeKit app you can add a condition to your automation to only work if the mode is selected

Example: if door opens and the security system’s current mode is night, turn on Siren

Hopefully this makes it more clear.

ahmadnazirafiq commented 3 years ago

Uploading FullSizeRender.mov…

Thank you! Seems to work well, I made the automation using Eve app. Considering that this plugin requires a HomePod or AirPlay speaker, is there a workaround for the sound as I have neither of those.

MiguelRipoll23 commented 3 years ago

Yes, you can connect a speaker to your Homebridge device. Install ffmpeg using the command that appears on the option description.

ahmadnazirafiq commented 3 years ago

Alright, I've connected a speaker to the included audio jack of the Pi. I have enabled Audio with an alarm sound stored in /home/pi/sounds but I don't get to hear anything if I tap the Siren tile on the Home app. How do we test and know that its working? I already have ffmpeg installed.

MiguelRipoll23 commented 3 years ago

Can you run Homebridge on debug mode using the command below and paste the log here?

homebridge -D

ahmadnazirafiq commented 3 years ago

`pi@homebridge:/var/lib/homebridge $ homebridge -D [06/01/2021, 15:24:05] Loaded config.json with 2 accessories and 7 platforms. [06/01/2021, 15:24:05] --- [06/01/2021, 15:24:06] Plugin /usr/local/lib/node_modules/homebridge-dafang does not contain a package.json. [06/01/2021, 15:24:07] Loaded plugin: homebridge-adb@1.1.5 [06/01/2021, 15:24:07] Registering platform 'homebridge-adb.HomebridgeADB' [06/01/2021, 15:24:07] --- [06/01/2021, 15:24:07] Loaded plugin: homebridge-camera-ffmpeg@3.0.3 [06/01/2021, 15:24:07] Registering platform 'homebridge-camera-ffmpeg.Camera-ffmpeg' [06/01/2021, 15:24:07] --- [06/01/2021, 15:24:07] Loaded plugin: homebridge-config-ui-x@4.36.0 [06/01/2021, 15:24:07] Registering platform 'homebridge-config-ui-x.config' [06/01/2021, 15:24:07] --- [06/01/2021, 15:24:07] Loaded plugin: homebridge-dafang-mqtt-republish@2.1.3 [06/01/2021, 15:24:07] Registering platform 'homebridge-dafang-mqtt-republish.dafangMqtt' [06/01/2021, 15:24:07] --- [06/01/2021, 15:24:07] Loaded plugin: homebridge-dummy@0.4.1 [06/01/2021, 15:24:07] Registering accessory 'homebridge-dummy.DummySwitch' [06/01/2021, 15:24:07] --- [06/01/2021, 15:24:07] Loaded plugin: homebridge-dummy-lock@0.0.1 [06/01/2021, 15:24:07] Registering accessory 'homebridge-dummy-lock.DummyLock' [06/01/2021, 15:24:07] --- [06/01/2021, 15:24:08] Loaded plugin: homebridge-mi-gateway-fm@0.2.6 [06/01/2021, 15:24:08] --- [06/01/2021, 15:24:08] Loaded plugin: homebridge-mi-heatercooler@0.0.8 [06/01/2021, 15:24:08] Registering accessory 'homebridge-mi-heatercooler.MiHeaterCooler' [06/01/2021, 15:24:08] --- [06/01/2021, 15:24:08] Loaded plugin: homebridge-mi-humidifier@2.0.0-beta.8 [06/01/2021, 15:24:08] Registering platform 'homebridge-mi-humidifier.MiHumidifier' [06/01/2021, 15:24:08] --- [06/01/2021, 15:24:08] Loaded plugin: homebridge-mi-hygrothermograph@3.0.3 [06/01/2021, 15:24:12] Registering accessory 'homebridge-mi-hygrothermograph.Hygrotermograph' [06/01/2021, 15:24:12] --- [06/01/2021, 15:24:12] Loaded plugin: homebridge-raspberrypi-remote@1.0.2 [06/01/2021, 15:24:12] Registering accessory 'homebridge-raspberrypi-remote.RaspberryPi' [06/01/2021, 15:24:12] --- [06/01/2021, 15:24:13] Loaded plugin: homebridge-securitysystem@3.6.0 [06/01/2021, 15:24:13] Registering accessory 'homebridge-securitysystem.security-system' [06/01/2021, 15:24:13] --- [06/01/2021, 15:24:13] Loaded plugin: homebridge-switchsound@1.0.4 [06/01/2021, 15:24:13] Plugin 'homebridge-switchsound' tried to register with an incorrect plugin identifier: 'homebridge-sound-button'. Please report this to the developer! [06/01/2021, 15:24:13] Registering platform 'homebridge-switchsound.SwitchSound' [06/01/2021, 15:24:13] --- [06/01/2021, 15:24:14] Loaded plugin: homebridge-videodoorbell@0.2.9 [06/01/2021, 15:24:14] Registering platform 'homebridge-videodoorbell.Video-doorbell' [06/01/2021, 15:24:14] --- [06/01/2021, 15:24:15] Loaded plugin: homebridge-xiaomi-air-purifier3@1.3.0 [06/01/2021, 15:24:15] Registering accessory 'homebridge-xiaomi-air-purifier3.XiaomiAirPurifier3' [06/01/2021, 15:24:15] --- [06/01/2021, 15:24:16] Loaded plugin: homebridge-xiaomi-fan@1.4.7 [06/01/2021, 15:24:16] Registering platform 'homebridge-xiaomi-fan.xiaomifan' [06/01/2021, 15:24:16] --- [06/01/2021, 15:24:16] Loaded plugin: homebridge-xiaomi-outlet@0.5.0 [06/01/2021, 15:24:16] Plugin 'homebridge-xiaomi-outlet' tried to register with an incorrect plugin identifier: 'homebridge-mi-outlet'. Please report this to the developer! [06/01/2021, 15:24:16] Registering platform 'homebridge-xiaomi-outlet.MiOutletPlatform' [06/01/2021, 15:24:16] --- [06/01/2021, 15:24:17] Loaded plugin: homebridge-xiaomi-purifier@1.4.9 [06/01/2021, 15:24:17] Registering accessory 'homebridge-xiaomi-purifier.MiAirPurifier' [06/01/2021, 15:24:17] --- [06/01/2021, 15:24:17] Loaded plugin: @milo526/homebridge-tuya-web@0.7.1 [06/01/2021, 15:24:17] Registering platform '@milo526/homebridge-tuya-web.TuyaWebPlatform' [06/01/2021, 15:24:17] --- [06/01/2021, 15:24:17] Loading 7 platforms... [06/01/2021, 15:24:17] [Config] Initializing config platform... [06/01/2021, 15:24:17] [Config] *** Homebridge Standalone Mode Is Depreciated ** [06/01/2021, 15:24:17] [Config] Please swap to "service mode" using the hb-service command. [06/01/2021, 15:24:17] [Config] See https://git.io/JUvQr for instructions on how to migrate. [06/01/2021, 15:24:17] [Config] Running in Standalone Mode. [06/01/2021, 15:24:17] [xiaomifan] Initializing xiaomifan platform... [06/01/2021, 15:24:17] [MiOutletPlatform] Initializing MiOutletPlatform platform... [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][INFO]** [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][INFO] MiOutletPlatform v0.5.0 By YinHang [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][INFO] GitHub: https://github.com/YinHangCode/homebridge-mi-outlet [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][INFO] QQ Group: 107927710
[06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][INFO]** [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][INFO]start success... [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][DEBUG]Initializing MiPlugBase device: 192.168.1.204, accessories size: 1 [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][DEBUG]Initializing MiIntelligencePinboard device: 192.168.1.198, accessories size: 1 [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][DEBUG]Initializing MiPlugBaseEnhanced device: 192.168.1.16, accessories size: 2 [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][DEBUG]Initializing MiPlugBaseEnhanced device: 192.168.1.165, accessories size: 2 [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][DEBUG]Initializing MiPlugBaseEnhanced device: 192.168.1.178, accessories size: 2 [06/01/2021, 15:24:17] [MiOutletPlatform] [MiOutletPlatform][INFO]device size: 5, accessories size: 8 [06/01/2021, 15:24:17] Initializing platform accessory 'Chargers'... [06/01/2021, 15:24:17] Initializing platform accessory 'Modem'... [06/01/2021, 15:24:17] Initializing platform accessory 'Dehumidifier'... [06/01/2021, 15:24:17] Initializing platform accessory 'Repellent'... [06/01/2021, 15:24:17] Initializing platform accessory 'Patio Cameras'... [06/01/2021, 15:24:17] Initializing platform accessory 'Fountains'... [06/01/2021, 15:24:17] Initializing platform accessory 'Multimedia'... [06/01/2021, 15:24:17] Initializing platform accessory 'Laser Toy'... [06/01/2021, 15:24:17] [Camera FFmpeg] Initializing Camera-ffmpeg platform... [06/01/2021, 15:24:17] [Camera FFmpeg] Initializing dafangMqtt platform... [06/01/2021, 15:24:17] [Camera FFmpeg] Configuring "Xiaofang3" on topic "Xiaomod3/Xiaofang3" with 30 second cooldown. [06/01/2021, 15:24:17] [Camera FFmpeg] Configuring "Xiaofang1" on topic "Xiaomod1/Xiaofang1" with 30 second cooldown. [06/01/2021, 15:24:17] [Camera FFmpeg] Configuring "Dafang3" on topic "DafangMod3/Dafang3" with 30 second cooldown. [06/01/2021, 15:24:17] [Video Doorbell] Initializing Video-doorbell platform... [06/01/2021, 15:24:17] [HomebridgeADB] Initializing HomebridgeADB platform... [06/01/2021, 15:24:17] Loading 2 accessories... [06/01/2021, 15:24:17] [Aircond] Initializing MiHeaterCooler accessory... [06/01/2021, 15:24:17] [Alarm] Initializing security-system accessory... [06/01/2021, 15:24:17] [Alarm] Default mode (Off) [06/01/2021, 15:24:17] [Alarm] Arm delay (0 second/s) [06/01/2021, 15:24:17] [Alarm] Trigger delay (0 second/s) [06/01/2021, 15:24:17] [Alarm] Audio (Enabled) [06/01/2021, 15:24:17] [Camera FFmpeg] Configuring accessories for Dafang3... [06/01/2021, 15:24:17] [Camera FFmpeg] Configuring accessories for Xiaofang3... [06/01/2021, 15:24:17] [xiaomifan] Removing all cached accessories [06/01/2021, 15:24:17] [xiaomifan] Init - initializing devices [06/01/2021, 15:24:17] [xiaomifan] Error: 'ip' is required but not defined for undefined! [06/01/2021, 15:24:17] [xiaomifan] Failed to create platform device, missing mandatory information! [06/01/2021, 15:24:17] [xiaomifan] Please check your device config! [06/01/2021, 15:24:17] [Camera FFmpeg] Setting up MQTT connection with topic homebridge... [06/01/2021, 15:24:17] [Camera FFmpeg] [Xiaofang3] Configuring unbridged accessory... [06/01/2021, 15:24:17] [Camera FFmpeg] [Xiaofang1] Configuring unbridged accessory... [06/01/2021, 15:24:18] [Camera FFmpeg] [Dafang3] Configuring unbridged accessory... [06/01/2021, 15:24:18] [HomebridgeADB] Creating: TV Stick [06/01/2021, 15:24:18] Xiaofang3 9F60 is running on port 43847. [06/01/2021, 15:24:18] Please add [Xiaofang3 9F60] manually in Home app. Setup Code: 102-66-550 [06/01/2021, 15:24:18] Xiaofang1 E8EB is running on port 35889. [06/01/2021, 15:24:18] Please add [Xiaofang1 E8EB] manually in Home app. Setup Code: 102-66-550 [06/01/2021, 15:24:18] Dafang3 A0A6 is running on port 39079. [06/01/2021, 15:24:18] Please add [Dafang3 A0A6] manually in Home app. Setup Code: 102-66-550 [06/01/2021, 15:24:19] [Video Doorbell] Video-doorbell Doorbell Port 1884 Server Error: listen EADDRINUSE: address already in use :::1884 at Server.setupListenHandle [as _listen2] (net.js:1318:16) at listenInCluster (net.js:1366:12) at Server.listen (net.js:1452:7) at /usr/local/lib/node_modules/homebridge-videodoorbell/index.js:176:47 at Array.forEach () at videodoorbellPlatform.didFinishLaunching (/usr/local/lib/node_modules/homebridge-videodoorbell/index.js:72:17) at HomebridgeAPI.emit (events.js:327:22) at HomebridgeAPI.signalFinished (/usr/local/lib/node_modules/homebridge/src/api.ts:251:10) at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:158:14) at cli (/usr/local/lib/node_modules/homebridge/src/cli.ts:80:10) { code: 'EADDRINUSE', errno: -98, syscall: 'listen', address: '::', port: 1884 } [06/01/2021, 15:24:19] Doorbell CB27 is running on port 39731. [06/01/2021, 15:24:19] Please add [Doorbell CB27] manually in Home app. Setup Code: 102-66-550 Setup Payload: X-HM://0023N1LTIA4C5 Scan this code with your HomeKit app on your iOS device to pair with Homebridge:

[06/01/2021, 15:24:19] Error: listen EADDRINUSE: address already in use :::51594 at Server.setupListenHandle [as _listen2] (net.js:1318:16) at listenInCluster (net.js:1366:12) at Server.listen (net.js:1452:7) at EventedHTTPServer._this.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/eventedhttp.ts:84:21) at HAPServer._this.listen (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/HAPServer.ts:236:22) at Bridge.Accessory._this.publish (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:999:18) at Server.publishBridge (/usr/local/lib/node_modules/homebridge/src/server.ts:190:17) at /usr/local/lib/node_modules/homebridge/src/server.ts:162:24 at processTicksAndRejections (internal/process/task_queues.js:93:5) at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:161:5) [06/01/2021, 15:24:19] Got SIGTERM, shutting down Homebridge... (node:8665) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Cannot stop advertisement when service wasn't yet advertised! at Advertiser.stopAdvertising (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Advertiser.ts:99:11) at Advertiser. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Advertiser.ts:104:16) at step (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Advertiser.js:57:23) at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Advertiser.js:38:53) at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Advertiser.js:32:71 at new Promise () at __awaiter (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Advertiser.js:28:12) at Advertiser.shutdown (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Advertiser.js:137:16) at Bridge.Accessory._this.unpublish (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1025:24) at Server.teardown (/usr/local/lib/node_modules/homebridge/src/server.ts:615:17) (Use node --trace-warnings ... to show where the warning was created) (node:8665) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:8665) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. [06/01/2021, 15:24:19] [Camera FFmpeg] MQTT connected. [06/01/2021, 15:24:19] [Camera FFmpeg] MQTT Connection Opened [06/01/2021, 15:24:19] [Alarm] State (Loaded) { currentState: 3, targetState: 3, armingDelay: true } [06/01/2021, 15:24:19] [Alarm] Saved state (Found) [06/01/2021, 15:24:19] [Alarm] Current mode (Off) [06/01/2021, 15:24:19] [Alarm] Arming delay (On) pi@homebridge:/var/lib/homebridge $ `

MiguelRipoll23 commented 3 years ago

Can you paste the log when switching to the mode that should play sound?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

MiguelRipoll23 commented 3 years ago

If the issue persists please re-open this issue.

Thank you.