howanghk / homebridge-ewelink

Homebridge plugin to control Sonoff relays with OEM firmware
MIT License
81 stars 46 forks source link

Blind #54

Closed LeJeko closed 4 years ago

LeJeko commented 4 years ago

First of all, congratulations for your work. Perfect integration with a clear code.

In my case, I use a Sonoff Dual for my outdoor roller blind and I wanted the real WindowCovering accessory in Homekit instead of two separate switches.

I added the ability to create groups to select channels from one device to create another accessory.

This work is the adaptation of the plug-in https://github.com/manolab/homebridge-sonoff-stateful-blinds that I integrated in your fork.

I did not change the general behavior. I just manipulate the switches differently if the device is part of a group.

Extract of modified ReadMe:

Groups

You can group channels of multi-switch model to simulate another accessory instead of having each switch separately. Currently, only blind (WindowCovering) is supported.

Blind

(Tested with Sonoff Dual) Simulate dual motors blind, one to move up and other to move down, without start or end detector. The duration of move is calculed from the up/down time. Handle realtime response when setting position other than Open or Close. Also responding to event from API, so you can use Home or eWelink App and have up-to-date state. The device is automatically reconfigured to turn off all options (power-on response, inching, ...) including disable Interlock that is incompatible with the behavior of this group.

To improve: 4 channels models can only use 2 channels, others will be disabled.

Group configuration:
    {
        "platform" : "eWeLink",
        "name" : "eWeLink",
        "email" : "your-email@example.com",
        "password" : "your-login-password",
        "imei" : "01234567-89AB-CDEF-0123-456789ABCDEF",
        "groups": [
            {
                "type": "blind",
                "deviceId": "1000654321",
                "relay_up": 1,
                "relay_down": 2,
                "time_up": 10,
                "time_down": 10,
                "time_botton_margin_up": 0,
                "time_botton_margin_down": 0,
                "handle_api_changes": true
            }
        ]
    }
howanghk commented 4 years ago

Thanks @LeJeko. I don't have the Sonoff dual to test if this works, I will just merge and let everybody test. 😅

LeJeko commented 4 years ago

Hi @howanghk, You are not scared 😳 Thank you for being confident ☺️ I tried to test all cases but I may have forgotten ... 😅