smartechru / homebridge-relays

This Homebridge plugin controls 4 relays through Apple Home App.
MIT License
16 stars 13 forks source link

Relay turns off after delay, but Homekit switch stays on. #7

Closed Moonmonkey-Beep closed 3 years ago

Moonmonkey-Beep commented 3 years ago

The description really explains things, I have this opening a trashcan in my kitchen so it needs to be a momentary switch (as it can only open and not close) the relay thankfully turns off after 1000 ms - the switch stays on in Homekit.

My config is :

{ "accessory": "Relay", "duration_ms": 1000, "name": "Bin", "pin": 8, "invert": true, "default_state": false }

any ideas?

smartechru commented 3 years ago

@tomwoodhams please upload the full log.

honeywelluser commented 3 years ago

I agree with OP. Log as requested:

[30/01/2021, 09:58:55] [Close Garage] Relay status for 'Close Garage', pin 11 is true
[30/01/2021, 09:58:57] [Close Garage] Relay for 'Close Garage', pin 11 timed out.

It would be good if the HomeKit button deactivated after a delay (perhaps duration_ms or another selectable value).

Poking around the code, it seems that when the callback happens:

RelayAccessory.prototype.timeOutCB = function (o) {
        o.setState(false);
        o.log("Relay for '%s', pin %d timed out.", o.name, o.pin);
        o.timerid = -1;
}

It needs to (optionally) set the HomeKit status of the relay to false.

smartechru commented 3 years ago

I've just updated the plugin and published it to npmjs store. https://www.npmjs.com/package/homebridge-relays It was tested on Raspberry pi 3B+. Any feedback is appreciated. Thanks.