snowdd1 / homebridge-knx

KNX platform shim for homebridge
https://github.com/nfarina/homebridge
GNU General Public License v2.0
97 stars 55 forks source link

Reverse seems not working #62

Closed giase82 closed 7 years ago

giase82 commented 7 years ago

Hi,

I recognised that the "reverse" keyword does not change the behaviour of my LockMechanism. The door shows open when closed and the other way around. I tried both of the following configurations. What am I doing wrong?

                    "ServiceType": "LockMechanism",
                    "ServiceName": "Tür Wohnzimmer",
                    "Characteristics": [
                        {
                            "Type": "LockCurrentState",
                            "Listen": [
                                "3/1/4"
                            ]
                        },
                        {
                            "Type": "LockTargetState",
                            "Listen": [
                                "3/1/4"
                            ]
                        }
                    ]
                },

and this

                {
                    "ServiceType": "LockMechanism",
                    "ServiceName": "Tür Wohnzimmer",
                    "Characteristics": [
                        {
                            "Type": "LockCurrentState",
                            "Listen": [
                                "3/1/4"
                            ],
                            "Reverse": true
                        },
                        {
                            "Type": "LockTargetState",
                            "Listen": [
                                "3/1/4"
                            ],
                            "Reverse": true
                        }
                    ]
                },

The Lock did not change its status.

snowdd1 commented 7 years ago

Have to look up the characteristics. Reverse does only work with Boolean and Percentage types. First guess is that LockTargetState is an integer type with discrete values for states.

snowdd1 commented 7 years ago

As I assumed, LockCurrentState
https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js#L900
is a UINT8 with values 0,1,2,3

LockTargetState https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js#L972
is a UINT8 with values 0 or 1

So no Boolean value, even if it looks as if it was.

snowdd1 commented 7 years ago

And Christof, could you read #61 for pasting code samples here? Thanks

snowdd1 commented 7 years ago

If you need other values than the ones defined by homekit, you need to write another add-in. Like I needed for my ContactSensor, because the characteristic is a UINT8, too.

giase82 commented 7 years ago

Ah makes sense! I was thinking the "old stuff" was working as before still... So in the time before addins, which code did the mapping? (I am asking as I would probably copy this one)

snowdd1 commented 7 years ago

I recommend using ContactSensor add-in as an example, because the old code worked completely different - and I forced it to be Boolean in 0.2.

giase82 commented 7 years ago

Ok, agree. We can close this then.