bwp91 / homebridge-ewelink

Homebridge plugin to integrate eWeLink devices into HomeKit.
MIT License
384 stars 127 forks source link

Switch for DIY Obstruction Detection #180

Closed MoTechnicalities closed 3 years ago

MoTechnicalities commented 3 years ago

How can I add a 3rd sensor in the plugin configuration to support Obstruction Detection for a garage door. Is this possible? I currently use the Eachen GD-DC5 configuration, and would like to support this additional HomeKit protection feature.

bwp91 commented 3 years ago

Hi @MoTechnicalities It isn't possible to any extra sensors to the GD-DC5 configuration (to use with the plugin), as the GD-DC5 device itself has a sensor to determine the current open/close status of the garage. Thanks and sorry I can't be of more help with this!

MoTechnicalities commented 3 years ago

Thanks for answering. But under the HOOBS eWeLink plugin I am not limited to using the Eachen's onboard Open/Closed state sensor. Because, with "sensorId" I can assign any other eWeLink sensor to that purpose. So, just as the plugin can allow two different devices (a switch and a sensor) to be combined for garage door functionality under HomeKit, I am actually asking if the plugin can be made to support the HomeKit Obstruction Detection feature?

Currently, if I press the HomeKit icon to open my garage but physically force the door to stay closed, the icon stays in an  infinite "Opening..." state. Well past the 10 seconds I set using "operationTime": 100. Same if I force the door to stay open. Then it infinitely reports "Closing...". It would seem to me that this is a plugin bug issue when it does not report an Obstruction, but Infinitely loops.

bwp91 commented 3 years ago

Hi @MoTechnicalities

The sensorId option which is part of the group configuration is only valid for type: garage, not type: garage_eachen. In other words, adding the extra sensor to the Eachen device setup will have no effect. For the GD-DC5, the plugin uses the in-built sensor to determine the current state of the door. This is under 'normal' circumstances. I would consider using force to keep the door open/closed abnormal circumstances!

The "obstruction detected" feature would be difficult to implement as for all garage door setups.

The plugin only has two statuses for a garage door - CLOSED and NOT CLOSED. It cannot tell between a door slightly open and a door fully open as indeed in both these cases the door is still NOT CLOSED. The plugin would not be able to differentiate between an opening door that had gotten stuck, and an opening door that had completely opened.

It would be possible for the plugin to determine whether a door has taken significantly longer to close, based on the operation time, and in this case could show an "obstruction detected", but I am rather hesitant to add a feature just for one way of the door working.

MoTechnicalities commented 3 years ago

Got it. But you could perhaps consider advancing the plugin to take advantage of using optional separate sensors at each end of the track to detect a timeout of an open close state. The fist sensor closure for door closed, and an optional second eWeLink sensor closure for door fully open. Just a thought. Thanks.

MoTechnicalities commented 3 years ago

I want to apologize and start over, because I realized that I first need to know: What does HomeKit do if the "Obstruction Detected" variable is set to YES?

Does it 1) disable the button and automations from activating the garage door because it detects something in the path? (i.e. sensor detects a kid is in the way of the door, so now it won't let the door activate)

Or is it 2) simply for letting you know that the door is stuck and didn't finish what it started to do?

I prefer the first, but up-to-now have only been presuming the second.

I now think the second case is already taken care of when the icon is continuously stuck in (Opening...) or (Closing...). HomeKit is already giving you information that the door didn't finish its job.

bwp91 commented 3 years ago

Hi @MoTechnicalities

I don't have a garage myself so I have never played around with how ObstructionDetected works when it appears. I thought I could let you test it out yourself if you're willing!

I have released a beta version of the plugin which will allow you to activate the ObstructionDetected characteristic of your garage.

  1. Please update to the beta of the plugin, you'll need version 4.2.3-0. Not sure how you run Homebridge so here is a link for reference - https://github.com/bwp91/homebridge-ewelink/wiki/Beta-Version.
  2. Edit your Homebridge config file directly, adding the line (where 1000##### is the eWeLink ID of the device): "obstructGarage": "1000#####",
  3. Restart Homebridge.
  4. Now when you control your garage, after four seconds the ObstructionDetected will set to true.
  5. Each time you restart Homebridge, the ObstructionDetected will revert back to false.
  6. And when you want to go back to normal, just delete the config line and restart Homebridge.

Hopefully this will help you find out what you need as as I said, this is something I have never experimented with, and my lack of garage means it is difficult to.

I would be interested in knowing how it works if you manage to :)

MoTechnicalities commented 3 years ago

Ok. I tried. I am running HOOBS, and confirmed the beta plugin version 4.2.3-0. At the moment I only have 2 eWeLink compatible devices. Garage: Eachen GD-DC5: "1000873168" Switch: Sonoff Basic: "100089a31b"

I tried it with the following config for GROUPS:

[ { "deviceId": "1000873168", "type": "garage_eachen", "setup": "oneSwitch", "operationTime": 100, "sensorId": "1000873168", "obstructGarage": "1000873168" } ]

The garage worked as usual and the ObstructionDetected value never changed from NO.

I also tried with the following config for GROUPS:

[ { "deviceId": "1000873168", "type": "garage_eachen", "setup": "oneSwitch", "operationTime": 100, "sensorId": "1000873168", "obstructGarage": "100089a31b" } ]

I tried with the Sonoff tuned ON and tuned OFF, but the value of ObstructionDetected value never changed.

I have a second Eachen arriving soon for my second door, and will play around with it before installing it on the other door. Let me know if there is anything else you want me to try. Thanks.

bwp91 commented 3 years ago

Ah I should have clarified better - the config line needs to go not in the group section but in the main section e.g.

"username": "",
"password": "",
"obstructGarage": "100089a31b",
"groups" []
MoTechnicalities commented 3 years ago

Ok, I tested the second config. still no results. The Obstruct remained "NO" in all scenarios.

One point of note: In any final version, the Obstruct Device will need to be associated with the individual garage door setup under the GROUP array, for individuals that may have an array of multiple garage doors. I myself will have 2 doors to support (an Eachen GD-DC5 on each door each with its own obstruction detection)(if possible). So, I am happy to work with you on this. Thanks.

bwp91 commented 3 years ago

Please update to the latest beta (4.2.3-3) and try again. I tested this by turning my single light switch into a garage door (!) and the obstruction detected definitely showed YES when I operated the garage. Please also verify that the ewelink ID you placed in the config matches your garage door.

The Obstruction Detected feature is not on my list of planned features. I just wanted to give you a chance to test how it works with regards to your previous question

What does HomeKit do if the "Obstruction Detected" variable is set to YES?

Hope this helps

MoTechnicalities commented 3 years ago

Success! And thank you for letting me test. I now understand the Obstruction Detected feature. In HomeKit this is only an exclamation mark (!) notice on the icon (see the pictures below with my garage door open and closed). WARNING!!! IT DOES NOT DISABLE THE HOMEKIT BUTTON OR AUTOMATONS.

Therefore, when configured ideally for a true protection function under HOOBS with the eWeLink plugin:

  1. If an Obstruction Detection device (DEVICE A) such as an infrared beam detects something in the door's path, it would report to the eWeLink plugin which turns HomeKit Obstruct Detect to YES for that Garage Setup.
  2. The same (DEVICE A) (or a Device linked to it) must create an OPEN CIRCUIT in the actual button press circuitry coming from the Eachen GD-DC5 (DEVICE B) to prevent any hazardous HomeKit activation.

DEVICE A: would consist of 1 LASER or IR emitter and detector with 1 Normally Closed dry circuit that goes Open if the beam is broken, and changes eWeLink obstructDetected from Normally NO to YES.

DEVICE B: Eachen GD-DC5 or similar device with its button press circuit made interruptible by DEVICE A.

Alternately (a more technical but more fail safe solution): DEVICE A would interrupt low voltage power to the relay that controls high current power to the drive motor. This would prevent door activation and also stop the door if something tripped the Obstruction Detect after the door had already been activated.

Conclusion: It would be possible to design a single device similar to the Eachen GD-DC5 with all of the necessary sensory and switch circuitry to support full protection, or incorporate a home-made solution if the eWeLink plugin were to support one extra optional sensor for obstruction detection purposes per garage under the Group array.

imageimage

stale[bot] commented 3 years ago

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

MoTechnicalities commented 3 years ago

So I understand that you earlier stated:

The Obstruction Detected feature is not on my list of planned features. I just wanted to give you a chance to test how it works with regards to your previous question

Still I would like to know if it would be difficult for you to implement a solution where one Sonoff relay could optionally be exposed as an Obstruction Detection device for each Garage Door under the Group array?

I have checked, and seemingly no DIY wifi opener units, not even the Meross HomeKit device, has implemented this feature, short of purchasing a completely new garage door opener unit like a Genei unit or something that comes with the LASER safety beam sensors.

So, If you implement such feature, You would certainly be presenting us DIYers with a great solution.

My hope is to have a beam trigger a Sonoff relay and do as I've mentioned above, like this: DIY LASER barrier with a SONOFF MINI!

In any case, please consider it, Thanks again!

bwp91 commented 3 years ago

So it would involve just using a sonoff mini (or some other single channel device), and depending on the state of the switch, for example,

ON <=> obstruction detected = YES OFF <=> obstruction detected = NO

If this is the case then I think this would be relatively simple, and possible.

MoTechnicalities commented 3 years ago

So it would involve just using a sonoff mini (or some other single channel device), and depending on the state of the switch, for example,

ON <=> obstruction detected = YES OFF <=> obstruction detected = NO

If this is the case then I think this would be relatively simple, and possible.

Yes. The plugin would allow a Sonoff to be identified (optionally) as part of the garage grouping and report its state to HomeKit's obstruction detect variable. After that, the Do-It-Yourselfer can design his own detection input method (be it laser or whatever) to the Sonoff, and execution output method (to interrupt the doors mechanical execution), OR minimally to be given true NOTICE (!) that there is some kind of obstruction.

The benefit of implementing the feature will allow Do-It-Yourselfers to meat safety standards that are currently only met by expensive major brand door openers, and even then most brands don't automatically support much desired HomeKit accessability. I see it as a big plus for using [ HOOBS + Ewelink + Sonoff ] over other options, including the meross Smart Garage Door Opener Remote (HomeKit version), because the meross Smart Garage Door Opener Remote does not support this safety feature.

Thanks,

bwp91 commented 3 years ago

Would it be more practical to have:

device ON <=> obstruction detected = YES device OFF <=> obstruction detected = NO

or

device ON <=> obstruction detected = NO device OFF <=> obstruction detected = TES

MoTechnicalities commented 3 years ago

I think: device ON <=> obstruction detected = YES device OFF <=> obstruction detected = NO

But its more practice to see it in action this way. LASER Beam unbroken = <=> device OFF <=> obstruction detected = NO (AND Button Circuit Closed) LASER Beam broken = <=> device ON <=> obstruction detected = YES (AND Button Circuit Open)

bwp91 commented 3 years ago

@MoTechnicalities Might be simpler to message you on my discord server if you can join? https://discord.gg/cMGhNtZ3tW

github-actions[bot] commented 3 years ago

This issue has been marked as complete as I believe the original query has been fixed/answered or will not be actioned. The issue will be closed in three days. If you feel the issue requires further attention then please let me know. Thanks!

MoTechnicalities commented 3 years ago

Just letting you know the final results are perfect! Two doors working with true HomeKit Obstruction Detection plus Activation Protection. Each door setup with:

My E3JK and MINI are wired to 110v power in parallel. The E3JK's Normal Open and Common go to the MINI to activate when beam is broken. And, the Normal Close and Common act as a pass through for the Eachen and the Real Button, but interrupt them if the beam is broken.

Thank you for this excellent software upgrade!

image