nfarina / homebridge-dummy

Dummy switches for Homebridge: https://github.com/nfarina/homebridge
262 stars 82 forks source link

Resettable timed switch #76

Open matscb opened 1 year ago

matscb commented 1 year ago

If a resettable timed switch is cleared externally for example from an automation I would like the timer to stop. Now I believe it continues to run? This could also be a selectable option.

mkz212 commented 1 year ago

At the moment it is so that the regular switch is only reset when it is turned off, and the Reverse switch when it is turned on. I proposed to the author a change so that each activity resets the timer - E.G. we have the switch turned on, the automation turns it on (again) and the timer resets. #82

matscb commented 1 year ago

Yes, that would solve my issue and will be very useful.

mkz212 commented 1 year ago

See also #84

matscb commented 1 year ago

Looks good! i hope it will be added soon ...

arcaholic commented 8 months ago

homebridge-dummy v0.9.0

please correct me if i misunderstand this feature. I expect that when resettable is enabled that every time it is turned on before the timer expires the timer resets to 0. to me this would keep the switch on until the timer runs down.

example: motion event turns on switch with 1 minute resettable time every 10 seconds there is a motion event over the next 5 minutes the switch should not turn of until 1 minute after the last motion event.

what seems to happen is: motion event turns on switch with 1 minute resettable time motion events every 10 seconds. logs show switch event turning on. after 1 minute the switch tuns off.

so it looks like the switch turns off after the initial time expires.

mkz212 commented 8 months ago

@arcaholic see #84

Resettable means here that if you have the Switch set, for example, for 10 minutes and let's say in the 8th minute you run this switch, the time will extend from 8 minutes by another 10 minutes. If resetable is turned off, the timer will turn off after the specified time.

arcaholic commented 8 months ago

ok so exactly as i expected. that doesnt happen.

On Nov 6, 2023, at 8:37 PM, mkz212 @.***> wrote:

@arcaholic https://github.com/arcaholic see #84 https://github.com/nfarina/homebridge-dummy/issues/84 Resettable means here that if you have the Switch set, for example, for 10 minutes and let's say in the 8th minute you run this switch, the time will extend from 8 minutes by another 10 minutes. If resetable is turned off, the timer will turn off after the specified time.

— Reply to this email directly, view it on GitHub https://github.com/nfarina/homebridge-dummy/issues/76#issuecomment-1797132476, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEK6YUTFXXXTGC4XZBRWAKTYDGGFPAVCNFSM6AAAAAAU3RQUISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJXGEZTENBXGY. You are receiving this because you were mentioned.

mkz212 commented 8 months ago

At the moment (in original plugin code) it is so that the regular switch timer is only reset when switch is turned off, and the Reverse switch timer is reset when Switch is turned on.

I proposed to the author a change so that each activity resets the timer - E.G. we have the switch turned on, the automation turns it on (again) and the timer resets. https://github.com/nfarina/homebridge-dummy/issues/84

arcaholic commented 8 months ago

so if reverse is enabled the timer is extended for off. but if reverse is not enabled the time is not extended for on?

On Nov 6, 2023, at 8:47 PM, mkz212 @.***> wrote:

If you have reverse: true switch time is extended after each turning off only. Corrected this is in #84 https://github.com/nfarina/homebridge-dummy/issues/84 — Reply to this email directly, view it on GitHub https://github.com/nfarina/homebridge-dummy/issues/76#issuecomment-1797147287, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEK6YUQBPVARXYPJFKGEB4LYDGHJTAVCNFSM6AAAAAAU3RQUISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJXGE2DOMRYG4. You are receiving this because you were mentioned.

mkz212 commented 8 months ago

That's why I suggested corrections in #84 . In my opinion, each motion detection should extend the timer. It currently works differently.

64Spaces commented 8 months ago

@incline02, @mkz212, Thanks so much for working on this. Does this fork of this plug-in work properly for the Resettable Timed Switches? https://github.com/incline02/homebridge-dummy-incline_02-beta

mkz212 commented 8 months ago

Yes.

arcaholic commented 8 months ago

I can see the dilemma. switch turns on and resets timer. switch turns off and resets timer. it would be an endless loop of resetting the timer.

but if you check the state of reversable..

if reverse state is not checked. only reset the timer when the switch is turned on.

if reverse stat is checked. only reset the timer when the switch is turned off.

this will prevent and endless loop and would allow for a resetable timer in both instances.

mkz212 commented 8 months ago

There is no infinite loop in my code. I have had this code for many months and I use it.

So THERE IS NO LOOP!

64Spaces commented 8 months ago

@mkz212, I concur. I installed your code yesterday and have been configuring and testing it. The Reset feature works very well now. I’m finally able to undo some bandaids around this setting. Thanks so much for your code.

mkz212 commented 8 months ago

@64Spaces I'm glad it help you. To tell you the truth, I looked through the Issues and what people need. I wrote this code hoping that the author ( @nfarina ) would include it and make it available to everyone.