Skip to content

Add contact sensor state option for garage doors#32

Merged
tassy-h merged 1 commit into
homebridge-plugins:latestfrom
jmnovak50:fix/garage-door-contact-state
Jun 12, 2026
Merged

Add contact sensor state option for garage doors#32
tassy-h merged 1 commit into
homebridge-plugins:latestfrom
jmnovak50:fix/garage-door-contact-state

Conversation

@jmnovak50

Copy link
Copy Markdown

Adds an opt-in per-device setting for ckmkzq garage doors where switch_1 remains true persistently.

When garageDoorUseContactSensorForState is enabled:

  • CurrentDoorState is derived from doorcontact_state
  • TargetDoorState mirrors doorcontact_state
  • commands still use switch_1
  • default behavior is unchanged

Build passes. Full test suite has existing local-config-dependent failures when ~/.homebridge-dev/config.json is not present.

@jmnovak50

Copy link
Copy Markdown
Author

All tests are passing now. I also confirmed the opt-in behavior locally on a Tuya ckmkzq garage controller that keeps switch_1=true persistently: HomeKit now reads state from doorcontact_state while commands continue to use switch_1.

@tassy-h

tassy-h commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Hi! @jmnovak50
Thank you for the PR.

The changes you made look good, and it seems like everything should work correctly.
However, I have a feeling that the contact sensor state might actually be obtainable through the API.

Could you check whether your device’s schema includes a dpcode such as doorcontact_state (or something similar)?
If that dpcode exists, it would be better to retrieve the state directly through the API rather than enabling it manually through the plugin settings.

Since I don’t have the actual device here, it would be extremely helpful if you could look into this and make the necessary adjustments.

@jmnovak50

jmnovak50 commented Jun 11, 2026 via email

Copy link
Copy Markdown
Author

@tassy-h

tassy-h commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

I see — I finally understand the issue now.

On your device, the switch_1 value that represents the current contact state does not return the expected values.
If this is a device‑specific behavior, I think the existing deviceOverrides feature might help.
By overriding switch_1 with doorcontact_state, it should behave as expected.
Do you think this approach would work for your device?

That said, I agree that it would be much more convenient if users could simply enable this with a checkbox.
It would definitely help others who use the same device, so let's include this feature in the plugin.

Since English is not my native language, I’ll leave the naming of the setting to your sense — I trust your judgment.

@jmnovak50

jmnovak50 commented Jun 11, 2026 via email

Copy link
Copy Markdown
Author

@jmnovak50 jmnovak50 force-pushed the fix/garage-door-contact-state branch from d4073ea to af30f61 Compare June 11, 2026 15:27
@jmnovak50

jmnovak50 commented Jun 11, 2026

Copy link
Copy Markdown
Author

Validated locally with both garage controllers. After restart, both ckmkzq devices now show Closed correctly in HomeKit with garageDoorUseContactSensorForState enabled. Commands still use switch_1.

Also verified with Homebridge’s npm:
/opt/homebridge/bin/npm run build passes
/opt/homebridge/bin/npm test -- test/sanitizeName.test.ts passes

@tassy-h tassy-h merged commit 9f02e07 into homebridge-plugins:latest Jun 12, 2026
3 checks passed
@tassy-h

tassy-h commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Thank you for the fix!
I’ve released v2.3.0 with your changes, so I’ll go ahead and close this issue.

@jmnovak50

jmnovak50 commented Jun 12, 2026 via email

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants