rasod / homebridge-dummy-garage

Dummy Garage Opener for Homebridge
17 stars 10 forks source link

Persist state across Homebridge reboots? #3

Closed name99-org closed 4 years ago

name99-org commented 4 years ago

Like other users I love this plugin and the way you can effectively use it with CarPlay to run scenes when you leave and return to the house. (Basically you can have various scenes triggered by when the dummy garage door opens or closes. I trigger lights, door locks, burglar alarm, cameras, etc. The advantage of using dummy garage, even if you have a smart garage door, like I do, is that you don't want the scenes triggered by opening the real door, because then they will trigger whenever you open/close the garage door to move out the lawn mower or whatever. By keying the scenes off the dummy door, you can ensure that changing the dummy door state correlates with actual intent to leave the house.)

But there is one small bug which is the following: Given the setup I described above, the normal way I use the dummy door is that I leave home, I tell CarPlay to close the dummy door, and the state of the door when I am away is "closed". Likewise when I return home the dummy door is opened and its state, while I am home, is "open". So far so good. Now assume that I restart HomeBridge for some reason (maybe a plugin is updated, maybe macOS is updated). When HomeBridge (and in particular homebridge-dummy-garage) restarts, it restarts in the state "closed", not in the state it was occupying before the restart (which was probably "open".) This confused the heck out of me the first two times it happened, when I got into the car and CarPlay displayed the garage door in the wrong state, and scared me that maybe there was something fundamentally unreliable about my setup!

So I'd suggest that either this be treated as a bug, or at least be treated as an option for some users, that after a reboot, dummy garage be restored to the same open/close state that it had before the reboot. Does that make sense?

rasod commented 4 years ago

Interesting, I’ve never thought of that use case. I’ll have to do some research as I’m not 100% sure how to accomplish saving the state between restarts.

name99-org commented 4 years ago

That's the fun of opens-source programming! People figure out ways to use your tools that you never imagined :-)

I'm no JS expert (especially once you get to the nodeJS world that's no longer in the browser). But https://www.npmjs.com/package/node-persist https://www.npmjs.com/package/node-persist seems to do the job? Maybe there's something even simpler given how easy this task is (just storage of one bool, no need for speed, async, or anything else like that)?

On Aug 5, 2020, at 4:05 PM, rasod notifications@github.com wrote:

Interesting, I’ve never thought of that use case. I’ll have to do some research as I’m not 100% sure how to accomplish saving the state between restarts.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rasod/homebridge-dummy-garage/issues/3#issuecomment-669589380, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLDU26ENRBLDYFNP2CQJJ3R7HQUFANCNFSM4PV7NA2Q.

rasod commented 4 years ago

@name99-org I just published 1.2.0 which should keep the state of the door between restarts. Hopefully it works since I could only test on my development environment. My main environment is grossly out of date and i'm not looking forward to updating it.

name99-org commented 4 years ago

Woo hoo! OK, I'll update now and let you know in a day or two if it appears to work. Thanks for looking into this :-)

On Aug 11, 2020, at 12:38 PM, rasod notifications@github.com wrote:

@name99-org https://github.com/name99-org I just published 1.2.0 which should keep the state of the door between restarts. Hopefully it works since I could only test on my development environment. My main environment is grossly out of date and i'm not looking forward to updating it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rasod/homebridge-dummy-garage/issues/3#issuecomment-672223652, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLDU2ZNTK6UIONYWA3BZ7TSAGM43ANCNFSM4PV7NA2Q.

name99-org commented 4 years ago

So far so good! I tried a HomeBridge restart, an OS restart, and have left and returned once, and in all cases everything is working as expected. Nice job :-)

On Aug 11, 2020, at 12:38 PM, rasod notifications@github.com wrote:

@name99-org https://github.com/name99-org I just published 1.2.0 which should keep the state of the door between restarts. Hopefully it works since I could only test on my development environment. My main environment is grossly out of date and i'm not looking forward to updating it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rasod/homebridge-dummy-garage/issues/3#issuecomment-672223652, or unsubscribe https://github.com/notifications/unsubscribe-auth/APLDU2ZNTK6UIONYWA3BZ7TSAGM43ANCNFSM4PV7NA2Q.