fix(knx_windowcoverings): correct DPT 5.001 position mapping, with invert_position migration for existing devices - #87
Conversation
…dard KNX DPT 5.001 for shutter position has the inverse semantics of Homey's windowcoverings_set: - KNX: 0% = fully open (up), 100% = fully closed (down) (KNX Standard v2.1 §3.7.2; matches every major shutter actuator manufacturer: MDT JAL series, ABB JRA/S, Gira, Jung, Theben) - Homey: 1.0 = open, 0.0 = closed (https://apps.developer.homey.app/the-basics/devices/best-practices/window-coverings) Without this fix, a shutter physically closed reports 100% in Homey and the position bar sits at the 'open' side of the slider, while pressing up on the slider physically closes the shutter. Reported as issue athombv#78. The existing invert_updown setting only flips DPT 1.008 (up/down commands and status). DPT 5.001 reads/writes were not inverted, leaving the position slider permanently inverted for any KNX-standard installation. This change applies the inversion unconditionally so that the default configuration follows the KNX standard. Users who previously inverted the position in their KNX actuator (ETS) as a workaround must remove that workaround after upgrading. Fixes athombv#78
|
I understand the intention to fix this bug. |
@ttherbrink, no the up and down commands stay the same. Those are already correct, it's only the visual presence that's corrected. Unless users are sending percentages instead of UP/DOWN. |
|
Thanks for the review and the migration concern @ttherbrink — agreed, silently flipping behaviour on existing flows isn't acceptable. I'd like to propose a slightly different angle: instead of a hidden store flag set only at pair time, expose this as a per-device setting The user-visible mental model would be: "should the app compensate for the legacy position mapping to preserve old flows?"
A few reasons I think this works better than overloading
Happy to implement this if you agree on the direction — both the read/write changes and the one-time migration in |
…gacy flows Per PR review discussion: the DPT 5.001 standard-mapping fix is now gated behind a per-device invert_position setting (default off = KNX standard). Newly paired devices get a windowcoverings_set_migrated store flag from the pair view; existing devices with a configured ga_height are migrated once in onInit to invert_position=true so their sliders and set-position flows keep behaving exactly as before. Toggling the setting flips the displayed position in place. Also fixes an undefined variable in the pair view's createDevice error alert. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@ttherbrink implemented as discussed: the fix is now gated behind a per-device |
|
@ttherbrink friendly ping on this one. I see #86, #89 and #90 have landed in The revision from 24 July implements the migration exactly as we discussed: your Two small things I can fix if needed:
Happy to do the rebase straight away if that unblocks it. |

Summary
KNX DPT 5.001 for shutter position has inverse semantics from Homey's
windowcoverings_set. Theknx_windowcoveringsdriver did not account for this, leaving the position slider permanently inverted for any KNX-standard installation. This PR fixes the read and write paths so the default configuration matches the KNX standard, and adds a per-deviceinvert_positionsetting plus a one-time migration so that existing devices and their flows keep behaving exactly as before (addressing the review feedback from @ttherbrink).Fixes #78.
Why
windowcoverings_set)0/ 0%1.0/ 100%255/ 100%0.0/ 0%The KNX convention is in KNX Standard v2.1 §3.7.2 (DPT 5.001 Scaling) and in the application descriptions of every major shutter actuator manufacturer (MDT JAL series, ABB JRA/S, Gira, Jung, Theben). The Homey convention is documented at https://apps.developer.homey.app/the-basics/devices/best-practices/window-coverings (
1.0= open,0.0= closed).The existing
invert_updownadvanced setting onknx_windowcoveringscorrectly handles DPT 1.008 (it inverts both command direction andga_status). It does not apply to DPT 5.001 reads/writes onga_height/ga_height_status. As a result, a shutter that is physically fully closed reports 100% in Homey, the position bar sits at the "open" side of the slider, and dragging the slider up physically closes the shutter.What changes
A new per-device checkbox setting
invert_positionnext to the existinginvert_updown, one knob per DPT:invert_position = false(default for newly paired devices): the app follows the KNX standard — DPT 5.001 values are inverted on both the read path (ga_height_status→windowcoverings_set) and the write path (windowcoverings_set→ga_height) so they map correctly onto Homey's semantics.invert_position = true(set automatically for devices that existed before this change): the legacy mapping — position values pass through unchanged, exactly as the app behaved before. Existing "Set position" flow cards keep doing what they did.invert_updown(DPT 1.008 up/down command + status) is unchanged and stays orthogonal.Migration (no breaking change)
Per the review discussion:
windowcoverings_set_migratedstore flag on newly paired windowcovering devices (as suggested by @ttherbrink), so they start with the KNX-standard mapping.onInitafter the upgrade, devices without that flag (i.e. everything paired before this version) that have a position groupaddress configured getinvert_position = true, and the flag is then set. Their sliders, percentages, and flows behave identically to today — nothing flips on upgrade. Pre-existing devices withoutga_heighthave no position behaviour to preserve, so they simply adopt the standard mapping if a position address is added later.invert_position = true(the migration default) and are also unaffected.Drive-by one-liner: the
Homey.createDeviceerror alert in the shared pair view referenced an undefinederr(swallowing any pairing error); it now alerts the actualerror.The setting's hint text explains both states, in all 13 app languages.
Testing
The corrected KNX-standard mapping (the
invert_position = falsepath) was tested earlier on a Homey Pro 2023 with KNX-standard rollershutter actuators: position 0% on a physically closed shutter, slider on the "closed" side, up-gesture opens — matching Homey's documented semantics. The legacy path is the app's current release behaviour, unchanged.For this revision:
homey app validate -l publishpasses andapp.jsonis regenerated from compose. I'll run the migration path (upgrade of an already-paired device + toggling the setting) on my Homey Pro and report back here.