HomeKit MetaData for Door/Window zones seems to have different state than simple ContactSensor MetaData

Good afternoon, all.

Running OpenHAB 3.1 on a Pi (the OpenHABian image). It’s purpose is to basically HomeKit-enable an old HAI/Lutron Omni panel, but this issue/question isn’t really about that, as that linkage works fine.

Within v3, a TON of HomeKit tags now allow a robust set of features to be integrated/exposed, which has wanted us to change how we apply the tags. For example, in the past, on the security system zones, we’d simply tag them all as Contact Sensors, then in HomeKit we’d assing them as the types of devices they are.

However, in OH3, we now can now tag things like “Door, ContactSensor”, which allows HomeKit to already know it’s a door, apply the correct icon, and even place it in the newer sub-panes of “doors”, “windows”, “sensors”, etc.

Just got to actually test this for the first time, and discovered an oddity. OpenHAB shows the zone state correctly as “closed”, and when you have the channel’s HomeKit MetaData as just “ContactSensor” (telling it within HomeKit to display as Door), it shows Closed (matching the OpenHAB state). However, when the MetaData is actually “Door, ContactSensor”, it instead shows the door as open. Now, I haven’t gotten a chance to test if it’s truly reversed (meaning, when the door is actually opened, does it show as closed in HomeKit), because this is a home the owners aren’t at yet until next week. But, I did test use of the “inverted” config flag, and that didn’t seem to make a change.

Here’s the MetaData we have assigned to the zone:

value: ContactSensor,Door
config:
  inverted: "true"

I had expected that the INVERTED flag would have reversed the state being reported to HomeKit, and if so, then I could do some testing on zones I know that are actually open.

One other thing I noticed in testing, I also tried “Door, Door.CurrentPosition” as well as “Door, Door.PositionState”, and it was showing “99%”. I’m thinking the return code is “1” for secure, meaning an inverted value is going to be 99, hence that display), but 1 or 99, is still higher than 0. I’m thinking, if I were to write the translation/inversion to be “if 0, send a 1 and if anything higher than a 1, send 0”, which may fix the issue (just a guess and more random thought than anything).

Does anyone have a thought on this?

Thanks.

Hi Kristian,

the doors in homekit according to apple are always motorized door and dont have status open/close but rather currentPosition and targetPosition, which can be 0% to 100%. therefor the contact value (0 or 1) gets converted to 100% or 99%

if you only need open/close then you need to user contact sensor only and select a suitable icon in home app for it.