Skip to content

Fix XHS2-UE battery voltage curve#12609

Merged
Koenkk merged 1 commit into
Koenkk:masterfrom
klinquist:codex/xhs2-ue-battery-voltage-curve
Jul 4, 2026
Merged

Fix XHS2-UE battery voltage curve#12609
Koenkk merged 1 commit into
Koenkk:masterfrom
klinquist:codex/xhs2-ue-battery-voltage-curve

Conversation

@klinquist

Copy link
Copy Markdown
Contributor

Summary

Fixes #12608.

This updates the Universal Electronics Inc XHS2-UE / URC4460BC0-X-R contact sensor battery curve to derive percentage from measured voltage:

  • changes voltageToPercentage from 3V_2100 to {min: 2500, max: 2800}
  • adds a regression test that 2800mV reports 100% even when the device reports a stale 27%

Why

This is the same behavior fixed for the Sylvania 74388 contact sensor in #12486: after a fresh battery change, the device can report a healthy/full voltage while also reporting a stale low battery percentage.

For XHS2-UE, the observed state was:

{
    "battery": 27,
    "battery_low": false,
    "contact": true,
    "linkquality": 188,
    "tamper": false,
    "temperature": 20,
    "voltage": 2800
}

Using {min: 2500, max: 2800} matches the previously merged Sylvania fix and treats 2800mV as full.

Tests

  • pnpm exec vitest run --config ./test/vitest.config.mts test/fromZigbee.test.ts
  • pnpm run check
  • commit hook: pnpm run build
  • commit hook: pnpm run check
  • commit hook: pnpm test

@klinquist klinquist marked this pull request as ready for review July 2, 2026 19:52
@Koenkk

Koenkk commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Could you fix the merge conflict?

@klinquist klinquist force-pushed the codex/xhs2-ue-battery-voltage-curve branch from dd0d922 to 590fd3e Compare July 3, 2026 11:10
@klinquist

Copy link
Copy Markdown
Contributor Author

Thanks for the heads up. I rebased the branch on the latest upstream master and resolved the merge conflict.

@Koenkk Koenkk merged commit 770439c into Koenkk:master Jul 4, 2026
3 checks passed
@Koenkk

Koenkk commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Thanks!

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.

XHS2-UE reports low battery percentage with 2800mV after fresh battery

2 participants