rooi/homebridge-foscam

Suggestion: Implement as security system instead of motion sensor

Closed this issue · 8 comments

I am looking through HAP-NodeJS and found out that there's a SecuritySystem service. We can take advantage of that and implement the Foscam plugin as a SecuritySystem.

The nice thing is that SecuritySystem already included a writable characteristic SecuritySystemTargetState which we can use to switch on/off (arm/disarm) the motion detection. In that way, we don't need to implement an extra switch via addCharacteristic for turning on/off the motion detection.

Moreover, HomeKit gives me a nice push notification whenever I arm, disarm or trigger the SecuritySystem.

I already finish coding on my own HomeBridge and it works pretty well for me. I can go ahead and create a PR if you think that's a good idea.

rooi commented

I've seen that option as well and was thinking about including it. Nice work that you've already done it! A PR is always fine, bur I have no computer at the moment to test and include it myself.

Thanks!

Since SecuritySystem has 4 different types of states, do you have any suggestions on mapping the states to the Foscam state?

0 - STAY_ARM
1 - AWAY_ARM
2 - NIGHT_ARM
3 - DISARMED

Currently, I map DISARM to motion detection off and AWAY_ARM to motion detection on. Should I use STAY_ARM as a switch to take snapshot or you have other suggestions? STAY_ARM and NIGHT_ARM are unused currently.

rooi commented

Ah, now I remember. This is why I initially choose the motiondetection with added switch. Perhaps it's better to use separate switches? Someone may what to trigger emails while they are away, while others may trigger the sound alarm. I think it's difficult to come up with a generic solution that can fit everyone's needs, but perhaps I'm wrong.
Btw you can use homekit triggers to set each switch (email, alarm, etc) to state like I'm leaving and such. I'm using an applescript right now that detects if I'm at home using ping and sends a video if I'm away using iMessage.

TargetState is basically a switch but instead of having 2 states, it has 4 states. It can be used to trigger events just like a switch. The reason I am proposing this is because an added switch is not a generic characteristic. I can only access that using the HMCatalog app. Other apps like iDevice doesn't even show that switch.

rooi commented

You're right, that also something to consider.

One more thing, we can add flexibility of letting users to configuring different state using config.json. Just import from config.json and translate to language understood by setMotionDetectConfig

Just added configurable state via config.json. Check my PR 😄

rooi commented

Merged your pull request. Works great! Thanks!