Request for change to HKLS to accommodate a new VGD state

A plugin to integration Indigo devices into HomeKit (and Siri)
User avatar
papamac
Posts: 168
Joined: Wed Jan 29, 2014 2:07 pm

Request for change to HKLS to accommodate a new VGD state

Post by papamac »

Hi Glenn,

I am adding a LOCKED state to the Virtual Garage Door (VGD) opener device as part of a future VGD plugin security upgrade. Unfortunately Apple has not provided a LOCKED state in the HomeKit garage door state enumeration. The following minor changes to HLKS v0.6.65 plugin.py will substitute the CLOSED state for the LOCKED state to preserve HKLS/HomeKit functionality.

1. Change line 2029 to

Code: Select all

                       # doorState:    0 -> open, 1 -> closed, 2 -> opening, 3 -> closing, 4 -> stopped, 5 -> reversing, 6 -> locked
2. Change line 2049 to

Code: Select all

                               currentDoorState = (0, 1, 2, 3, 0, 2, 1)[newstate]
3. Change line 2053 to

Code: Select all

                               targetDoorState = (0, 1, 0, 1, 0, 0, 1)[newstate]
4. Change line 2057 to

Code: Select all

                               obstructionDetected = (None, 0, None, None, 1, 1, None)[newstate]
5. Add a new line after line 2728

Code: Select all

                        doorState = indigodevice.states[stateName]  # Get Indigo doorState (0-6)
6. Change line 2729 to

Code: Select all

                        return (0, 1, 2, 3, 0, 2, 1)[doorState]     # Return HomeKit currentDoorState (0-3)
7. Delete lines 2037, 2038, 2044, 2061, and 2062. These are obsolete comments that remain from the original VGD modification.

I have successfully tested these changes in my home system. Please add them to your next HLKS release. There is no hurry since my VGD security update will probably not be released until the end of July.

Thanks for your help.

David (aka papamac)
User avatar
papamac
Posts: 168
Joined: Wed Jan 29, 2014 2:07 pm

Re: Request for change to HKLS to accommodate a new VGD state

Post by papamac »

Hi Glenn,

In my previous post, I requested that you make changes to HLKS to accommodate a new LOCKED state that I intended to include in the opener device in my upcoming VGD security release. As it turns out, these changes will not be needed. In my latest pre-release version, I chose to use the onOffState in the linked VGD lock device in lieu of the LOCKED doorState in the opener device, No new opener device doorState... no changes to HKLS needed. This is a more elegant solution with cleaner code and fewer dependencies. My current interim version of the VGD plugin with the security features is running with the official Indigo Plugin Store release of HKLS (v0.6.61).

Having said that, there is one obscure case which will cause HLKS to issue a cascading series of exceptions ending with a "NoneType" error which causes an entire bridge to fail initialization. If the garage door is in the STOPPED state (doorState = 4) and HKLS is reloaded, the currentDoorState value is considered invalid causing the chain of initialization errors. Although this is a rare occurrence, it will happen with both old and current versions of VGD and HKLS since we included the HKLS doorState changes. This was my bad... I missed this one when proposing the initial doorState changes. Fortunately, only 2 lines of code are needed to fix this:

1. Add a new line after line 2728 in HLKS v0.6.65 plugin.py:

Code: Select all

                        doorState = indigodevice.states[stateName]  # Get Indigo doorState (0-5)
2. Change line 2729 in HLKS v0.6.65 plugin.py: to:

Code: Select all

                        return (0, 1, 2, 3, 0, 2)[doorState]     # Return HomeKit currentDoorState (0-3)
Also, if you wish to do dome clean-up, you can delete lines 2037, 2038, 2044, 2061, and 2062 from HLKS v0.6.65 plugin.py. These are obsolete comments that remain from the original VGD modification.

Finally, if by chance, you have already included my requested changes from the previous post in some interim version of HLKS that is not currently on GitHub, it's OK. These changes will also work with both the current VGD plugin and future one with the security features. The deprecated LOCKED state (doorState = 6) is just not used. The changes also fix the obscure initialization error.

I request that you include these changes at your convenience in some future HKLS release. Timing is not an issue as my future VGD release will work with the current HLKS. I don't think that anyone besides me has encountered the obscure initialization error, so that should not be not a problem either.

Thanks,

David Krause (aka papamac).
Post Reply

Return to “HomeKitLink Siri”